· 8 years ago · Mar 02, 2018, 08:12 PM
1import asyncio
2import json
3
4import codecs
5import os
6import random
7import re
8
9from cloudbot import hook
10from cloudbot.util import textgen
11
12nick_re = re.compile("^[A-Za-z0-9_|.\-\]\[\{\}]*$", re.I)
13
14#
15# https://github.com/CloudBotIRC/CloudBot/tree/master/plugins
16# https://pastebin.com/u/Hack5190
17#
18# Hack5190 (at) gmail.com
19#
20# v1.0 - 2-Mar-2018 - Initial release
21#
22
23teas = ['Honey', 'Honey Nut', 'Green', 'Oolong', 'Matcha', 'White', 'Pu-erh',
24 'Yellow', 'Mulberry', 'Herbal', 'Chai', 'Ceylon', 'Spearmint',
25 'Mint Ginger Lemon', 'Chamomile with Lemongrass', 'Peppermint',
26 'Hibiscus', 'Jasmine', 'Red Ginseng']
27
28
29def is_valid(target):
30 """ Checks if a string is a valid IRC nick. """
31 if nick_re.match(target):
32 return True
33 else:
34 return False
35
36
37@asyncio.coroutine
38@hook.command
39def tea(text, action):
40 """<user> - gives <user> a tea"""
41 user = text.strip()
42
43 if not is_valid(user):
44 return "I can't give a tea to that user."
45
46 tea_type = random.choice(teas)
47 type = random.choice(['hot', 'cold', 'iced'])
48 method = random.choice(['makes', 'gives', 'gets', 'pours'])
49
50 action("{} a {} {} tea for {} and serves it with a smile, enjoy.".format(method, type, tea_type, user))