Un bridge entre la shout et l'IRC
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
shoutbridge/bridge.py

36 lines
832 B

1 year ago
import json
import logging
import requests as r
import time
from irc import IRC
from shoutbox import Shoutbox
from cookies import cookies
from sasl import nick, password
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)
@irc.on(lambda m: m.to[1:] in channels)
def handle_irc(m):
shoutbox.post(f"{m.author}: {m.text}", m.to[1:])
@shoutbox.on(lambda m: m.channel in channels and m.author != "IRC")
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()