40 lines
819 B
Python
Executable File
40 lines
819 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
main (GLaDOS)
|
|
=============
|
|
|
|
Description
|
|
-----------
|
|
Create a bot's instance and manages it.
|
|
"""
|
|
|
|
import logging
|
|
import re
|
|
from bot import Bot
|
|
|
|
|
|
LOG_FORMAT = "%(asctime)s [%(levelname)s] <%(filename)s> %(funcName)s: %(message)s"
|
|
logging.basicConfig(format=LOG_FORMAT, level=logging.DEBUG)
|
|
|
|
|
|
glados = Bot(
|
|
('irc.planet-casio.com', 6697),
|
|
('127.0.0.1', 5555),
|
|
["#general", "#glados"]
|
|
)
|
|
|
|
|
|
@glados.irc.on(lambda m: re.match("bonjour glados", m.text, re.IGNORECASE))
|
|
def say_hello(msg):
|
|
"""Make GLaDOS responds to greetings."""
|
|
glados.irc.send(msg.to, f"Heureuse de vous revoir, {msg.author}")
|
|
|
|
|
|
@glados.v5.on(lambda c, m: True)
|
|
def announce(channels, message):
|
|
"""Make an announce."""
|
|
for channel in channels:
|
|
glados.irc.send(channel, message)
|
|
|
|
glados.start()
|