We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9a67c26 commit f48d82eCopy full SHA for f48d82e
1 file changed
plugins/hug.py
@@ -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