Skip to content

Commit 6cc8008

Browse files
authored
Merge pull request CloudBotIRC#123 from IlGnome/patch-18
Create gnomeagainsthumanity.py
2 parents 6ea019c + f89fd46 commit 6cc8008

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

plugins/gnomeagainsthumanity.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import codecs
2+
import json
3+
import asyncio
4+
import random
5+
from cloudbot import hook
6+
import re
7+
8+
9+
@hook.on_start()
10+
def shuffle_deck(bot):
11+
12+
global gnomecards
13+
with codecs.open(os.path.join(bot.data_dir, "gnomecards.json"), encoding="utf-8") as f:
14+
gnomecards = json.load(f)
15+
16+
17+
18+
@hook.command('cah')
19+
def CAHwhitecard(text, message):
20+
'''Submit text to be used as a CAH whitecard'''
21+
CardText = text.strip()
22+
message(random.choice(gnomecards['black']).format(text))
23+
24+
25+
@hook.command('cahb')
26+
def CAHblackcard(text, message):
27+
'''Submit text with _ for the bot to fill in the rest. You can submit text with multiple _'''
28+
CardText = text.strip()
29+
30+
def blankfiller(matchobj):
31+
return random.choice(gnomecards['white'])
32+
33+
out = re.sub(r'_', blankfiller, CardText)
34+
message(out)

0 commit comments

Comments
 (0)