Skip to content

Commit 781c473

Browse files
author
thebestgirl123
authored
Merge pull request #1 from edwardslabs/gonzobot
x
2 parents 8ee4d10 + 8fa6d7b commit 781c473

9 files changed

Lines changed: 119 additions & 56 deletions

File tree

cloudbot/__main__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,18 @@ def main():
3838
original_sigint = signal.getsignal(signal.SIGINT)
3939

4040
# define closure for signal handling
41-
def exit_gracefully():
41+
# The handler is called with two arguments: the signal number and the current stack frame
42+
# These parameters should NOT be removed
43+
def exit_gracefully(signum, frame):
4244
nonlocal stopped_while_restarting
4345
if not _bot:
4446
# we are currently in the process of restarting
4547
stopped_while_restarting = True
4648
else:
47-
_bot.loop.call_soon_threadsafe(lambda: asyncio.async(_bot.stop("Killed"), loop=_bot.loop))
49+
_bot.loop.call_soon_threadsafe(
50+
lambda: asyncio.async(_bot.stop("Killed (Received SIGINT {})".format(signum)), loop=_bot.loop))
51+
52+
logger.warn("Bot received Signal Interrupt ({})".format(signum))
4853

4954
# restore the original handler so if they do it again it triggers
5055
signal.signal(signal.SIGINT, original_sigint)

data/chocolate.json

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"Bounty bars",
3434
"green tea Kit-Kats",
3535
"Aero mint bars",
36-
"After Eight’s",
36+
"After Eights",
3737
"Butterfingers",
3838
"Freddos",
3939
"Kinder buenos",
@@ -53,7 +53,36 @@
5353
"store brand 72% chocolate bar",
5454
"chilli flavoured chocolate",
5555
"Ferrero Rocher",
56-
"Ferrero Yogurette"
56+
"Ferrero Yogurette",
57+
"cheap chocolate",
58+
"Marmite chocolate",
59+
"Marathon",
60+
"Double Decker",
61+
"Crunchie",
62+
"Milky Way",
63+
"Galaxy",
64+
"caramel chocolate",
65+
"Galaxy caramel",
66+
"Dairy Milk",
67+
"white chocolate",
68+
"Taxi",
69+
"Boost",
70+
"Hershey",
71+
"Milka",
72+
"Daim",
73+
"Crunch",
74+
"Yorkie",
75+
"Flake",
76+
"Creme Egg Twisted",
77+
"mouldy choclate",
78+
"Wispa",
79+
"Bournville",
80+
"Curly Whirly",
81+
"£100 Freddo",
82+
"Caramac",
83+
"Fry’s Chocolate Cream",
84+
"Twirl",
85+
"Turkish Delight"
5786
]
5887
}
59-
}
88+
}

data/clinton.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
{
2-
"templates": [
3-
"thinks {user} is {insult}",
4-
"thinks that {user} helped Clinton deleted her emails",
5-
"knows that {user} assisted Clinton with Benghazi",
6-
"saw {user} help Clinton when she collapsed"
7-
],
8-
"parts":{
9-
"insult": [
10-
"deplorable",
11-
"a basement dweller"
12-
]
13-
}
14-
}
1+
{
2+
"templates": [
3+
"thinks {user} is {insult}",
4+
"thinks that {user} helped Clinton deleted her emails",
5+
"knows that {user} assisted Clinton with Benghazi",
6+
"saw {user} help Clinton when she collapsed"
7+
],
8+
"parts":{
9+
"insult": [
10+
"deplorable",
11+
"a basement dweller"
12+
]
13+
}
14+
}

