Skip to content

Commit

Permalink
Merge pull request #192 from toasti/patch-1
Browse files Browse the repository at this point in the history
create .hug command
  • Loading branch information
edwardslabs authored Oct 23, 2017
2 parents 9a67c26 + 9374fb5 commit 04fc918
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
21 changes: 21 additions & 0 deletions data/hug.json
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"
]
}
27 changes: 27 additions & 0 deletions plugins/hug.py
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())

0 comments on commit 04fc918

Please sign in to comment.