This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/plugins/fortune.py
Luke Rogers cb9129aebc PEP-8
2012-03-26 18:36:40 +13:00

23 lines
498 B
Python
Executable file

from util import hook
import re
import random
fortunes = []
with open("plugins/data/fortunes.txt") as f:
for line in f.readlines():
if line.startswith("//"):
continue
fortunes.append(line.strip())
@hook.command(autohelp=False)
def fortune(inp, nick=None, say=None, input=None):
".fortune -- Fortune cookies on demand."
msg = "(" + nick + ") " + random.choice(fortunes)
if inp:
msg = "(@" + inp + ") " + random.choice(fortunes)
say(msg)