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

23 lines
498 B
Python
Raw Normal View History

2011-11-20 10:23:31 +01:00
from util import hook
import re
import random
2012-03-26 06:17:19 +02:00
fortunes = []
with open("plugins/data/fortunes.txt") as f:
for line in f.readlines():
if line.startswith("//"):
continue
2012-03-26 07:33:11 +02:00
fortunes.append(line.strip())
2011-11-20 10:23:31 +01:00
2012-03-26 07:36:40 +02:00
2011-11-20 10:23:31 +01:00
@hook.command(autohelp=False)
def fortune(inp, nick=None, say=None, input=None):
2012-02-28 03:03:43 +01:00
".fortune -- Fortune cookies on demand."
2012-02-29 09:29:53 +01:00
2011-11-20 10:23:31 +01:00
msg = "(" + nick + ") " + random.choice(fortunes)
2012-03-26 06:17:19 +02:00
if inp:
2011-11-20 10:23:31 +01:00
msg = "(@" + inp + ") " + random.choice(fortunes)
say(msg)