cosmicbot/commands/prompt.py

17 lines
438 B
Python
Raw Normal View History

2019-11-03 16:47:49 +00:00
import plugin,requests,random
def get(*args,**kwargs):
r = requests.get(*args,**kwargs)
r.raise_for_status()
return r.json()
prompts = get("https://khuxkm.tilde.team/prompts.json")["prompts"]
@plugin.command("prompt","")
def prompt(bot,channel,nick,*args):
2020-01-10 17:39:28 +00:00
if len(args)==1:
prompt_ = prompts[int(args[0])-1]
else:
prompt_ = random.choice(prompts)
2019-11-03 16:47:49 +00:00
bot.say(channel,"{}: {!s}. {}".format(nick,prompts.index(prompt_)+1,prompt_))