Skip to content

Commit f48d82e

Browse files
authored
create hug.py
.hug <user> hugs the user <3
1 parent 9a67c26 commit f48d82e

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

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)