Add show photo link handler

trunk
mio 2018-09-17 16:27:05 +00:00
parent d5f882303e
commit 1ebf436ba9
6 changed files with 62 additions and 12 deletions

View File

@ -5,14 +5,14 @@ A very basic Python IRC bot script.
## Example: ramenkan ## Example: ramenkan
- Edit `ramenkan/config.sample.yml` to change settings as appropriate. - Copy the `ramenkan/config.sample.yml` as `ramenkan/comfig.yml` and change
settings.
- Run: - Run:
``` ```
chmod +x ramenkan.py chmod +x ramenkan.py
nohup python3 ramenkan.py & nohup python3 ramenkan.py &
ctrl + c
``` ```

View File

@ -13,10 +13,11 @@ class Ramen:
self.rand = self.util.rand self.rand = self.util.rand
self.std = self.util.yml("ramenkan/standard.yml") self.std = self.util.yml("ramenkan/standard.yml")
self.links = self.util.yml("ramenkan/links.yml") self.links = self.util.yml("ramenkan/links.yml")
self.photos = self.util.yml("ramenkan/photos.yml")
self.dishes = self.util.yml("ramenkan/dishes.yml") self.dishes = self.util.yml("ramenkan/dishes.yml")
# Init irc object # Init irc object
self.irc = IRC() self.irc = IRC()
self.cfg = self.irc.config("ramenkan/config.sample.yml") self.cfg = self.irc.config("ramenkan/config.yml")
self.irc.run(self.add_listeners) self.irc.run(self.add_listeners)
def add_listeners(self, cxt): def add_listeners(self, cxt):
@ -32,6 +33,7 @@ class Ramen:
self.irc.listen(cxt, "rk", self.ramen) self.irc.listen(cxt, "rk", self.ramen)
self.irc.listen(cxt, "rkveg", self.ramen_veggie) self.irc.listen(cxt, "rkveg", self.ramen_veggie)
self.irc.listen(cxt, "rklink", self.link) self.irc.listen(cxt, "rklink", self.link)
self.irc.listen(cxt, "rkselfie", self.selfie)
def quit(self, cxt): def quit(self, cxt):
"""Disconnect from the server and quit.""" """Disconnect from the server and quit."""
@ -97,7 +99,7 @@ class Ramen:
prev_top = next_top prev_top = next_top
# Condiment and side dish # Condiment and side dish
if randint(0, 1): if randint(0, 1):
combo += ", garnished with " + self.rand(dish["condiment"]) + "." combo += ", sprinkled with " + self.rand(dish["condiment"]) + "."
else: else:
combo += "." combo += "."
if randint(0, 1): if randint(0, 1):
@ -129,11 +131,15 @@ class Ramen:
self.irc.reply(cxt, resp) self.irc.reply(cxt, resp)
def link(self, cxt): def link(self, cxt):
"""Handle to display a link.""" """Handle to display a titled link."""
index = randint(0, len(self.links)-1) index = randint(0, len(self.links)-1)
self.irc.reply(cxt, self.links[index]["title"] + " " + \ self.irc.reply(cxt, self.links[index]["title"] + " " + \
self.links[index]["link"]) self.links[index]["link"])
def selfie(self, cxt):
"""Handle to display a photo link."""
self.irc.reply(cxt, self.rand(self.photos["ticket"]))
app = Ramen() app = Ramen()
app.main() app.main()

View File

@ -10,7 +10,7 @@ bot_nick: "ramenkan"
# User and code for admin actions # User and code for admin actions
admin: admin:
user: "mio" user: "user"
code: "ramen" code: "ramen"
# Request prefix, e.g. "!" for "!<request>" # Request prefix, e.g. "!" for "!<request>"

View File

@ -1,3 +1,4 @@
# Lists of ingredients to assemble a ramen dish
broth: broth:
- Kobe beef bone - Kobe beef bone
- pork bone - pork bone
@ -35,7 +36,6 @@ condiment:
- chili pepper - chili pepper
- chili sauce - chili sauce
- sesame oil - sesame oil
- Japanese curry
- dashi # fish and seaweed stock - dashi # fish and seaweed stock
- white pepper - white pepper
- black pepper - black pepper

View File

