sopel/modules/grog.py

28 lines
603 B
Python
Raw Normal View History

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Selects a random Grog of Substantial Whimsy effect.
"""
import os
import random
from module import commands, example
@commands("grog")
def grog(bot, trigger):
"""
Picks a random status effect from Grog of Substantial Whimsy effect.
"""
with open(os.path.join(bot.config.homedir, "grog.txt"), "r") as file:
data = file.read().split("\n")
num = 0
if trigger.group(2):
try:
num = int(trigger.group(2)) - 1
except:
pass
if num and num < len(data):
bot.say(data[num])
else:
bot.say(random.choice(data))