forked from CloudBotIRC/CloudBot
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from toasti/patch-1
create .hug command
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"parts": {}, | ||
"templates": [ | ||
"{nick} wraps arms around {target} and clings forever", | ||
"{nick} gives {target} a BIIIIIIIIG hug!!!", | ||
"{nick} gives {target} a warming hug", | ||
"{nick} hugs {target} into a coma", | ||
"{nick} squeezes {target} to death", | ||
"{nick} gives {target} a christian side hug", | ||
"{nick} glomps {target}", | ||
"{nick} reluctantly hugs {target}...", | ||
"{nick} gives {target} a well-deserved hug :)", | ||
"{nick} hugs {target}", | ||
"{nick} hugs {target} forever and ever and ever", | ||
"cant stop, wont stop. {nick} hugs {target} until the sun goes cold", | ||
"{nick} rallies up everyone in the channel to give {target} a group hug", | ||
"{nick} gives {target} a tight hug and rubs their back", | ||
"{nick} hugs {target} and gives their hair a sniff", | ||
"{nick} smothers {target} with a loving hug" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
from cloudbot import hook | ||
from cloudbot.util.textgen import TextGenerator | ||
|
||
hug_data = {} | ||
|
||
|
||
@hook.on_start | ||
def load_hug(bot): | ||
hug_data.clear() | ||
data_file = Path(bot.data_dir) / "hug.json" | ||
with data_file.open(encoding='utf-8') as f: | ||
hug_data.update(json.load(f)) | ||
|
||
|
||
@hook.command("hug") | ||
def hug(text, nick, message): | ||
"""hugs <user>""" | ||
data = { | ||
'nick': nick, | ||
'target': text, | ||
} | ||
|
||
generator = TextGenerator(hug_data['templates'], hug_data['parts'], variables=data) | ||
message(generator.generate_string()) |