@ -0,0 +1,44 @@
# Photo links of ramen vending machines
# Ticket machines
ticket:
- https://c2.staticflickr.com/6/5077/5902028877_7d8c65b23f_b.jpg
- https://c1.staticflickr.com/3/2455/5777431350_36e147e719_z.jpg
- https://i.pinimg.com/originals/72/08/1e/72081e68ff0989d54fd24a86fcac6f2b.jpg
- https://i.pinimg.com/originals/9f/74/92/9f7492b7c456ac7ba350498a50c74b23.jpg
- https://c1.staticflickr.com/9/8157/7105010129_cd4b0d7e27_c.jpg
- https://c1.staticflickr.com/8/7600/27418644850_2c70342734_c.jpg
- https://c3.staticflickr.com/3/2049/2229742287_8df3e823a9_z.jpg
- https://c1.staticflickr.com/1/101/308523474_4295a27326_z.jpg
- https://media-cdn.tripadvisor.com/media/photo-s/0b/b6/27/f6/ramen-shop-menu-banner.jpg
- https://abroadabroad2011.files.wordpress.com/2013/03/sam_0040.jpg
- https://c1.staticflickr.com/6/5753/22803130417_ba86ebb4fa_c.jpg
- https://c1.staticflickr.com/6/5077/5902028877_7d8c65b23f_z.jpg
- https://c1.staticflickr.com/8/7504/15210528573_2612010fc3_c.jpg
- https://s3-media4.fl.yelpcdn.com/bphoto/iUHJczm_--xNqWEUzDS69Q/o.jpg
- https://thewholeworldornothing.com/wp-content/uploads/2017/01/vending-machine-waiter.jpg
- https://thebrunchingbooth.files.wordpress.com/2014/07/img_42681.jpg
- https://c1.staticflickr.com/8/7426/16587852342_0cbfa4a63c_c.jpg
- https://c1.staticflickr.com/9/8422/7535359482_b5537bbde0_c.jpg
- https://c1.staticflickr.com/5/4037/4530351457_8666286b56_z.jpg
- https://c1.staticflickr.com/1/97/244236130_0c22679f97_z.jpg
- https://c1.staticflickr.com/4/3479/3465112347_1be2868ff0_z.jpg
- https://1.bp.blogspot.com/_W-pG7tUmJk0/TDQ-J_vz9sI/AAAAAAAACac/xYjAvl8ZGOY/s1600/shinjuku_ramen_02.jpg
- https://thefoodieflight.files.wordpress.com/2015/10/img_3749.jpg
- https://static1.squarespace.com/static/57ad3b51c534a528e26a2e93/t/57f91e3be6f2e18cf1d11c82/1476472671797/
- https://c1.staticflickr.com/1/166/417127513_e063ccf80a_z.jpg
# Instant cup noodles
instant:
- http://www.toxel.com/wp-content/uploads/2009/06/vendingmachine04.jpg
- https://c1.staticflickr.com/3/2233/2347915323_9e9e2264a3_z.jpg
- https://c1.staticflickr.com/4/3818/10186967173_237d38b86f_c.jpg
- https://c1.staticflickr.com/8/7221/7175446233_076264a2b4_c.jpg
- https://c7.alamy.com/comp/BCDJRG/a-cup-noodle-vending-machine-instant-ramen-museum-osaka-japan-1-december-BCDJRG.jpg
# Ramen can
can:
- https://c1.staticflickr.com/4/3625/3374051074_641b371d23_z.jpg
- https://c4.staticflickr.com/4/3214/2911821453_78c6178f54_z.jpg
- https://smallbiztrends.com/wp-content/uploads/2015/06/P1020817-728x485.jpg
- https://c1.staticflickr.com/9/8440/7745533776_7b9990be82_c.jpg
- https://c1.staticflickr.com/3/2268/4507516049_e7aa354489_z.jpg

View File

@ -1,7 +1,7 @@
rollcall: rollcall:
"一、二、三、らーめん缶! "一、二、三、らーめん缶!
Hello, I am a ramen vending machine. Please type a code for service: Hello, I am a ramen vending machine. Please type a code for service:
!help !ramen !veggieramen !rklink !help !ramen !veggieramen !rklink !rkselfie
- Support: +81 012-700-1MIO どうぞめしあがれ。" - Support: +81 012-700-1MIO どうぞめしあがれ。"
water: water: