2018-09-13 06:10:50 +00:00
|
|
|
|
from random import randint
|
|
|
|
|
|
2018-09-16 04:48:50 +00:00
|
|
|
|
from itte import IRC, Util
|
2018-09-13 06:10:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Ramen:
|
2018-09-14 05:54:21 +00:00
|
|
|
|
"""Requests with a ramen theme."""
|
2018-09-13 06:10:50 +00:00
|
|
|
|
|
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-16 04:48:50 +00:00
|
|
|
|
# Load yaml sources used by request handlers
|
|
|
|
|
self.util = Util()
|
2018-09-17 03:51:09 +00:00
|
|
|
|
self.rand = self.util.rand
|
2018-09-16 04:48:50 +00:00
|
|
|
|
self.links = self.util.yml("ramenkan/links.yml")
|
2018-09-17 03:51:09 +00:00
|
|
|
|
self.dishes = self.util.yml("ramenkan/dishes.yml")
|
2018-09-16 04:48:50 +00:00
|
|
|
|
# Init irc object
|
2018-09-14 05:54:21 +00:00
|
|
|
|
self.irc = IRC()
|
2018-09-16 04:48:50 +00:00
|
|
|
|
self.cfg = self.irc.config("ramenkan/config.sample.yml")
|
2018-09-15 23:18:44 +00:00
|
|
|
|
self.irc.run(self.add_listeners)
|
2018-09-13 06:10:50 +00:00
|
|
|
|
|
2018-09-14 23:37:47 +00:00
|
|
|
|
def add_listeners(self, cxt):
|
|
|
|
|
"""Map triggers to handlers."""
|
2018-09-15 23:18:44 +00:00
|
|
|
|
self.irc.listen(cxt, "exit " + self.cfg["admin"]["code"], self.quit, \
|
|
|
|
|
admin=True)
|
2018-09-14 23:37:47 +00:00
|
|
|
|
self.irc.listen(cxt, "rollcall", self.rollcall)
|
|
|
|
|
self.irc.listen(cxt, "help", self.rollcall)
|
2018-09-15 23:18:44 +00:00
|
|
|
|
self.irc.listen(cxt, "water " + self.cfg["bot_nick"], self.water)
|
|
|
|
|
self.irc.listen(cxt, "botsnack " + self.cfg["bot_nick"], self.botsnack)
|
2018-09-17 03:51:09 +00:00
|
|
|
|
self.irc.listen(cxt, "ramen", self.ramen)
|
|
|
|
|
self.irc.listen(cxt, "rk", self.ramen)
|
2018-09-16 04:48:50 +00:00
|
|
|
|
self.irc.listen(cxt, "rklink", self.link)
|
2018-09-13 06:10:50 +00:00
|
|
|
|
|
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-13 06:10:50 +00:00
|
|
|
|
|
2018-09-14 23:37:47 +00:00
|
|
|
|
def rollcall(self, cxt):
|
2018-09-13 06:10:50 +00:00
|
|
|
|
resp = (
|
|
|
|
|
"一、二、三、らーめん缶! "
|
|
|
|
|
"Hello, I am a ramen vending machine. "
|
|
|
|
|
"Please type a code for service: "
|
2018-09-17 03:51:09 +00:00
|
|
|
|
"!help !ramen !rklink - "
|
2018-09-13 06:10:50 +00:00
|
|
|
|
"Support: +81 012-700-1MIO どうぞめしあがれ。"
|
|
|
|
|
)
|
2018-09-14 23:37:47 +00:00
|
|
|
|
self.irc.reply(cxt, resp)
|
2018-09-13 06:10:50 +00:00
|
|
|
|
|
2018-09-14 23:37:47 +00:00
|
|
|
|
def water(self, cxt):
|
2018-09-13 06:10:50 +00:00
|
|
|
|
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",
|
2018-09-17 03:51:09 +00:00
|
|
|
|
"Cheers! 自o(^_^ )",
|
|
|
|
|
"Water Level [/////////] 200% - Thanks! (^▽^ )",
|
|
|
|
|
("Thanks. Some people say I have a CRABby tempeRAMENt. "
|
|
|
|
|
"I wonder why. (´-` )"),
|
|
|
|
|
("Q. What do you call noodles made from the core of a tree? "
|
|
|
|
|
"A. DuRAMEN. *ba dum tss* ┐('∀`;)┌"),
|
|
|
|
|
("Q. What do you call noodles eaten on bulletin boards? "
|
|
|
|
|
"A. FoRAMEN. *ba dum tss* ┐('∀`;)┌"),
|
|
|
|
|
("Q. What kind of noodles can be found at TV stations? "
|
|
|
|
|
"A. CameRAMEN. *ba dum tss* ┐('∀`;)┌")
|
2018-09-13 06:10:50 +00:00
|
|
|
|
]
|
2018-09-17 03:51:09 +00:00
|
|
|
|
self.irc.reply(cxt, self.rand(resp))
|
2018-09-13 06:10:50 +00:00
|
|
|
|
|
2018-09-14 23:37:47 +00:00
|
|
|
|
def botsnack(self, cxt):
|
2018-09-17 03:51:09 +00:00
|
|
|
|
resp = [
|
|
|
|
|
"CHIKIN RAAAAAMEN━━━(゜∀゜)━━━!!!!!",
|
|
|
|
|
"Ramen time anytime! 自o(´▽` )/"
|
|
|
|
|
]
|
|
|
|
|
self.irc.reply(cxt, self.rand(resp))
|
|
|
|
|
|
|
|
|
|
def make_ramen_combo(self):
|
|
|
|
|
dish = self.dishes
|
|
|
|
|
combo = "ramen in "
|
|
|
|
|
# Noodle type and broth richness
|
|
|
|
|
if randint(0, 1):
|
|
|
|
|
combo = self.rand(dish["noodle-shape"]) + ", " + \
|
|
|
|
|
self.rand(dish["noodle-broth-type"]) + " "
|
|
|
|
|
combo = combo.capitalize()
|
|
|
|
|
# Broth type
|
|
|
|
|
combo += self.rand(dish["broth"] + dish["broth-veggie"]) + " broth"
|
|
|
|
|
# Topping
|
|
|
|
|
n_top = randint(2, 4)
|
|
|
|
|
for n in range(2, n_top+1):
|
|
|
|
|
if n == 2:
|
|
|
|
|
prev_top = self.rand(dish["topping"] + dish["meat"])
|
|
|
|
|
combo += " with " + prev_top
|
|
|
|
|
else:
|
|
|
|
|
if n > 2 and n < n_top:
|
|
|
|
|
combo += ", "
|
|
|
|
|
else:
|
|
|
|
|
combo += " and "
|
|
|
|
|
next_top = self.rand(dish["topping"] + dish["meat"])
|
|
|
|
|
# Check for duplicate
|
|
|
|
|
if next_top == prev_top:
|
|
|
|
|
next_top = self.rand(dish["topping"])
|
|
|
|
|
combo += next_top
|
|
|
|
|
prev_top = next_top
|
|
|
|
|
# Condiment and side dish
|
|
|
|
|
if randint(0, 1):
|
|
|
|
|
combo += ", garnished with " + self.rand(dish["condiment"]) + "."
|
|
|
|
|
else:
|
|
|
|
|
combo += "."
|
|
|
|
|
if randint(0, 1):
|
|
|
|
|
combo += " Served with " + self.rand(dish["tapa"] + \
|
|
|
|
|
dish["tapa-veggie"]) + "."
|
|
|
|
|
return combo
|
|
|
|
|
|
|
|
|
|
def ramen(self, cxt):
|
|
|
|
|
roll = randint(1, 100)
|
|
|
|
|
# 1% possibility of regional preset
|
|
|
|
|
if roll == 100:
|
|
|
|
|
resp = (self.rand(self.dishes["set"] + \
|
|
|
|
|
self.dishes["set-veggie"]) + ".").capitalize()
|
|
|
|
|
else:
|
|
|
|
|
resp = self.make_ramen_combo()
|
|
|
|
|
self.irc.reply(cxt, resp)
|
2018-09-13 20:12:18 +00:00
|
|
|
|
|
2018-09-16 04:48:50 +00:00
|
|
|
|
def link(self, cxt):
|
2018-09-17 03:51:09 +00:00
|
|
|
|
index = randint(0, len(self.links)-1)
|
|
|
|
|
self.irc.reply(cxt, self.links[index]["title"] + " " + \
|
|
|
|
|
self.links[index]["link"])
|
2018-09-16 04:48:50 +00:00
|
|
|
|
|
2018-09-13 20:12:18 +00:00
|
|
|
|
|
|
|
|
|
app = Ramen()
|
2018-09-14 05:54:21 +00:00
|
|
|
|
app.main()
|