itte/ramen.py
2018-09-14 23:37:47 +00:00

53 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from random import randint
import config as cfg
from irc import IRC
class Ramen:
"""Requests with a ramen theme."""
def main(self):
"""Instantiate an IRC object and attach the listeners."""
self.irc = IRC()
self.irc.debug = cfg.debug
self.irc.run(self.add_listeners, cfg)
def add_listeners(self, cxt):
"""Map triggers to handlers."""
self.irc.listen(cxt, "exit " + cfg.admin_code, self.quit, admin=True)
self.irc.listen(cxt, "rollcall", self.rollcall)
self.irc.listen(cxt, "help", self.rollcall)
self.irc.listen(cxt, "water " + cfg.bot_nick, self.water)
self.irc.listen(cxt, "botsnack " + cfg.bot_nick, self.botsnack)
def quit(self, cxt):
"""Disconnect from the server and quit."""
self.irc.disconnect("Okay, okay, I'll leave. (´・ω・`)", "noodling off")
def rollcall(self, cxt):
resp = (
"一、二、三、らーめん缶! "
"Hello, I am a ramen vending machine. "
"Please type a code for service: "
"!help "
"Support: +81 012-700-1MIO どうぞめしあがれ。"
)
self.irc.reply(cxt, resp)
def water(self, cxt):
resp = [
("\x01ACTION happily pours the hot liquid into a bowl of noodles "
"and offers it to ") + cxt["msg"]["nick"] + "\x01",
" ^_^o自自o^_^ Cheers!",
"Water Level [/////////] 200% - Thanks! (^▽^)"
]
self.irc.reply(cxt, resp[randint(0, len(resp)-1)])
def botsnack(self, cxt):
self.irc.reply(cxt, "Ramen time anytime! 自o(´▽`)/")
app = Ramen()
app.main()