File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 )
You can’t perform that action at this time.
0 commit comments