data/trump.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@
44
"walks in on {user} while undressing.",
55
"pops a tic-tac and kisses {user}.",
66
"calls {user} {insult}.",
7-
"makes {user} great again."
7+
"makes the wall 10 feet higher and makes {user} pay for it.",
8+
"thinks {user} isn't sending their best.",
9+
"thinks {user} is great. the greatest. a really great user.",
10+
"thinks {user} has a yuge problem",
11+
"thinks people love {user}. And you know what, {user} has been very successful. Everybody loves {user}.",
12+
"thinks {user} actually doesn't have a bad hairline.",
13+
"makes {user} great again.",
14+
"knows that {user} had someone killed to keep them quiet.",
15+
"saw {user} rig the DNC primaries in favor of Clinton."
816
],
917
"parts":{
1018
"insult": [

plugins/clinton.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
import codecs
2-
import json
3-
import os
4-
import random
5-
import asyncio
6-
7-
from cloudbot import hook
8-
from cloudbot.util import textgen
9-
10-
@hook.on_start()
11-
def load_clintons(bot):
12-
"""
13-
:type bot: cloudbot.bot.CloudBot
14-
"""
15-
global clinton_data
16-
17-
with codecs.open(os.path.join(bot.data_dir, "clinton.json"), encoding="utf-8") as f:
18-
clinton_data = json.load(f)
19-
20-
@asyncio.coroutine
21-
@hook.command
22-
def clinton(text, action):
23-
"""clinton a user."""
24-
user = text.strip()
25-
generator = textgen.TextGenerator(clinton_data["templates"], clinton_data["parts"], variables={"user": user})
26-
action(generator.generate_string())
1+
import codecs
2+
import json
3+
import os
4+
import random
5+
import asyncio
6+
7+
from cloudbot import hook
8+
from cloudbot.util import textgen
9+
10+
@hook.on_start()
11+
def load_clintons(bot):
12+
"""
13+
:type bot: cloudbot.bot.CloudBot
14+
"""
15+
global clinton_data
16+
17+
with codecs.open(os.path.join(bot.data_dir, "clinton.json"), encoding="utf-8") as f:
18+
clinton_data = json.load(f)
19+
20+
@asyncio.coroutine
21+
@hook.command
22+
def clinton(text, action):
23+
"""clinton a user."""
24+
user = text.strip()
25+
generator = textgen.TextGenerator(clinton_data["templates"], clinton_data["parts"], variables={"user": user})
26+
action(generator.generate_string())

plugins/history.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ def seen(text, nick, chan, db, event, conn):
109109
last_seen = db.execute("select name, time, quote from seen_user where name like :name escape '/' and chan = :chan",
110110
{'name': text, 'chan': chan}).fetchone()
111111

112+
text = text.replace("/", "")
113+
112114
if last_seen:
113115
reltime = timeformat.time_since(last_seen[1])
114116
if last_seen[0] != text.lower(): # for glob matching

plugins/link_announcer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from cloudbot import hook
66

77
# This will match any URL except the patterns defined in blacklist.
8-
blacklist = '.*(reddit\.com|redd\.it|youtube\.com|youtu\.be|spotify\.com|twitter\.com|twitch\.tv|amazon\.co|xkcd\.com|amzn\.co|steamcommunity\.com|steampowered\.com|newegg\.com|vimeo\.com).*'
8+
blacklist = '.*(reddit\.com|redd\.it|youtube\.com|youtu\.be|spotify\.com|twitter\.com|twitch\.tv|amazon\.co|xkcd\.com|amzn\.co|steamcommunity\.com|steampowered\.com|newegg\.com|soundcloud\.com|vimeo\.com).*'
99
url_re = re.compile('(?!{})http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+~]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'.format(blacklist), re.I)
1010

1111
opt_out = []

plugins/lurve.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,29 @@
55

66
@hook.command("lurve","luff", "luv")
77
def lurve(text, nick, message):
8-
""""loves all over <user>"""
8+
"""lurves all over <user>"""
99
target = text.strip()
10-
11-
12-
loving = [ nick + " wraps arms around " + target + " and clings forever", nick + " cuddles " + target +" in the fluffiest blanket ever", nick + " lays their head on the lap of " + target + " and goes to sleep, dreaming da best sweet dreams ", nick + " caresses " + target + "'s hair", nick + " caresses " + target + "'s cheek", nick + " plants a shy kiss on " + target + "'s cheek", nick + " gives " + target + " a BIIIIIIIIG hug!!!", nick + " lovingly tackles " + target + " into a pit of the softest pillows ever", nick + " cheers happily for " + target + "!!", nick + " pulls " + target + " back into bed for more cuddles ♥~", nick + " snuggles " + target + " for Netflix and chili popcorn", nick + " happily kisses " + target + " on the cheek", nick + " shares a milkshake with " + target]
13-
14-
message(random.choice(loving))
15-
16-
10+
11+
# Use {N} to represent the person's nickname who is performing the action
12+
# Use {T} to represent the person's nickname who is the target of the action
13+
loving = [
14+
"{N} wraps arms around {T} and clings forever",
15+
"{N} cuddles {T} in the fluffiest blanket ever",
16+
"{N} lays their head on the lap of {T} and goes to sleep, dreaming da best sweet dreams",
17+
"{N} caresses {T}'s hair",
18+
"{N} caresses {T}'s cheek",
19+
"{N} plants a shy kiss on {T}'s cheek",
20+
"{N} gives {T} a BIIIIIIIIG hug!!!",
21+
"{N} lovingly tackles {T} into a pit of the softest pillows ever",
22+
"{N} cheers happily for {T}!!",
23+
"{N} pulls {T} back into bed for more cuddles ♥~",
24+
"{N} snuggles {T} for Netflix and chili popcorn",
25+
"{N} happily kisses {T} on the cheek",
26+
"{N} shares a milkshake with {T}"
27+
];
28+
29+
out = "{}".format(random.choice(loving))
30+
out = out.replace("{N}", nick)
31+
out = out.replace("{T}", target)
32+
33+
message(out)

plugins/profiling.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ def pympler_diff():
113113

114114
# # Provide an easy way to get a threaddump, by using SIGUSR1 (only on POSIX systems)
115115
if os.name == "posix":
116-
def debug():
116+
# The handler is called with two arguments: the signal number and the current stack frame
117+
# These parameters should NOT be removed
118+
def debug(sig, frame):
117119
print(get_thread_dump())
118120

119121
signal.signal(signal.SIGUSR1, debug) # Register handler

0 commit comments

Comments
 (0)