GLaDOS/proposal/commands.py

27 lines
849 B
Python

# Import the relevant bot
from main import my_bot
# Register a free response to a message
# Here we reply to people mentionning the bot
# Note that this is a simple exemple that can bug if
# bot's name is included in a word (ex "Bobsleigh")
@my_bot.on(lambda m: my_bot.nick in m.text)
def hello(msg):
""" Says hello to nice people """
my_bot.send(msg.to, f"What's up, {m.author}?")
# Register a command on specific channels
@my_bot.command("!fun")
@my_bot.on_channel("#fun", "#play")
def cmd_fun(msg):
""" Gives some fun, but only on authorized channels """
my_bot.send(msg.to, "Fun is allowed only here.")
# Register a command on specific users
@my_bot.on(lambda m: True)
@my_bot.users("Breizh")
def breizh_is_always_right(msg):
""" Agrees every message from Breizh """
my_bot.send(msg.to, "I agree what Breizh said.")