44 lines
1012 B
Python
44 lines
1012 B
Python
import logging
|
|
import sys
|
|
|
|
|
|
from irc import IRC
|
|
from shoutbox import Shoutbox
|
|
from cookies import cookies
|
|
from sasl import nick, password
|
|
from users import USERS
|
|
|
|
|
|
LOG_FORMAT = "%(asctime)s [%(levelname)s] <%(filename)s> %(funcName)s: %(message)s"
|
|
logging.basicConfig(format=LOG_FORMAT, level=logging.DEBUG)
|
|
|
|
channels = ["hs", "projets", "annonces"]
|
|
|
|
irc = IRC('irc.planet-casio.com', 6697)
|
|
shoutbox = Shoutbox(cookies)
|
|
|
|
|
|
@irc.on(lambda m: m.to[1:] in channels and not m.author.endswith("[s]"))
|
|
def handle_irc(m):
|
|
shoutbox.post(m.author, m.text, m.to[1:], USERS)
|
|
|
|
|
|
@shoutbox.on(lambda m: m.channel in channels and m.author != "IRC" and not m.text.endswith("[IRC]"))
|
|
def handle_shoutbox(m):
|
|
author = Shoutbox.normalize(m.author)
|
|
shoutbox.irc_clients[author][0].send(f"#{m.channel}", f"{m.text}")
|
|
|
|
|
|
irc.start("Shoutbox[darks]", password, nick)
|
|
for c in channels:
|
|
irc.join(f"#{c}")
|
|
|
|
try:
|
|
shoutbox.run()
|
|
irc.run()
|
|
|
|
except KeyboardInterrupt:
|
|
irc.stop()
|
|
shoutbox.stop()
|
|
sys.exit(0)
|