Skip to content

Commit cdff1db

Browse files
committed
Move cheer data out to a data file
1 parent e1a0288 commit cdff1db

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

data/cheers.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FUCK YEAH!
2+
HOORAH!
3+
HURRAY!
4+
OORAH!
5+
YAY!
6+
*\o/* CHEERS! *\o/*
7+
HOOHAH!
8+
HOOYAH!
9+
HUAH!
10+
♪ ┏(°.°)┛ ┗(°.°)┓ ♬

plugins/cheer.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
import random
22
import re
3+
from pathlib import Path
34

45
from cloudbot import hook
56

6-
cheers = [
7-
"FUCK YEAH!",
8-
"HOORAH!",
9-
"HURRAY!",
10-
"OORAH!",
11-
"YAY!",
12-
"*\o/* CHEERS! *\o/*",
13-
"HOOHAH!",
14-
"HOOYAH!",
15-
"HUAH!",
16-
"♪ ┏(°.°)┛ ┗(°.°)┓ ♬",
17-
]
18-
197
cheer_re = re.compile(r'\\o/', re.IGNORECASE)
208

9+
cheers = []
10+
11+
12+
@hook.on_start
13+
def load_cheers(bot):
14+
cheers.clear()
15+
data_file = Path(bot.data_dir) / "cheers.txt"
16+
with data_file.open(encoding='utf-8') as f:
17+
cheers.extend(line.strip() for line in f if not line.startswith('//'))
18+
2119

2220
@hook.regex(cheer_re)
2321
def cheer(chan, message):

0 commit comments

Comments
 (0)