Skip to content

Commit 04fc918

Browse files
authored
Merge pull request CloudBotIRC#192 from toasti/patch-1
create .hug command
2 parents 9a67c26 + 9374fb5 commit 04fc918

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

data/hug.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"parts": {},
3+
"templates": [
4+
"{nick} wraps arms around {target} and clings forever",
5+
"{nick} gives {target} a BIIIIIIIIG hug!!!",
6+
"{nick} gives {target} a warming hug",
7+
"{nick} hugs {target} into a coma",
8+
"{nick} squeezes {target} to death",
9+
"{nick} gives {target} a christian side hug",
10+
"{nick} glomps {target}",
11+
"{nick} reluctantly hugs {target}...",
12+
"{nick} gives {target} a well-deserved hug :)",
13+
"{nick} hugs {target}",
14+
"{nick} hugs {target} forever and ever and ever",
15+
"cant stop, wont stop. {nick} hugs {target} until the sun goes cold",
16+
"{nick} rallies up everyone in the channel to give {target} a group hug",
17+
"{nick} gives {target} a tight hug and rubs their back",
18+
"{nick} hugs {target} and gives their hair a sniff",
19+
"{nick} smothers {target} with a loving hug"
20+
]
21+
}

plugins/hug.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import json
2+
from pathlib import Path
3+
4+
from cloudbot import hook
5+
from cloudbot.util.textgen import TextGenerator
6+
7+
hug_data = {}
8+
9+
10+
@hook.on_start
11+
def load_hug(bot):
12+
hug_data.clear()
13+
data_file = Path(bot.data_dir) / "hug.json"
14+
with data_file.open(encoding='utf-8') as f:
15+
hug_data.update(json.load(f))
16+
17+
18+
@hook.command("hug")
19+
def hug(text, nick, message):
20+
"""hugs <user>"""
21+
data = {
22+
'nick': nick,
23+
'target': text,
24+
}
25+
26+
generator = TextGenerator(hug_data['templates'], hug_data['parts'], variables=data)
27+
message(generator.generate_string())

0 commit comments

Comments
 (0)