fulvia/modules/grog.py

28 lines
616 B
Python
Raw Normal View History

2018-03-16 03:13:43 -04:00
#!/usr/bin/env python3
"""
Selects a random Grog of Substantial Whimsy effect.
"""
import os
import random
from module import commands
@commands("grog")
def grog(bot, trigger):
"""
Prints a status effect from Grog of Substantial Whimsy effect. If an
index is not given, a random one is chosen.
2018-03-16 03:13:43 -04:00
"""
with open(os.path.join(bot.static, "grog.txt"), "r") as file:
data = file.read().splitlines()
num = None
try:
num = int(trigger.group(2)) - 1
except:
pass
if num == None:
num = random.randint(0, len(data)-1)
if num >= len(data)-1:
num = len(data)-1
2018-05-25 15:21:18 -04:00
bot.msg(data[num])