bridge_with_irc: Fix sending from Zulip to IRC and enable it by default.
This commit is contained in:
parent
910f83ee8e
commit
edcf1fd8e9
|
@ -26,9 +26,6 @@ Example:
|
|||
Specify your Zulip API credentials and server in a ~/.zuliprc file or using the options.
|
||||
|
||||
Note that "_zulip" will be automatically appended to the IRC nick provided
|
||||
|
||||
Also note that at present you need to edit this code to do the Zulip => IRC side
|
||||
|
||||
"""
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -2,6 +2,7 @@ import irc.bot
|
|||
import irc.strings
|
||||
from irc.client import ip_numstr_to_quad, ip_quad_to_numstr, Event, ServerConnection
|
||||
from irc.client_aio import AioReactor
|
||||
import multiprocessing as mp
|
||||
from typing import Any, Dict
|
||||
|
||||
|
||||
|
@ -41,7 +42,7 @@ class IRCBot(irc.bot.SingleServerIRCBot):
|
|||
def forward_to_irc(msg):
|
||||
# type: (Dict[str, Any]) -> None
|
||||
if msg["type"] == "stream":
|
||||
send = lambda x: c.privmsg(msg["display_recipient"], x)
|
||||
send = lambda x: c.privmsg(self.channel, x)
|
||||
else:
|
||||
recipients = [u["short_name"] for u in msg["display_recipient"] if
|
||||
u["email"] != msg["sender_email"]]
|
||||
|
@ -52,10 +53,8 @@ class IRCBot(irc.bot.SingleServerIRCBot):
|
|||
for line in msg["content"].split("\n"):
|
||||
send(line)
|
||||
|
||||
## Forwarding from Zulip => IRC is disabled; uncomment the next
|
||||
## line to make this bot forward in that direction instead.
|
||||
#
|
||||
# self.zulip_client.call_on_each_message(forward_to_irc)
|
||||
z2i = mp.Process(target=self.zulip_client.call_on_each_message, args=(forward_to_irc,))
|
||||
z2i.start()
|
||||
|
||||
def on_privmsg(self, c, e):
|
||||
# type: (ServerConnection, Event) -> None
|
||||
|
|
Loading…
Reference in a new issue