add ship quirks command

This commit is contained in:
iou1name 2020-02-26 11:33:50 -05:00
parent 90d59aff50
commit 382b3ce179

View File

@ -46,3 +46,22 @@ def magic(bot, trigger):
if num >= len(data)-1:
num = len(data)-1
bot.msg(data[num])
@commands("ship")
def magic(bot, trigger):
"""
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])