itte/ramen.py

53 lines
1.7 KiB
Python
Raw Normal View History

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