Skip to content

Commit b3f85b9

Browse files
committed
IRC bridge: Do not append "_zulip" to the specified nickname.
1 parent 9315324 commit b3f85b9

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

zulip/integrations/bridge_with_irc/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Usage
44

55
```
6-
./irc-mirror.py --irc-server=IRC_SERVER --channel=<CHANNEL> --nick-prefix=<NICK> --stream=<STREAM> [optional args]
6+
./irc-mirror.py --irc-server=IRC_SERVER --channel=<CHANNEL> --nickname=<NICK> --stream=<STREAM> [optional args]
77
```
88

99
`--stream` is a Zulip stream.
@@ -14,12 +14,10 @@ IMPORTANT: Make sure the bot is subscribed to the relevant Zulip stream!!
1414

1515
Specify your Zulip API credentials and server in a ~/.zuliprc file or using the options.
1616

17-
IMPORTANT: Note that "_zulip" will be automatically appended to the IRC nick provided, so make sure that your actual registered nick ends with "_zulip".
18-
1917
## Example
2018

2119
```
22-
./irc-mirror.py --irc-server=irc.freenode.net --channel='#python-mypy' --nick-prefix=irc_mirror \
20+
./irc-mirror.py --irc-server=irc.freenode.net --channel='#python-mypy' --nickname=irc_mirror \
2321
--stream='test here' --topic='#mypy' \
2422
--site="https://chat.zulip.org" --user=<bot-email> \
2523
--api-key=<bot-api-key>

zulip/integrations/bridge_with_irc/irc-mirror.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,17 @@
1010

1111
import zulip
1212

13-
usage = """./irc-mirror.py --irc-server=IRC_SERVER --channel=<CHANNEL> --nick-prefix=<NICK> --stream=<STREAM> [optional args]
13+
usage = """./irc-mirror.py --irc-server=IRC_SERVER --channel=<CHANNEL> --nickname=<NICK> --stream=<STREAM> [optional args]
1414
1515
Example:
1616
17-
./irc-mirror.py --irc-server=127.0.0.1 --channel='#test' --nick-prefix=username --stream='test' --topic='#mypy'
17+
./irc-mirror.py --irc-server=irc.freenode.net --channel='#test' --nickname=username --stream='test' --topic='#mypy'
1818
1919
--stream is a Zulip stream.
2020
--topic is a Zulip topic, is optionally specified, defaults to "IRC".
2121
--nickserv-pw is a password for the nickserv, is optionally specified.
2222
2323
Specify your Zulip API credentials and server in a ~/.zuliprc file or using the options.
24-
25-
Note that "_zulip" will be automatically appended to the IRC nick provided
2624
"""
2725

2826
if __name__ == "__main__":
@@ -31,7 +29,7 @@
3129
)
3230
parser.add_argument("--irc-server", default=None)
3331
parser.add_argument("--port", default=6667)
34-
parser.add_argument("--nick-prefix", default=None)
32+
parser.add_argument("--nickname", default=None)
3533
parser.add_argument("--channel", default=None)
3634
parser.add_argument("--stream", default="general")
3735
parser.add_argument("--topic", default="IRC")
@@ -51,10 +49,10 @@
5149
)
5250
sys.exit(1)
5351

54-
if options.irc_server is None or options.nick_prefix is None or options.channel is None:
52+
if options.irc_server is None or options.nickname is None or options.channel is None:
5553
parser.error("Missing required argument")
5654

57-
nickname = options.nick_prefix + "_zulip"
55+
nickname = options.nickname
5856
bot = IRCBot(
5957
zulip_client,
6058
options.stream,

zulip/integrations/bridge_with_irc/irc_mirror_backend.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def __init__(
2525
self.zulip_client = zulip_client
2626
self.stream = stream
2727
self.topic = topic
28+
self.nickname = nickname
2829
self.IRC_DOMAIN = server
2930
self.nickserv_password = nickserv_password
3031
# Make sure the bot is subscribed to the stream
@@ -98,7 +99,7 @@ def forward_to_irc(msg: Dict[str, Any]) -> None:
9899
def on_privmsg(self, c: ServerConnection, e: Event) -> None:
99100
content = e.arguments[0]
100101
sender = self.zulip_sender(e.source)
101-
if sender.endswith("_zulip@" + self.IRC_DOMAIN):
102+
if sender == (self.nickname + "@" + self.IRC_DOMAIN):
102103
return
103104

104105
# Forward the PM to Zulip
@@ -116,7 +117,7 @@ def on_privmsg(self, c: ServerConnection, e: Event) -> None:
116117
def on_pubmsg(self, c: ServerConnection, e: Event) -> None:
117118
content = e.arguments[0]
118119
sender = self.zulip_sender(e.source)
119-
if sender.endswith("_zulip@" + self.IRC_DOMAIN):
120+
if sender == (self.nickname + "@" + self.IRC_DOMAIN):
120121
return
121122

122123
# Forward the stream message to Zulip

0 commit comments

Comments
 (0)