shoutbridge/bridge.py

36 lines
846 B
Python
Raw Normal View History

2021-09-10 14:23:43 +02:00
import logging
from irc import IRC
from shoutbox import Shoutbox
from cookies import cookies
from sasl import nick, password
2022-03-09 14:14:58 +01:00
from users import users
2021-09-10 14:23:43 +02:00
LOG_FORMAT = "%(asctime)s [%(levelname)s] <%(filename)s> %(funcName)s: %(message)s"
logging.basicConfig(format=LOG_FORMAT, level=logging.INFO)
channels = ["hs", "projets", "annonces"]
irc = IRC('irc.planet-casio.com', 6697)
shoutbox = Shoutbox(cookies)
2022-03-09 14:14:58 +01:00
2021-09-10 14:23:43 +02:00
@irc.on(lambda m: m.to[1:] in channels)
def handle_irc(m):
2022-03-09 14:14:58 +01:00
shoutbox.post(m.author, m.text, m.to[1:], users)
2021-09-10 14:23:43 +02:00
2022-03-09 14:15:20 +01:00
@shoutbox.on(lambda m: m.channel in channels and m.author != "IRC" and not m.text.endswith("[IRC]"))
2021-09-10 14:23:43 +02:00
def handle_shoutbox(m):
irc.send(f"#{m.channel}", f"{m.author}: {m.text}")
irc.start("Shoutbox", password, nick)
for c in channels:
irc.join(f"#{c}")
shoutbox.run()
irc.run()