fulvia/modules/grog.py

68 lines
1.6 KiB
Python
Raw Permalink Normal View History

2018-03-16 03:13:43 -04:00
#!/usr/bin/env python3
"""
Selects a random Grog of Substantial Whimsy effect.
2018-06-09 01:07:40 -04:00
Also does stuff from the Net Libram of Random Magic Effects.
2018-03-16 03:13:43 -04:00
"""
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:
2020-01-07 18:58:19 -05:00
num = int(trigger.args[1]) - 1
except (IndexError, ValueError):
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])
2018-06-09 01:07:40 -04:00
@commands("magic")
def magic(bot, trigger):
"""
Prints a magic effect from the Net Libram of Random Magic Effects. If an
index is not given, a random one is chosen.
"""
with open(os.path.join(bot.static, "netlibram.txt"), "r") as file:
data = file.read().splitlines()
num = None
try:
2020-01-07 18:58:19 -05:00
num = int(trigger.args[1]) - 1
except (IndexError, ValueError):
2018-06-09 01:07:40 -04:00
pass
if num == None:
num = random.randint(0, len(data)-1)
if num >= len(data)-1:
num = len(data)-1
2020-01-07 18:58:19 -05:00
bot.msg(data[num])
2020-02-26 11:33:50 -05:00
@commands("ship")
2020-03-18 19:48:07 -04:00
def ship(bot, trigger):
2020-02-26 11:33:50 -05:00
"""
Prints a ship quirk. If an index is not given, a random one is chosen.
"""
with open(os.path.join(bot.static, "ship_quirks.txt"), "r") as file:
data = file.read().splitlines()
num = None
try:
num = int(trigger.args[1]) - 1
except (IndexError, ValueError):
pass
if num == None:
num = random.randint(0, len(data)-1)
if num >= len(data)-1:
num = len(data)-1
bot.msg(data[num])