From 9d91617975580a9f811588885e4e44f9238ab258 Mon Sep 17 00:00:00 2001 From: neersighted Date: Thu, 1 Mar 2012 21:54:40 -0800 Subject: [PATCH 001/205] roll back version on dev branch --- README.md | 4 ++-- bot.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6dae957..98c7a6c 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# CloudBot/1.1 +# CloudBot/DEV ## About @@ -102,7 +102,7 @@ The programs `screen` or `daemon` are recomended for the wrapper to run optimaly ## License CloudBot is **licensed** under the **GPL v3** license. The terms are as follows. - CloudBot/1.1 + CloudBot/DEV Copyright © 2011 Luke Rogers - diff --git a/bot.py b/bot.py index 6431e06..45fac16 100755 --- a/bot.py +++ b/bot.py @@ -13,7 +13,7 @@ os.chdir(sys.path[0] or '.') # do stuff relative to the install directory class Bot(object): pass -print 'Welcome to Cloudbot - Version 1.1 - http://git.io/cloudbot' +print 'Welcome to Cloudbot - Version DEV - http://git.io/cloudbot' bot = Bot() From dec3690373f3ef4fecbc156bf74567739ed0a831 Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 2 Mar 2012 01:36:47 -0800 Subject: [PATCH 002/205] Fix minor bug in URL detection --- plugins/urlparse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/urlparse.py b/plugins/urlparse.py index d8ba986..8fb29e9 100755 --- a/plugins/urlparse.py +++ b/plugins/urlparse.py @@ -18,7 +18,7 @@ def parse(match): except: return "fail" -@hook.regex(r'(^[^\.])([a-zA-Z]://|www\.)?[^ ]+(\.[a-z]+)(\/)?(.*)') +@hook.regex(r'([a-zA-Z]://|www\.)?[^ ]+(\.[a-z]+)(\/)?(.*)') def urlparser(match, say=None): url = urlnorm.normalize(match.group().encode('utf-8')) if url[:7] != "http://": From e2a575aa0aa5212e8e92fd830df2bfe0b6517809 Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 2 Mar 2012 09:53:46 -0800 Subject: [PATCH 003/205] Fixed typos in lart/kill/slap, added some minecraft ones too! * Added Minecraft-Related LARTs (BECAUSE I CAN!) * Fixed Typos (BECAUSE WE FAIL) --- plugins/kill.py | 4 ++++ plugins/lart.py | 13 +++++++++---- plugins/slap.py | 5 ++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/plugins/kill.py b/plugins/kill.py index e5dfb05..80d652a 100755 --- a/plugins/kill.py +++ b/plugins/kill.py @@ -7,9 +7,13 @@ kills = ["rips off 's and leaves them to die.", "grabs a machine gun and riddles 's body with bullets.", "gags and ties then throws them off a bridge.", "crushes with a huge spiked boulder.", + "stuffs a few TNT blocks under 's bed, and sets them off.", "rams a rocket launcher up 's ass and lets off a few rounds.", "crushes 's skull in with a spiked mace.", + "unleashes the armies of Isengard on .", + "throws to Cthulu!", "feeds to an owlbear.", + "turns into a snail, and then salts them.", "puts into a sack, throws the sack in the river, and hurls the river into space.", "goes bowling with 's head.", "sends to /dev/null!", diff --git a/plugins/lart.py b/plugins/lart.py index 7fc0754..843a3ae 100755 --- a/plugins/lart.py +++ b/plugins/lart.py @@ -13,6 +13,7 @@ larts = ["swaps 's shampoo with glue", "beats senseless with a 50lb Linux manual", "cats /dev/random into 's ear", "signs up for AOL", + "downvotes on Reddit", "enrolls in Visual Basic 101", "sporks ", "drops a truckload of support tickets on ", @@ -21,15 +22,19 @@ larts = ["swaps 's shampoo with glue", "formats 's harddrive to fat12", "rm -rf's ", "stabs ", + "makes learn C++", "steals 's mojo", "strangles with a doohicky mouse cord", "whacks with the cluebat", "sells on EBay", + "drops creepers on 's house", + "throws all of 's diamond gear into lava", "uses as a biological warfare study", "uses the 'Customer Appreciation Bat' on ", "puts in the Total Perspective Vortex", "casts into the fires of Mt. Doom", "gives a melvin", + "turns over to the Fun Police", "turns over to Agent Smith to be 'bugged'", "takes away 's internet connection", "pushes past the Shoe Event Horizon", @@ -62,13 +67,13 @@ larts = ["swaps 's shampoo with glue", "lets Borg have his way with ", "signs up for line dancing classes at the local senior center", "wakes out of a sound sleep with some brand new nipple piercings", - "gives a 2 guage Prince Albert", + "gives a 2 gauge Prince Albert", "forces to eat all their veggies", "covers 's toilet paper with lemon-pepper", "fills 's ketchup bottle with Dave's Insanity sauce", - "forces to stare at an incredibly frustrating and seemingly neverending IRC political debate", + "forces to stare at an incredibly frustrating and seemingly never-ending IRC political debate", "knocks two of 's teeth out with a 2x4", - "removes debian from 's system", + "removes Debian from 's system", "uses 's iPod for skeet shooting practice", "gives 's phone number to Borg", "posts 's IP, username, and password on 4chan", @@ -97,7 +102,7 @@ larts = ["swaps 's shampoo with glue", "does the Australian Death Grip on ", "dances upon the grave of 's ancestors.", "farts in 's general direction", - "flogs with stinging neddle", + "flogs with stinging nettle", "assigns all of the permissions tickets on the BeastNode support system to ", "hands a poison ivy joint"] diff --git a/plugins/slap.py b/plugins/slap.py index a4f7b23..0baac2e 100755 --- a/plugins/slap.py +++ b/plugins/slap.py @@ -17,12 +17,15 @@ items = ["cast iron skillet", "baseball bat", "wooden cane", "CRT monitor", + "diamond sword", "physics textbook", "television", "mau5 head", - "five tonn truck", + "five ton truck", "roll of duct tape", "book", + "cobblestone block", + "lava bucket", "rubber chicken", "gold block", "fire extinguisher", From 95671d5241d15db3c9cc3a0b374f090103ddac25 Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 2 Mar 2012 11:10:51 -0800 Subject: [PATCH 004/205] Merged mcping.py into mctools.py * mcping.py => mctools.py --- plugins/mcping.py | 36 ------------------------------------ plugins/mctools.py | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 37 deletions(-) delete mode 100755 plugins/mcping.py diff --git a/plugins/mcping.py b/plugins/mcping.py deleted file mode 100755 index 5a0e0a1..0000000 --- a/plugins/mcping.py +++ /dev/null @@ -1,36 +0,0 @@ -import socket -import struct - - -from util import hook - -def get_info(host, port): - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - try: - sock.connect((host, port)) - sock.send('\xfe') - response = sock.recv(1) - if response != '\xff': - return "Server gave invalid response: "+repr(response) - length = struct.unpack('!h', sock.recv(2))[0] - values = sock.recv(length*2).decode('utf-16be').split(u'\xa7') - sock.close() - return "%s - %d/%d players" % (values[0], int(values[1]), int(values[2])) - except: - return "Error pinging "+host+":"+str(port)+", is it up? Double-check your address!" - -@hook.command -def mcping(inp): - ".mcping server[:port] - Ping a Minecraft server to check status." - inp = inp.strip().split(" ")[0] - - if ":" in inp: - host, port = inp.split(":", 1) - try: - port = int(port) - except: - return "Invalid port!" - else: - host = inp - port = 25565 - return get_info(host, port) diff --git a/plugins/mctools.py b/plugins/mctools.py index fa2c934..f70bb73 100755 --- a/plugins/mctools.py +++ b/plugins/mctools.py @@ -1,5 +1,25 @@ -from util import hook, http +from util import hook +from util import http import string +import socket +import struct + + +def mcping_connect(host, port): + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + try: + sock.connect((host, port)) + sock.send('\xfe') + response = sock.recv(1) + if response != '\xff': + return "Server gave invalid response: "+repr(response) + length = struct.unpack('!h', sock.recv(2))[0] + values = sock.recv(length*2).decode('utf-16be').split(u'\xa7') + sock.close() + return "%s - %d/%d players" % (values[0], int(values[1]), int(values[2])) + except: + return "Error pinging "+host+":"+str(port)+", is it up? Double-check your address!" + @hook.command(autohelp=False) def mcstatus(inp, bot=None): @@ -36,3 +56,22 @@ def mcpaid(inp): return "The account \'" + inp + "\' is a premium Minecraft account!" else: return "The account \'" + inp + "\' is not a premium Minecraft account!" + +from util import hook + + +@hook.command +def mcping(inp): + ".mcping server[:port] - Ping a Minecraft server to check status." + inp = inp.strip().split(" ")[0] + + if ":" in inp: + host, port = inp.split(":", 1) + try: + port = int(port) + except: + return "Invalid port!" + else: + host = inp + port = 25565 + return mcping_connect(host, port) From a10370fdcd5ccfc8c9cf87ab4f679954df2317b8 Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 2 Mar 2012 11:40:51 -0800 Subject: [PATCH 005/205] Quick patch for (more) unicode support --- core/irc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/core/irc.py b/core/irc.py index b14c828..5a3ccae 100755 --- a/core/irc.py +++ b/core/irc.py @@ -17,6 +17,7 @@ def decode(txt): def censor(text): + text = text.decode('ascii', 'replace') replacement = '[censored]' if 'censored_strings' in bot.config: words = map(re.escape, bot.config['censored_strings']) From c68fafc43a5b76a325a343d79d5b2a7a9821bfc2 Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 2 Mar 2012 12:14:45 -0800 Subject: [PATCH 006/205] Change header to BING --- plugins/translate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/translate.py b/plugins/translate.py index 0709f38..253e5f5 100755 --- a/plugins/translate.py +++ b/plugins/translate.py @@ -1,4 +1,4 @@ -# MyGengo translation plugin by lukeroge and neersighted +# BING translation plugin by lukeroge and neersighted from util import hook from util import http import re From bd6b6206161c35846b2c41b7607cdd83b2e498cd Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 2 Mar 2012 20:04:27 -0800 Subject: [PATCH 007/205] Swap lukeroge with ClouDev --- README.md | 2 +- cloudbot | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 98c7a6c..f803e10 100755 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ CloudBot is **licensed** under the **GPL v3** license. The terms are as follows. CloudBot/DEV - Copyright © 2011 Luke Rogers - + Copyright © 2011 ClouDev - CloudBot is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/cloudbot b/cloudbot index 02f8d37..860e63a 100755 --- a/cloudbot +++ b/cloudbot @@ -5,7 +5,7 @@ echo " / ____/ /___ __ ______/ / __ )____ / /_" echo " / / / / __ \/ / / / __ / __ / __ \/ __/" echo "/ /___/ / /_/ / /_/ / /_/ / /_/ / /_/ / /_ " echo "\____/_/\____/\__,_/\__,_/_____/\____/\__/ " -echo " http://git.io/cloudbot by lukeroge " +echo " http://git.io/cloudbot by ClouDev " echo "" locatefiles() { botfile="/bot.py" From 19022fc80838f288669bf9885c08b42f7eaa0f39 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Sat, 3 Mar 2012 17:07:07 +1300 Subject: [PATCH 008/205] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f803e10..d61e38a 100755 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ CloudBot is **licensed** under the **GPL v3** license. The terms are as follows. CloudBot/DEV - Copyright © 2011 ClouDev - + Copyright © 2011 ClouDev CloudBot is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by From bef009c54e61c426a0af64a4049102c95e098111 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sat, 3 Mar 2012 14:14:40 -0800 Subject: [PATCH 009/205] Tweaks/additions to lart.py --- plugins/lart.py | 205 ++++++++++++++++++++++++------------------------ 1 file changed, 104 insertions(+), 101 deletions(-) diff --git a/plugins/lart.py b/plugins/lart.py index 843a3ae..bacd79b 100755 --- a/plugins/lart.py +++ b/plugins/lart.py @@ -2,109 +2,112 @@ from util import hook import re import random -larts = ["swaps 's shampoo with glue", - "installs windows on 's machine", - "forces to use perl for 3 weeks", - "registers 's name with 50 known spammers", - "resizes 's console to 40x24", - "takes 's drink", - "dispenses 's email address to a few hundred 'bulk mailing services'", - "pokes in the eye", - "beats senseless with a 50lb Linux manual", - "cats /dev/random into 's ear", - "signs up for AOL", - "downvotes on Reddit", - "enrolls in Visual Basic 101", - "sporks ", - "drops a truckload of support tickets on ", - "judo chops ", - "sets 's resolution to 800x600", - "formats 's harddrive to fat12", - "rm -rf's ", - "stabs ", - "makes learn C++", - "steals 's mojo", - "strangles with a doohicky mouse cord", - "whacks with the cluebat", - "sells on EBay", - "drops creepers on 's house", - "throws all of 's diamond gear into lava", - "uses as a biological warfare study", - "uses the 'Customer Appreciation Bat' on ", - "puts in the Total Perspective Vortex", - "casts into the fires of Mt. Doom", - "gives a melvin", - "turns over to the Fun Police", - "turns over to Agent Smith to be 'bugged'", - "takes away 's internet connection", - "pushes past the Shoe Event Horizon", - "counts '1, 2, 5... er... 3!' and hurls the Holy Handgrenade Of Antioch at ", - "puts in a nest of camel spiders", - "makes read slashdot at -1", - "puts 'alias vim=emacs' in 's /etc/profile", - "uninstalls every web browser from 's system", - "locks in the Chateau d'If", - "signs up for getting hit on the head lessons", - "makes try to set up a Lexmark printer", - "fills 's eyedrop bottle with lime juice", +larts = ["swaps 's shampoo with glue.", + "installs Windows on 's computer.", + "forces to use perl for 3 weeks.", + "registers 's name with 50 known spammers.", + "resizes 's console to 40x24.", + "takes 's drink.", + "dispenses 's email address to a few hundred 'bulk mailing services'.", + "pokes in the eye.", + "beats senseless with a 50lb Linux manual.", + "cats /dev/random into 's ear.", + "signs up for AOL.", + "downvotes on Reddit.", + "enrolls in Visual Basic 101.", + "sporks .", + "drops a truckload of support tickets on .", + "judo chops .", + "sets 's resolution to 800x600.", + "formats 's harddrive to fat12.", + "rm -rf's .", + "stabs .", + "makes learn C++.", + "steals 's mojo.", + "strangles with a doohicky mouse cord.", + "whacks with the cluebat.", + "sells on EBay.", + "drops creepers on 's house.", + "throws all of 's diamond gear into lava.", + "uses as a biological warfare study.", + "uses the 'Customer Appreciation Bat' on .", + "puts in the Total Perspective Vortex.", "casts into the fires of Mt. Doom.", - "gives a Flying Dutchman", - "rips off 's arm, and uses it to beat them to death", - "pierces 's nose with a rusty paper hole puncher", - "pokes with a rusty nail", - "puts sugar between 's bedsheets", - "pours sand into 's breakfast", - "mixes epoxy into 's toothpaste", - "puts Icy-Hot in 's lube container", - "straps to a chair, and plays a endless low bitrate MP3 loop of \"the world's most annoying sound\" from \"Dumb and Dumber\"", - "tells Dr. Dre that was talking smack", - "forces to use a Commodore 64 for all their word processing", - "smacks in the face with a burlap sack full of broken glass", - "puts in a room with several heavily armed manic depressives", - "makes watch reruns of \"Blue's Clues\"", - "puts lye in 's coffee", - "tattoos the Windows symbol on 's ass", - "lets Borg have his way with ", - "signs up for line dancing classes at the local senior center", - "wakes out of a sound sleep with some brand new nipple piercings", - "gives a 2 gauge Prince Albert", - "forces to eat all their veggies", - "covers 's toilet paper with lemon-pepper", - "fills 's ketchup bottle with Dave's Insanity sauce", - "forces to stare at an incredibly frustrating and seemingly never-ending IRC political debate", - "knocks two of 's teeth out with a 2x4", - "removes Debian from 's system", - "uses 's iPod for skeet shooting practice", - "gives 's phone number to Borg", - "posts 's IP, username, and password on 4chan", - "forces to use words like 'irregardless' and 'administrate' (thereby sounding like a real dumbass)", - "tickles until they wet their pants and pass out", - "replaces 's KY with elmer's clear wood glue", - "replaces 's TUMS with alka-seltzer tablets", - "squeezes habanero pepper juice into 's tub of vaseline", - "Forces to learn the Win32 API", - "gives an atomic wedgie", - "ties to a chair and forces them to listen to 'N Sync at full blast", - "forces to use notepad for text editing", - "frowns at really really hard", - "jabs a hot lighter into 's eye sockets", - "forces to browse the web with IE6", - "takes out at the knees with a broken pool cue", - "forces to listen to emo music", - "lets a few creepers into 's house", - "signs up for the Iowa State Ferret Legging Championship", - "attempts to hotswap 's RAM", - "dragon punches ", - "puts track spikes into 's side", - "replaces 's Astroglide with JB Weld", - "replaces 's stress pills with rat poison pellets", - "replaces s crotch itch cream with Nair", - "does the Australian Death Grip on ", + "gives a melvin.", + "turns over to the Fun Police.", + "turns over to Agent Smith to be 'bugged'.", + "takes away 's internet connection.", + "pushes past the Shoe Event Horizon.", + "counts '1, 2, 5... er... 3!' and hurls the Holy Handgrenade Of Antioch at .", + "puts in a nest of camel spiders.", + "makes read slashdot at -1.", + "puts 'alias vim=emacs' in 's /etc/profile.", + "uninstalls every web browser from 's system.", + "locks in the Chateau d'If.", + "signs up for getting hit on the head lessons.", + "makes try to set up a Lexmark printer.", + "fills 's eyedrop bottle with lime juice.", + "casts into the fires of Mt. Doom.", + "gives a Flying Dutchman.", + "rips off 's arm, and uses it to beat them to death.", + "pierces 's nose with a rusty paper hole puncher.", + "pokes with a rusty nail.", + "puts sugar between 's bedsheets.", + "pours sand into 's breakfast.", + "mixes epoxy into 's toothpaste.", + "puts Icy-Hot in 's lube container.", + "straps to a chair, and plays a endless low bitrate MP3 loop of \"the world's most annoying sound\" from \"Dumb and Dumber\".", + "tells Dr. Dre that was talking smack.", + "forces to use a Commodore 64 for all their word processing.", + "smacks in the face with a burlap sack full of broken glass.", + "puts in a room with several heavily armed manic depressives.", + "makes watch reruns of \"Blue's Clues\".", + "puts lye in 's coffee.", + "introduces to the clue-by-four.", + "tattoos the Windows symbol on 's ass.", + "lets Borg have his way with .", + "signs up for line dancing classes at the local senior center.", + "wakes out of a sound sleep with some brand new nipple piercings.", + "gives a 2 gauge Prince Albert.", + "forces to eat all their veggies.", + "covers 's toilet paper with lemon-pepper.", + "fills 's ketchup bottle with Dave's Insanity sauce.", + "forces to stare at an incredibly frustrating and seemingly never-ending IRC political debate.", + "knocks two of 's teeth out with a 2x4.", + "removes Debian from 's system.", + "switches over to CentOS.", + "uses 's iPod for skeet shooting practice.", + "gives 's phone number to Borg.", + "posts 's IP, username(s), and password(s) on 4chan.", + "forces to use words like 'irregardless' and 'administrate' (thereby sounding like a real dumbass).", + "tickles until they wet their pants and pass out.", + "replaces 's KY with elmer's clear wood glue.", + "replaces 's TUMS with alka-seltzer tablets.", + "squeezes habanero pepper juice into 's tub of vaseline.", + "forces to learn the Win32 API.", + "gives an atomic wedgie.", + "ties to a chair and forces them to listen to 'N Sync at full blast.", + "forces to use notepad for text editing.", + "frowns at really, really hard.", + "jabs a hot lighter into 's eye sockets.", + "forces to browse the web with IE6.", + "takes out at the knees with a broken pool cue.", + "forces to listen to emo music.", + "lets a few creepers into 's house.", + "signs up for the Iowa State Ferret Legging Championship.", + "attempts to hotswap 's RAM.", + "dragon punches .", + "puts railroad spikes into 's side.", + "replaces 's Astroglide with JB Weld.", + "replaces 's stress pills with rat poison pellets.", + "replaces 's crotch itch cream with Nair.", + "does the Australian Death Grip on .", "dances upon the grave of 's ancestors.", - "farts in 's general direction", - "flogs with stinging nettle", - "assigns all of the permissions tickets on the BeastNode support system to ", - "hands a poison ivy joint"] + "farts in 's general direction.", + "flogs with stinging nettle.", + "intoduces to the Knights who say Ni.", + "assigns all of the permissions tickets on the BeastNode support system to .", + "hands a poison ivy joint."] @hook.command def lart(inp, me=None, nick=None, input=None, notice=None): From a82b385622fbfba2a86df053d4bcc8c6997a0388 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sat, 3 Mar 2012 14:28:42 -0800 Subject: [PATCH 010/205] Fixed typos/added stuff to flirt.py, kill.py,and slap.py --- plugins/flirt.py | 8 ++++---- plugins/kill.py | 6 ++++++ plugins/slap.py | 20 ++++++++++---------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/plugins/flirt.py b/plugins/flirt.py index 0706b04..c7389d1 100755 --- a/plugins/flirt.py +++ b/plugins/flirt.py @@ -10,7 +10,7 @@ flirts = ["I bet your name's Mickey, 'cause you're so fine.", "I've been bad, take me to your room.", "I think Heaven's missing an angel.", "That shirt looks good on you, it'd look better on my bedroom floor.", - "I cant help to notice but you look a lot like my next girlfriend", + "I cant help to notice but you look a lot like my next girlfriend.", "Aren't your feet tired? Because you've been running through my mind all day.", "I must be asleep, 'cause you are a dream come true. Also, I'm slightly damp.", "I like large posteriors and I cannot prevaricate.", @@ -30,14 +30,14 @@ flirts = ["I bet your name's Mickey, 'cause you're so fine.", "Does this rag smell like chloroform to you? ", "I'm here, where are your other two wishes?", "Apart from being sexy, what do you do for a living?", - "Hi, I'm Mr. Right. Someone said you were looking for me. ", + "Hi, I'm Mr. Right. Someone said you were looking for me.", "You got something on your chest: My eyes.", "Are you from Tennessee? Cause you're the only TEN I see.", "Are you an alien? Because you just abducted my heart.", - "Excuse me, but I think you dropped something!!! MY JAW!!", + "Excuse me, but I think you dropped something!!! MY JAW!!!", "If I followed you home, would you keep me?", "Where have you been all my life?", - "I'm just a love machine, and I don't work for nobody but you", + "I'm just a love machine, and I don't work for nobody but you.", "Do you live on a chicken farm? Because you sure know how to raise cocks.", "Are you wearing space pants? Because your ass is out of this world.", "Nice legs. What time do they open?", diff --git a/plugins/kill.py b/plugins/kill.py index 80d652a..1f5e8ea 100755 --- a/plugins/kill.py +++ b/plugins/kill.py @@ -5,17 +5,23 @@ import random kills = ["rips off 's and leaves them to die.", "grabs 's head and rips it clean off their body.", "grabs a machine gun and riddles 's body with bullets.", + "sends The Terminator on a mission to retrieve 's .", "gags and ties then throws them off a bridge.", "crushes with a huge spiked boulder.", + "glares at until they die of boredom.", "stuffs a few TNT blocks under 's bed, and sets them off.", + "shivs in the .", "rams a rocket launcher up 's ass and lets off a few rounds.", "crushes 's skull in with a spiked mace.", "unleashes the armies of Isengard on .", + "packs into a SVN repo.", "throws to Cthulu!", "feeds to an owlbear.", "turns into a snail, and then salts them.", + "snacks on 's .", "puts into a sack, throws the sack in the river, and hurls the river into space.", "goes bowling with 's head.", + "uses 's as a back-scratcher.", "sends to /dev/null!", "feeds coke and mentos till they pop!"] diff --git a/plugins/slap.py b/plugins/slap.py index 0baac2e..1253660 100755 --- a/plugins/slap.py +++ b/plugins/slap.py @@ -2,15 +2,15 @@ from util import hook import re import random -slaps = ["slaps with a ", - "slaps around a bit with a ", - "throws a at ", - "grabs a and throws it in 's face", - "holds down and repeatedly whacks them with a ", - "prods with a flaming ", - "picks up a , and whacks with it", - "ties to a chair and throws a at them", - "hits on the head with a "] +slaps = ["slaps with a .", + "slaps around a bit with a .", + "throws a at .", + "grabs a and throws it in 's face.", + "holds down and repeatedly whacks them with a .", + "prods with a flaming .", + "picks up a , and whacks with it.", + "ties to a chair and throws a at them.", + "hits on the head with a ."] items = ["cast iron skillet", "large trout", @@ -20,7 +20,7 @@ items = ["cast iron skillet", "diamond sword", "physics textbook", "television", - "mau5 head", + "mau5head", "five ton truck", "roll of duct tape", "book", From dba741003fa18e47f210bd462f9f71f27e10b717 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sat, 3 Mar 2012 14:34:21 -0800 Subject: [PATCH 011/205] added more to kill.py/slap.py --- plugins/kill.py | 1 + plugins/slap.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/plugins/kill.py b/plugins/kill.py index 1f5e8ea..92d9ca3 100755 --- a/plugins/kill.py +++ b/plugins/kill.py @@ -15,6 +15,7 @@ kills = ["rips off 's and leaves them to die.", "crushes 's skull in with a spiked mace.", "unleashes the armies of Isengard on .", "packs into a SVN repo.", + "slices 's off with a Katana", "throws to Cthulu!", "feeds to an owlbear.", "turns into a snail, and then salts them.", diff --git a/plugins/slap.py b/plugins/slap.py index 1253660..e162f56 100755 --- a/plugins/slap.py +++ b/plugins/slap.py @@ -5,7 +5,10 @@ import random slaps = ["slaps with a .", "slaps around a bit with a .", "throws a at .", + "chucks a few s at .", "grabs a and throws it in 's face.", + "launches a in 's general direction.", + "sits on 's face, while slamming a into their crotch.", "holds down and repeatedly whacks them with a .", "prods with a flaming .", "picks up a , and whacks with it.", From be35cc586a5820e66e024261a7d9c6a7c2ea6206 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sat, 3 Mar 2012 15:13:13 -0800 Subject: [PATCH 012/205] Added proper exit codes to the wrapper --- cloudbot | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cloudbot b/cloudbot index 860e63a..850b271 100755 --- a/cloudbot +++ b/cloudbot @@ -77,6 +77,7 @@ processargs() { start) if running; then echo "Cannot start! Bot is already running!" + exit 1 else echo "Starting CloudBot... ($backend)" start @@ -88,6 +89,7 @@ processargs() { stop else echo "Cannot stop! Bot is not already running!" + exit 1 fi ;; restart) @@ -97,6 +99,7 @@ processargs() { start else echo "Cannot restart! Bot is not already running!" + exit 1 fi ;; clear) @@ -122,3 +125,4 @@ main() { } main $* +exit 0 \ No newline at end of file From 7e3ce7ddba75736e0a3de2a0c0f444b0db232e8b Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Sun, 4 Mar 2012 13:47:14 +1300 Subject: [PATCH 013/205] Re-added rating --- plugins/youtube.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/youtube.py b/plugins/youtube.py index cd12256..91f1d30 100755 --- a/plugins/youtube.py +++ b/plugins/youtube.py @@ -37,6 +37,10 @@ def get_video_description(vid_id): out += '%dm ' % (length / 60 % 60) out += "%ds\x02" % (length % 60) + if 'rating' in j: + out += ' - rated \x02%.2f/5.0\x02 (%d)' % (j['rating'], + j['ratingCount']) + if 'viewCount' in j: out += ' - \x02%s\x02 views' % locale.format('%d', j['viewCount'], 1) From 104a4d681048f375413b881a1b5ef3a3fc687a5b Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Sun, 4 Mar 2012 14:23:39 +1300 Subject: [PATCH 014/205] Made url parsing toggleable, added more advenced regex --- core/config.py | 4 ++++ plugins/urlparse.py | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/core/config.py b/core/config.py index 8ea8255..5c39127 100755 --- a/core/config.py +++ b/core/config.py @@ -46,6 +46,10 @@ if not os.path.exists('config'): "factoids": { "prefix": false + }, + "urlparse": + { + "enabled": false } }, "censored_strings": diff --git a/plugins/urlparse.py b/plugins/urlparse.py index 8fb29e9..fc6b7aa 100755 --- a/plugins/urlparse.py +++ b/plugins/urlparse.py @@ -18,8 +18,17 @@ def parse(match): except: return "fail" -@hook.regex(r'([a-zA-Z]://|www\.)?[^ ]+(\.[a-z]+)(\/)?(.*)') -def urlparser(match, say=None): +# there should be " after the ' in the regex string but I was unable to escape it properly +@hook.regex(r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'.,<>?«»“”‘’]))") +def urlparser(match, say=None, bot=None): + try: + enabled = bot.config["plugins"]["urlparse"]["enabled"] + except KeyError: + enabled = False + + if not enabled: + return + url = urlnorm.normalize(match.group().encode('utf-8')) if url[:7] != "http://": if url[:8] != "https://": @@ -33,8 +42,8 @@ def urlparser(match, say=None): title = http.unescape(title) realurl = http.get_url(url) if realurl == url: - say("(Link) %s" % title) + say(u"(Link) %s" % title) return else: - say("(Link) %s [%s]" % (title, realurl)) + say(u"(Link) %s [%s]" % (title, realurl)) return From 8aaede9ad6ff86e9d74a34d204a15ced87794bb6 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Sun, 4 Mar 2012 14:32:58 +1300 Subject: [PATCH 015/205] Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d61e38a..d174eed 100755 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ For the wrapper to work best, install `screen`, or `daemon`: If you are a user of another Linux disto, use your package manager to install the dependencies, or, for other operating systems, use **Google** to locate source packages you can install. -Once you have installed the required dependencies, run the bot☩: +Once you have installed the required dependencies, run the bot¹: `./cloudbot start` @@ -87,17 +87,17 @@ They can both be found in [#CloudBot](irc://irc.esper.net/cloudbot "Connect via **mau5bot** is the stable bot, and runs on the latest release version of CloudBot. (mau5bot is running on **Ubuntu Server** *Oneric Ocelot/11.10* with **Python** *2.7.2*) -**neerbot** is the unstable bot, and runs on the latest development☩☩ version of CloudBot. (neerbot is running on **Debian** *Wheezy/Testing* with **Python** *2.7.2*) +**neerbot** is the unstable bot, and runs on the latest development² version of CloudBot. (neerbot is running on **Debian** *Wheezy/Testing* with **Python** *2.7.2*) ## Requirements -CloudBot runs on **Python** *2.7.x*. It is developed on **Debian** *Wheezy/Testing* with **Python** *2.7.2*. +CloudBot runs on **Python** *2.7.x*. It is developed on **Debian** *Wheezy/Testing* and **Ubuntu** *11.10* with **Python** *2.7.2*. It **requires Python modules** `lXML`, `BeautifulSoup`, `Enchant`, `MyGengo`, and `HTTPlib2`. The programs `screen` or `daemon` are recomended for the wrapper to run optimaly. -**Windows** users: Windows compatibility with the wrapper and some plugins is **broken** (such as the ping), but we do intend to add it.☩☩☩ +**Windows** users: Windows compatibility with the wrapper and some plugins is **broken** (such as the ping), but we do intend to add it.³ ## License CloudBot is **licensed** under the **GPL v3** license. The terms are as follows. @@ -121,8 +121,8 @@ CloudBot is **licensed** under the **GPL v3** license. The terms are as follows. ## ☩ -☩ if you prefer to run the bot with a custom backend/run it manually, or are on **Windows**, run the bot with `./bot.py` +¹ if you prefer to run the bot with a custom backend/run it manually, or are on **Windows**, run the bot with `./bot.py` -☩☩ or whatever version [neersighted](http://git.io/neersighted) is currently hacking on +² or whatever version [neersighted](http://git.io/neersighted) is currently hacking on -☩☩☩ eventually +³ eventually From 26d8cce1c5c0b4bf7a3b342a48a971e704fa87d8 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Sun, 4 Mar 2012 14:33:38 +1300 Subject: [PATCH 016/205] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d174eed..e25ef5b 100755 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ CloudBot is **licensed** under the **GPL v3** license. The terms are as follows. You should have received a copy of the GNU General Public License along with CloudBot. If not, see . -## ☩ +## Notes ¹ if you prefer to run the bot with a custom backend/run it manually, or are on **Windows**, run the bot with `./bot.py` From bf58e1a8a335a49ce246aee8f445c3a10726e0d5 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Mon, 5 Mar 2012 11:13:48 +1300 Subject: [PATCH 017/205] Removed penis reference that was never supposed to be pushed to github. ._. --- plugins/password.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/plugins/password.py b/plugins/password.py index 08ea501..c550ab6 100755 --- a/plugins/password.py +++ b/plugins/password.py @@ -40,7 +40,7 @@ def gen_password(types): okay.append(x) else: needs_def = 1 - #defualts to lowercase alpha password if no arguments are found + #defaults to lowercase alpha password if no arguments are found if needs_def == 1: for x in string.ascii_lowercase: okay.append(x) @@ -55,8 +55,4 @@ def gen_password(types): def password(inp, notice=None): ".password [types] -- Generates a password of (default 10). [types] can include 'alpha', 'no caps', 'numeric', 'symbols' or any combination of the types, eg. 'numbers symbols'" password = gen_password(inp) - short = "error: input too short" - penis = ["penis", "mypenis", "dick", "mydick"] - if inp in penis: - return short notice(password) From 59628292c13772626526f9ae03ecd502a233e9df Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 5 Mar 2012 20:53:45 -0800 Subject: [PATCH 018/205] Cleaned up flirt, kill, lart, and slap.py --- plugins/flirt.py | 15 +++++++++++---- plugins/kill.py | 14 +++++++------- plugins/lart.py | 6 +++--- plugins/slap.py | 10 +++------- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/plugins/flirt.py b/plugins/flirt.py index c7389d1..fd610b3 100755 --- a/plugins/flirt.py +++ b/plugins/flirt.py @@ -47,9 +47,16 @@ flirts = ["I bet your name's Mickey, 'cause you're so fine.", @hook.command(autohelp=False) def flirt(inp, nick=None, me=None, input=None): ".flirt -- Make the bot flirt with ." - msg = "flirts with " + nick + "... \"" + random.choice(flirts) + "\"" - if re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()) and inp != "": - msg = "flirts with " + inp + "... \"" + random.choice(flirts) + "\"" + inp = inp.strip() + + if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): + notice("Invalid username!") + return + + target = nick + if inp.lower() and inp != "": + target = inp if inp == input.conn.nick.lower() or inp == "itself": - msg = "flirts with itself... \"" + random.choice(flirts) + "\"" + target = "itself" + msg = "flirts with " + target + "... \"" + random.choice(flirts) + "\"" me(msg) diff --git a/plugins/kill.py b/plugins/kill.py index 92d9ca3..20e6324 100755 --- a/plugins/kill.py +++ b/plugins/kill.py @@ -42,12 +42,12 @@ def kill(inp, me=None, nick=None, input=None, notice=None): return if inp == input.conn.nick.lower() or inp == "itself": - kill = random.choice(kills) - kill = re.sub ('', nick, kill) - msg = re.sub ('', random.choice(body), kill) + target = random.choice(kills) + target = re.sub ('', nick, target) + target = re.sub ('', random.choice(body), target) else: - kill = random.choice(kills) - kill = re.sub ('', inp, kill) - msg = re.sub ('', random.choice(body), kill) - + target = random.choice(kills) + target = re.sub ('', inp, target) + target = re.sub ('', random.choice(body), target) + msg = target me(msg) diff --git a/plugins/lart.py b/plugins/lart.py index bacd79b..5fa8388 100755 --- a/plugins/lart.py +++ b/plugins/lart.py @@ -119,8 +119,8 @@ def lart(inp, me=None, nick=None, input=None, notice=None): return if inp == input.conn.nick.lower() or inp == "itself": - msg = re.sub ('', nick, random.choice(larts)) + target = nick else: - msg = re.sub ('', inp, random.choice(larts)) - + target = inp + msg = re.sub ('', target, random.choice(larts)) me(msg) diff --git a/plugins/slap.py b/plugins/slap.py index e162f56..8fffd45 100755 --- a/plugins/slap.py +++ b/plugins/slap.py @@ -45,12 +45,8 @@ def slap(inp, me=None, nick=None, input=None, notice=None): return if inp == input.conn.nick.lower() or inp == "itself": - slap = random.choice(slaps) - slap = re.sub ('', nick, slap) - msg = re.sub ('', random.choice(items), slap) + target = re.sub ('', nick, random.choice(slaps)) else: - slap = random.choice(slaps) - slap = re.sub ('', inp, slap) - msg = re.sub ('', random.choice(items), slap) - + target = re.sub ('', inp, random.choice(slaps)) + msg = re.sub ('', random.choice(items), target) me(msg) From 0948ceed1217179a30e6242c155224d6c265af30 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 5 Mar 2012 20:56:03 -0800 Subject: [PATCH 019/205] fixed minor naming issue in kill.py --- plugins/kill.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/kill.py b/plugins/kill.py index 20e6324..c698cc8 100755 --- a/plugins/kill.py +++ b/plugins/kill.py @@ -44,10 +44,10 @@ def kill(inp, me=None, nick=None, input=None, notice=None): if inp == input.conn.nick.lower() or inp == "itself": target = random.choice(kills) target = re.sub ('', nick, target) - target = re.sub ('', random.choice(body), target) + kill = re.sub ('', random.choice(body), target) else: target = random.choice(kills) target = re.sub ('', inp, target) - target = re.sub ('', random.choice(body), target) - msg = target + kill = re.sub ('', random.choice(body), target) + msg = kill me(msg) From de9fa026df0e59fb24e62ba824adee1559cc1370 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 5 Mar 2012 20:59:05 -0800 Subject: [PATCH 020/205] realized I was repeating lines, fixed that --- plugins/kill.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/plugins/kill.py b/plugins/kill.py index c698cc8..a4daedd 100755 --- a/plugins/kill.py +++ b/plugins/kill.py @@ -42,12 +42,11 @@ def kill(inp, me=None, nick=None, input=None, notice=None): return if inp == input.conn.nick.lower() or inp == "itself": - target = random.choice(kills) - target = re.sub ('', nick, target) - kill = re.sub ('', random.choice(body), target) + target = inp else: - target = random.choice(kills) - target = re.sub ('', inp, target) - kill = re.sub ('', random.choice(body), target) + target = nick + kill = random.choice(kills) + kill = re.sub ('', target, target) + kill = re.sub ('', random.choice(body), target) msg = kill me(msg) From a459d10cfaff176a1b05e0b6b055684d3fbd0ac9 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Tue, 6 Mar 2012 18:00:34 +1300 Subject: [PATCH 021/205] why did we need that line? :P --- plugins/kill.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/kill.py b/plugins/kill.py index a4daedd..272f4c0 100755 --- a/plugins/kill.py +++ b/plugins/kill.py @@ -48,5 +48,4 @@ def kill(inp, me=None, nick=None, input=None, notice=None): kill = random.choice(kills) kill = re.sub ('', target, target) kill = re.sub ('', random.choice(body), target) - msg = kill - me(msg) + me(kill) From 7a1dac692a72405a73197feadc4a731e36a79551 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Tue, 6 Mar 2012 18:03:11 +1300 Subject: [PATCH 022/205] Standardised shit --- plugins/kill.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/kill.py b/plugins/kill.py index 272f4c0..33beea0 100755 --- a/plugins/kill.py +++ b/plugins/kill.py @@ -45,7 +45,7 @@ def kill(inp, me=None, nick=None, input=None, notice=None): target = inp else: target = nick - kill = random.choice(kills) - kill = re.sub ('', target, target) - kill = re.sub ('', random.choice(body), target) - me(kill) + msg = random.choice(kills) + msg = re.sub ('', target, target) + msg = re.sub ('', random.choice(body), target) + me(msg) From db52b155705dfbac0ecb738446c085a59ab0bd97 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 5 Mar 2012 21:21:02 -0800 Subject: [PATCH 023/205] My patch broke the bot, removed --- core/irc.py | 1 - 1 file changed, 1 deletion(-) diff --git a/core/irc.py b/core/irc.py index 5a3ccae..b14c828 100755 --- a/core/irc.py +++ b/core/irc.py @@ -17,7 +17,6 @@ def decode(txt): def censor(text): - text = text.decode('ascii', 'replace') replacement = '[censored]' if 'censored_strings' in bot.config: words = map(re.escape, bot.config['censored_strings']) From f4435f4557b138059d93ad7147f20d824c61adbe Mon Sep 17 00:00:00 2001 From: lukeroge Date: Tue, 6 Mar 2012 18:33:45 +1300 Subject: [PATCH 024/205] Made quote.py return quotes from all channels if called with .q --- plugins/quote.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/plugins/quote.py b/plugins/quote.py index 04a5237..cb20f2b 100755 --- a/plugins/quote.py +++ b/plugins/quote.py @@ -60,8 +60,28 @@ def get_quote_num(num, count, name): num = random.randint(1, count) return num -def get_quote_by_nick(db, chan, nick, num=False): +def get_quote_by_nick(db, nick, num=False): "Returns a formatted quote from a nick, random or selected by number" + count = db.execute('''SELECT COUNT(*) + FROM quote + WHERE deleted != 1 + AND lower(nick) = lower(?)''', [nick]).fetchall()[0][0] + + try: + num = get_quote_num(num, count, nick) + except Exception as error_message: + return error_message + + quote = db.execute('''SELECT time, nick, msg + FROM quote + WHERE deleted != 1 + AND lower(nick) = lower(?) + ORDER BY time + LIMIT ?, 1''', (nick, (num-1))).fetchall()[0] + return format_quote(quote, num, count) + +def get_quote_by_nick_chan(db, chan, nick, num=False): + "Returns a formatted quote from a nick in a channel, random or selected by number" count = db.execute('''SELECT COUNT(*) FROM quote WHERE deleted != 1 @@ -122,9 +142,9 @@ def quote(inp, nick='', chan='', db=None, notice=None): if by_chan: return get_quote_by_chan(db, select, num) else: - return get_quote_by_nick(db, chan, select, num) + return get_quote_by_nick(db, select, num) elif retrieve_chan: chan, nick, num = retrieve_chan.groups() - return get_quote_by_nick(db, chan, nick, num) + return get_quote_by_nick_chan(db, chan, nick, num) notice(quote.__doc__) From 34859743d0b5fa49fedcd805a4ad36e96930301c Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 5 Mar 2012 23:08:03 -0800 Subject: [PATCH 025/205] Added PyDev stuff to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index bd69f72..fe205b0 100755 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ config .*.swp *.pyc *.orig +.project +.pydevproject From 5ffc63a7b4da5e731f43281e58a908545d1ee33f Mon Sep 17 00:00:00 2001 From: neersighted Date: Tue, 6 Mar 2012 10:14:26 -0800 Subject: [PATCH 026/205] Mereged kill, lart, and slap.py > violence.py --- plugins/kill.py | 51 --------------- plugins/slap.py | 52 --------------- plugins/{lart.py => violence.py} | 105 ++++++++++++++++++++++++++++++- 3 files changed, 104 insertions(+), 104 deletions(-) delete mode 100755 plugins/kill.py delete mode 100755 plugins/slap.py rename plugins/{lart.py => violence.py} (63%) mode change 100755 => 100644 diff --git a/plugins/kill.py b/plugins/kill.py deleted file mode 100755 index 33beea0..0000000 --- a/plugins/kill.py +++ /dev/null @@ -1,51 +0,0 @@ -from util import hook -import re -import random - -kills = ["rips off 's and leaves them to die.", - "grabs 's head and rips it clean off their body.", - "grabs a machine gun and riddles 's body with bullets.", - "sends The Terminator on a mission to retrieve 's .", - "gags and ties then throws them off a bridge.", - "crushes with a huge spiked boulder.", - "glares at until they die of boredom.", - "stuffs a few TNT blocks under 's bed, and sets them off.", - "shivs in the .", - "rams a rocket launcher up 's ass and lets off a few rounds.", - "crushes 's skull in with a spiked mace.", - "unleashes the armies of Isengard on .", - "packs into a SVN repo.", - "slices 's off with a Katana", - "throws to Cthulu!", - "feeds to an owlbear.", - "turns into a snail, and then salts them.", - "snacks on 's .", - "puts into a sack, throws the sack in the river, and hurls the river into space.", - "goes bowling with 's head.", - "uses 's as a back-scratcher.", - "sends to /dev/null!", - "feeds coke and mentos till they pop!"] - -body = ['head', - 'arms', - 'leg', - 'arm', - '"special parts"'] - -@hook.command -def kill(inp, me=None, nick=None, input=None, notice=None): - ".kill -- Makes the bot kill ." - inp = inp.strip() - - if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): - notice("Invalid username!") - return - - if inp == input.conn.nick.lower() or inp == "itself": - target = inp - else: - target = nick - msg = random.choice(kills) - msg = re.sub ('', target, target) - msg = re.sub ('', random.choice(body), target) - me(msg) diff --git a/plugins/slap.py b/plugins/slap.py deleted file mode 100755 index 8fffd45..0000000 --- a/plugins/slap.py +++ /dev/null @@ -1,52 +0,0 @@ -from util import hook -import re -import random - -slaps = ["slaps with a .", - "slaps around a bit with a .", - "throws a at .", - "chucks a few s at .", - "grabs a and throws it in 's face.", - "launches a in 's general direction.", - "sits on 's face, while slamming a into their crotch.", - "holds down and repeatedly whacks them with a .", - "prods with a flaming .", - "picks up a , and whacks with it.", - "ties to a chair and throws a at them.", - "hits on the head with a ."] - -items = ["cast iron skillet", - "large trout", - "baseball bat", - "wooden cane", - "CRT monitor", - "diamond sword", - "physics textbook", - "television", - "mau5head", - "five ton truck", - "roll of duct tape", - "book", - "cobblestone block", - "lava bucket", - "rubber chicken", - "gold block", - "fire extinguisher", - "heavy rock", - "chunk of dirt"] - -@hook.command -def slap(inp, me=None, nick=None, input=None, notice=None): - ".slap -- Makes the bot slap ." - inp = inp.strip() - - if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): - notice("Invalid username!") - return - - if inp == input.conn.nick.lower() or inp == "itself": - target = re.sub ('', nick, random.choice(slaps)) - else: - target = re.sub ('', inp, random.choice(slaps)) - msg = re.sub ('', random.choice(items), target) - me(msg) diff --git a/plugins/lart.py b/plugins/violence.py old mode 100755 new mode 100644 similarity index 63% rename from plugins/lart.py rename to plugins/violence.py index 5fa8388..3701a28 --- a/plugins/lart.py +++ b/plugins/violence.py @@ -2,6 +2,40 @@ from util import hook import re import random + +slaps = ["slaps with a .", + "slaps around a bit with a .", + "throws a at .", + "chucks a few s at .", + "grabs a and throws it in 's face.", + "launches a in 's general direction.", + "sits on 's face, while slamming a into their crotch.", + "holds down and repeatedly whacks them with a .", + "prods with a flaming .", + "picks up a , and whacks with it.", + "ties to a chair and throws a at them.", + "hits on the head with a ."] + +items = ["cast iron skillet", + "large trout", + "baseball bat", + "wooden cane", + "CRT monitor", + "diamond sword", + "physics textbook", + "television", + "mau5head", + "five ton truck", + "roll of duct tape", + "book", + "cobblestone block", + "lava bucket", + "rubber chicken", + "gold block", + "fire extinguisher", + "heavy rock", + "chunk of dirt"] + larts = ["swaps 's shampoo with glue.", "installs Windows on 's computer.", "forces to use perl for 3 weeks.", @@ -109,8 +143,57 @@ larts = ["swaps 's shampoo with glue.", "assigns all of the permissions tickets on the BeastNode support system to .", "hands a poison ivy joint."] +kills = ["rips off 's and leaves them to die.", + "grabs 's head and rips it clean off their body.", + "grabs a machine gun and riddles 's body with bullets.", + "sends The Terminator on a mission to retrieve 's .", + "gags and ties then throws them off a bridge.", + "crushes with a huge spiked boulder.", + "glares at until they die of boredom.", + "stuffs a few TNT blocks under 's bed, and sets them off.", + "shivs in the .", + "rams a rocket launcher up 's ass and lets off a few rounds.", + "crushes 's skull in with a spiked mace.", + "unleashes the armies of Isengard on .", + "packs into a SVN repo.", + "slices 's off with a Katana", + "throws to Cthulu!", + "feeds to an owlbear.", + "turns into a snail, and then salts them.", + "snacks on 's .", + "puts into a sack, throws the sack in the river, and hurls the river into space.", + "goes bowling with 's head.", + "uses 's as a back-scratcher.", + "sends to /dev/null!", + "feeds coke and mentos till they pop!"] + +body = ['head', + 'arms', + 'leg', + 'arm', + '"special parts"'] + + @hook.command -def lart(inp, me=None, nick=None, input=None, notice=None): +def slap(inp, me=None, nick=None, input=None, notice=None): + ".slap -- Makes the bot slap ." + inp = inp.strip() + + if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): + notice("Invalid username!") + return + + if inp == input.conn.nick.lower() or inp == "itself": + target = re.sub ('', nick, random.choice(slaps)) + else: + target = re.sub ('', inp, random.choice(slaps)) + msg = re.sub ('', random.choice(items), target) + me(msg) + + + +@hook.command +def lart(inp, me=None, nick=None, input=None, notice=None): ".lart -- Makes the bot LART ." inp = inp.strip() @@ -124,3 +207,23 @@ def lart(inp, me=None, nick=None, input=None, notice=None): target = inp msg = re.sub ('', target, random.choice(larts)) me(msg) + + + +@hook.command +def kill(inp, me=None, nick=None, input=None, notice=None): + ".kill -- Makes the bot kill ." + inp = inp.strip() + + if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): + notice("Invalid username!") + return + + if inp == input.conn.nick.lower() or inp == "itself": + target = inp + else: + target = nick + msg = random.choice(kills) + msg = re.sub ('', target, target) + msg = re.sub ('', random.choice(body), target) + me(msg) From f7a0bf03527d8585b01ca12d99682eb2c13f8596 Mon Sep 17 00:00:00 2001 From: neersighted Date: Tue, 6 Mar 2012 10:17:49 -0800 Subject: [PATCH 027/205] Fixed bug in .kill --- plugins/violence.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/violence.py b/plugins/violence.py index 3701a28..41c6fee 100644 --- a/plugins/violence.py +++ b/plugins/violence.py @@ -159,7 +159,7 @@ kills = ["rips off 's and leaves them to die.", "slices 's off with a Katana", "throws to Cthulu!", "feeds to an owlbear.", - "turns into a snail, and then salts them.", + "turns into a snail, and salts them.", "snacks on 's .", "puts into a sack, throws the sack in the river, and hurls the river into space.", "goes bowling with 's head.", @@ -220,10 +220,10 @@ def kill(inp, me=None, nick=None, input=None, notice=None): return if inp == input.conn.nick.lower() or inp == "itself": - target = inp - else: target = nick + else: + target = inp msg = random.choice(kills) - msg = re.sub ('', target, target) - msg = re.sub ('', random.choice(body), target) + msg = re.sub ('', target, msg) + msg = re.sub ('', random.choice(body), msg) me(msg) From 6f02860279b818160fc823356af13c1a79fe3d8b Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 7 Mar 2012 07:35:03 +1300 Subject: [PATCH 028/205] Replaced kills = [] with my tweaked version (since neer borked my original commit of this --- plugins/violence.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/violence.py b/plugins/violence.py index 41c6fee..888a5cd 100644 --- a/plugins/violence.py +++ b/plugins/violence.py @@ -143,6 +143,7 @@ larts = ["swaps 's shampoo with glue.", "assigns all of the permissions tickets on the BeastNode support system to .", "hands a poison ivy joint."] + kills = ["rips off 's and leaves them to die.", "grabs 's head and rips it clean off their body.", "grabs a machine gun and riddles 's body with bullets.", @@ -150,7 +151,7 @@ kills = ["rips off 's and leaves them to die.", "gags and ties then throws them off a bridge.", "crushes with a huge spiked boulder.", "glares at until they die of boredom.", - "stuffs a few TNT blocks under 's bed, and sets them off.", + "stuffs a few TNT blocks under 's bed and sets them off.", "shivs in the .", "rams a rocket launcher up 's ass and lets off a few rounds.", "crushes 's skull in with a spiked mace.", @@ -159,7 +160,7 @@ kills = ["rips off 's and leaves them to die.", "slices 's off with a Katana", "throws to Cthulu!", "feeds to an owlbear.", - "turns into a snail, and salts them.", + "turns into a snail and salts them.", "snacks on 's .", "puts into a sack, throws the sack in the river, and hurls the river into space.", "goes bowling with 's head.", @@ -167,6 +168,7 @@ kills = ["rips off 's and leaves them to die.", "sends to /dev/null!", "feeds coke and mentos till they pop!"] + body = ['head', 'arms', 'leg', From dd8531104487c1a7464c81b6a72c754e3556e210 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 7 Mar 2012 07:46:28 +1300 Subject: [PATCH 029/205] renamed gtime.py before working on it --- plugins/{gtime.py => time.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename plugins/{gtime.py => time.py} (100%) diff --git a/plugins/gtime.py b/plugins/time.py similarity index 100% rename from plugins/gtime.py rename to plugins/time.py From 788e62034c964f1538db39883fc58e7df95087e1 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 7 Mar 2012 09:16:22 +1300 Subject: [PATCH 030/205] Added timezone support to plugins/time.py. This commit fixes #2 --- plugins/time.py | 235 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 224 insertions(+), 11 deletions(-) diff --git a/plugins/time.py b/plugins/time.py index bfa9336..3e64edf 100755 --- a/plugins/time.py +++ b/plugins/time.py @@ -1,11 +1,219 @@ -import re +# Plugin by Lukeroge with some code from Phenny +# + +import re, time, locale, datetime from util import hook, http from BeautifulSoup import BeautifulSoup +TimeZones = {'KST': 9, 'CADT': 10.5, 'EETDST': 3, 'MESZ': 2, 'WADT': 9, + 'EET': 2, 'MST': -7, 'WAST': 8, 'IST': 5.5, 'B': 2, + 'MSK': 3, 'X': -11, 'MSD': 4, 'CETDST': 2, 'AST': -4, + 'HKT': 8, 'JST': 9, 'CAST': 9.5, 'CET': 1, 'CEST': 2, + 'EEST': 3, 'EAST': 10, 'METDST': 2, 'MDT': -6, 'A': 1, + 'UTC': 0, 'ADT': -3, 'EST': -5, 'E': 5, 'D': 4, 'G': 7, + 'F': 6, 'I': 9, 'H': 8, 'K': 10, 'PDT': -7, 'M': 12, + 'L': 11, 'O': -2, 'MEST': 2, 'Q': -4, 'P': -3, 'S': -6, + 'R': -5, 'U': -8, 'T': -7, 'W': -10, 'WET': 0, 'Y': -12, + 'CST': -6, 'EADT': 11, 'Z': 0, 'GMT': 0, 'WETDST': 1, + 'C': 3, 'WEST': 1, 'CDT': -5, 'MET': 1, 'N': -1, 'V': -9, + 'EDT': -4, 'UT': 0, 'PST': -8, 'MEZ': 1, 'BST': 1, + 'ACS': 9.5, 'ATL': -4, 'ALA': -9, 'HAW': -10, 'AKDT': -8, + 'AKST': -9, + 'BDST': 2} + +TZ1 = { + 'NDT': -2.5, + 'BRST': -2, + 'ADT': -3, + 'EDT': -4, + 'CDT': -5, + 'MDT': -6, + 'PDT': -7, + 'YDT': -8, + 'HDT': -9, + 'BST': 1, + 'MEST': 2, + 'SST': 2, + 'FST': 2, + 'CEST': 2, + 'EEST': 3, + 'WADT': 8, + 'KDT': 10, + 'EADT': 13, + 'NZD': 13, + 'NZDT': 13, + 'GMT': 0, + 'UT': 0, + 'UTC': 0, + 'WET': 0, + 'WAT': -1, + 'AT': -2, + 'FNT': -2, + 'BRT': -3, + 'MNT': -4, + 'EWT': -4, + 'AST': -4, + 'EST': -5, + 'ACT': -5, + 'CST': -6, + 'MST': -7, + 'PST': -8, + 'YST': -9, + 'HST': -10, + 'CAT': -10, + 'AHST': -10, + 'NT': -11, + 'IDLW': -12, + 'CET': 1, + 'MEZ': 1, + 'ECT': 1, + 'MET': 1, + 'MEWT': 1, + 'SWT': 1, + 'SET': 1, + 'FWT': 1, + 'EET': 2, + 'UKR': 2, + 'BT': 3, + 'ZP4': 4, + 'ZP5': 5, + 'ZP6': 6, + 'WST': 8, + 'HKT': 8, + 'CCT': 8, + 'JST': 9, + 'KST': 9, + 'EAST': 10, + 'GST': 10, + 'NZT': 12, + 'NZST': 12, + 'IDLE': 12 +} + +TZ2 = { + 'ACDT': 10.5, + 'ACST': 9.5, + 'ADT': 3, + 'AEDT': 11, # hmm + 'AEST': 10, # hmm + 'AHDT': 9, + 'AHST': 10, + 'AST': 4, + 'AT': 2, + 'AWDT': -9, + 'AWST': -8, + 'BAT': -3, + 'BDST': -2, + 'BET': 11, + 'BST': -1, + 'BT': -3, + 'BZT2': 3, + 'CADT': -10.5, + 'CAST': -9.5, + 'CAT': 10, + 'CCT': -8, + # 'CDT': 5, + 'CED': -2, + 'CET': -1, + 'CST': 6, + 'EAST': -10, + # 'EDT': 4, + 'EED': -3, + 'EET': -2, + 'EEST': -3, + 'EST': 5, + 'FST': -2, + 'FWT': -1, + 'GMT': 0, + 'GST': -10, + 'HDT': 9, + 'HST': 10, + 'IDLE': -12, + 'IDLW': 12, + # 'IST': -5.5, + 'IT': -3.5, + 'JST': -9, + 'JT': -7, + 'KST': -9, + 'MDT': 6, + 'MED': -2, + 'MET': -1, + 'MEST': -2, + 'MEWT': -1, + 'MST': 7, + 'MT': -8, + 'NDT': 2.5, + 'NFT': 3.5, + 'NT': 11, + 'NST': -6.5, + 'NZ': -11, + 'NZST': -12, + 'NZDT': -13, + 'NZT': -12, + 'PDT': 7, + 'PST': 8, + 'ROK': -9, + 'SAD': -10, + 'SAST': -9, + 'SAT': -9, + 'SDT': -10, + 'SST': -2, + 'SWT': -1, + 'USZ3': -4, + 'USZ4': -5, + 'USZ5': -6, + 'USZ6': -7, + 'UT': 0, + 'UTC': 0, + 'UZ10': -11, + 'WAT': 1, + 'WET': 0, + 'WST': -8, + 'YDT': 8, + 'YST': 9, + 'ZP4': -4, + 'ZP5': -5, + 'ZP6': -6 +} + +TZ3 = { + 'AEST': 10, + 'AEDT': 11 +} + +# TimeZones.update(TZ2) # do these have to be negated? +TimeZones.update(TZ1) +TimeZones.update(TZ3) + +r_local = re.compile(r'\([a-z]+_[A-Z]+\)') + +def get_time(tz): + TZ = tz.upper() + + if (TZ == 'UTC') or (TZ == 'Z'): + msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02 GMT", time.gmtime()) + return msg + elif r_local.match(tz): # thanks to Mark Shoulsdon (clsn) + locale.setlocale(locale.LC_TIME, (tz[1:-1], 'UTF-8')) + msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" + str(TZ), time.gmtime()) + return msg + elif TimeZones.has_key(TZ): + offset = TimeZones[TZ] * 3600 + timenow = time.gmtime(time.time() + offset) + msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" + str(TZ), timenow) + return msg + #elif tz and tz[0] in ('+', '-') and 4 <= len(tz) <= 6: + # timenow = time.gmtime(time.time() + (int(tz[:3]) * 3600)) + # msg = time.strftime("4\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" + str(tz), timenow) + # return msg + else: + timenow = time.gmtime(time.time() + (int(tz) * 3600)) + msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02 GMT" + str(tz), timenow) + return msg @hook.command("time") -def clock(inp, say=None): +def timecommand(inp, say=None): ".time -- Gets the time in " white_re = re.compile(r'\s+') @@ -17,17 +225,22 @@ def clock(inp, say=None): response = soup.find('td', {'style' : 'font-size:medium'}) - if response is None: - return "Could not get the time for " + inp + "!" + if response: + output = response.renderContents() - output = response.renderContents() + output = ' '.join(output.splitlines()) + output = output.replace("\xa0", ",") - output = ' '.join(output.splitlines()) - output = output.replace("\xa0", ",") + output = white_re.sub(' ', output.strip()) + output = tags_re.sub('\x02', output.strip()) - output = white_re.sub(' ', output.strip()) - output = tags_re.sub('\x02', output.strip()) + output = output.decode('utf-8', 'ignore') + return output + else: + try: + return get_time(inp) + except ValueError: + return "Could not get time for " + inp + "!" + - output = output.decode('utf-8', 'ignore') - return output From 37a3cc20301a83bc55c36ee52f1666893184eb0f Mon Sep 17 00:00:00 2001 From: lukeroge Date: Wed, 7 Mar 2012 12:39:55 +1300 Subject: [PATCH 031/205] Update plugins/time.py --- plugins/time.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/time.py b/plugins/time.py index 3e64edf..d64d11a 100755 --- a/plugins/time.py +++ b/plugins/time.py @@ -240,7 +240,7 @@ def timecommand(inp, say=None): try: return get_time(inp) except ValueError: - return "Could not get time for " + inp + "!" + return "Could not get the time for " + inp + "!" From 800dacd274da24b9d2cd6775f4d29ac63259de7d Mon Sep 17 00:00:00 2001 From: lukeroge Date: Wed, 7 Mar 2012 14:11:15 +1300 Subject: [PATCH 032/205] Started tweaking quote.py --- plugins/quote.py | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/plugins/quote.py b/plugins/quote.py index cb20f2b..dd1680b 100755 --- a/plugins/quote.py +++ b/plugins/quote.py @@ -12,15 +12,9 @@ def format_quote(q, num, n_quotes): def create_table_if_not_exists(db): "Creates an empty quote table if one does not already exist" - db.execute('''CREATE TABLE IF NOT EXISTS quote ( - chan, - nick, - add_nick, - msg, - time real, - deleted default 0, - PRIMARY KEY (chan, nick, msg) - )''') + db.execute("create table if not exists quote" + "(chan, nick, add_nick, msg, time real, deleted default 0, " + "primary key (chan, nick, msg))") db.commit() def add_quote(db, chan, nick, add_nick, msg): @@ -37,15 +31,12 @@ def add_quote(db, chan, nick, add_nick, msg): def del_quote(db, chan, nick, add_nick, msg): "Deletes a quote from a nick" - db.execute('''UPDATE quote - SET deleted = 1 - WHERE chan=? - AND lower(nick)=lower(?) - AND msg=msg''') + db.execute('''UPDATE quote SET deleted = 1 WHERE + chan=? AND lower(nick)=lower(?) AND msg=msg''') db.commit() def get_quote_num(num, count, name): - "Returns the quote number desired from the database" + "Returns the quote number to fetch from the DB" if num: # Make sure num is a number if it isn't false num = int(num) if count == 0: # If there are no quotes in the database, raise an Exception. @@ -62,9 +53,7 @@ def get_quote_num(num, count, name): def get_quote_by_nick(db, nick, num=False): "Returns a formatted quote from a nick, random or selected by number" - count = db.execute('''SELECT COUNT(*) - FROM quote - WHERE deleted != 1 + count = db.execute('''SELECT COUNT(*) FROM quote WHERE deleted != 1 AND lower(nick) = lower(?)''', [nick]).fetchall()[0][0] try: From ac03ceb3668edfe0926a40f9d2fc88470a439b1d Mon Sep 17 00:00:00 2001 From: neersighted Date: Tue, 6 Mar 2012 23:06:41 -0800 Subject: [PATCH 033/205] fixed bug in shorten.py --- plugins/shorten.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/shorten.py b/plugins/shorten.py index 270194b..df977b1 100755 --- a/plugins/shorten.py +++ b/plugins/shorten.py @@ -12,28 +12,30 @@ class ShortenError(Exception): def __str__(self): return repr(self.value) - + def bitly(url, user, apikey): try: + if url[:7] != "http://": + url = "http://" + url params = urlencode({'longUrl': url, 'login': user, 'apiKey': apikey, 'format': 'json'}) j = http.get_json("http://api.bit.ly/v3/shorten?%s" % params) if j['status_code'] == 200: return j['data']['url'] - raise ShortenError('%s'%j['status_txt']) + raise ShortenError('%s' % j['status_txt']) except (HTTPError, ShortenError): return "Could not shorten %s!" % url @hook.command -def shorten(inp, bot=None): +def shorten(inp, bot = None): ".shorten - Makes an j.mp/bit.ly shortlink to the url provided." - api_user = bot.config.get("api_keys", {}).get("bitly_user", None) + api_user = bot.config.get("api_keys", {}).get("bitly_user", None) api_key = bot.config.get("api_keys", {}).get("bitly_api", None) if api_key is None: return "error: no api key set" return bitly(inp, api_user, api_key) @hook.command -def expand(inp, bot=None): +def expand(inp, bot = None): ".expand - Gets the original URL from a shortened link." try: url = http.get_url(inp) From 11c500515853af25725f3a2cfab9e5da3498cd75 Mon Sep 17 00:00:00 2001 From: neersighted Date: Tue, 6 Mar 2012 23:10:40 -0800 Subject: [PATCH 034/205] fixed bug with https --- plugins/shorten.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/shorten.py b/plugins/shorten.py index df977b1..9ba15bd 100755 --- a/plugins/shorten.py +++ b/plugins/shorten.py @@ -16,6 +16,8 @@ class ShortenError(Exception): def bitly(url, user, apikey): try: if url[:7] != "http://": + if url[:8] == "https://": + url = url url = "http://" + url params = urlencode({'longUrl': url, 'login': user, 'apiKey': apikey, 'format': 'json'}) j = http.get_json("http://api.bit.ly/v3/shorten?%s" % params) From 6749bf8340f3a97b5f420c864f29fdd4f3b4e368 Mon Sep 17 00:00:00 2001 From: neersighted Date: Wed, 7 Mar 2012 09:37:37 -0800 Subject: [PATCH 035/205] Fixed (I hope) the same bug with https:// --- plugins/shorten.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/shorten.py b/plugins/shorten.py index 9ba15bd..8a028a4 100755 --- a/plugins/shorten.py +++ b/plugins/shorten.py @@ -15,9 +15,9 @@ class ShortenError(Exception): def bitly(url, user, apikey): try: - if url[:7] != "http://": - if url[:8] == "https://": - url = url + if url[:8] == "https://": + pass + elif url[:7] != "http://": url = "http://" + url params = urlencode({'longUrl': url, 'login': user, 'apiKey': apikey, 'format': 'json'}) j = http.get_json("http://api.bit.ly/v3/shorten?%s" % params) From 109dcb20641345477c1a4618d6f104b8d51b8d5f Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Thu, 8 Mar 2012 16:21:24 +1300 Subject: [PATCH 036/205] added git-flow to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index fe205b0..7d9d181 100755 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ persist config +gitflow *.db *.log .*.swp From f61cc28869d73624fa883a65540cea6210d59867 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sat, 10 Mar 2012 19:24:10 -0800 Subject: [PATCH 037/205] Fixed timing bug, stopping .restart --- cloudbot | 1 + 1 file changed, 1 insertion(+) diff --git a/cloudbot b/cloudbot index 850b271..3d7ac49 100755 --- a/cloudbot +++ b/cloudbot @@ -96,6 +96,7 @@ processargs() { if running; then echo "Restarting CloudBot... ($backend)" stop + sleep 3 start else echo "Cannot restart! Bot is not already running!" From 54c8e37cce00efdacd7518f6a7d3204367e118bb Mon Sep 17 00:00:00 2001 From: neersighted Date: Sun, 11 Mar 2012 11:45:49 -0800 Subject: [PATCH 038/205] Updated plugins/time.py --- plugins/time.py | 341 ++++++++++++++++++++++++------------------------ 1 file changed, 171 insertions(+), 170 deletions(-) diff --git a/plugins/time.py b/plugins/time.py index d64d11a..8598c63 100755 --- a/plugins/time.py +++ b/plugins/time.py @@ -1,184 +1,187 @@ # Plugin by Lukeroge with some code from Phenny # -import re, time, locale, datetime - -from util import hook, http +from util import hook +from util import http +import re +import time +import locale +import datetime from BeautifulSoup import BeautifulSoup -TimeZones = {'KST': 9, 'CADT': 10.5, 'EETDST': 3, 'MESZ': 2, 'WADT': 9, - 'EET': 2, 'MST': -7, 'WAST': 8, 'IST': 5.5, 'B': 2, - 'MSK': 3, 'X': -11, 'MSD': 4, 'CETDST': 2, 'AST': -4, - 'HKT': 8, 'JST': 9, 'CAST': 9.5, 'CET': 1, 'CEST': 2, - 'EEST': 3, 'EAST': 10, 'METDST': 2, 'MDT': -6, 'A': 1, - 'UTC': 0, 'ADT': -3, 'EST': -5, 'E': 5, 'D': 4, 'G': 7, - 'F': 6, 'I': 9, 'H': 8, 'K': 10, 'PDT': -7, 'M': 12, - 'L': 11, 'O': -2, 'MEST': 2, 'Q': -4, 'P': -3, 'S': -6, - 'R': -5, 'U': -8, 'T': -7, 'W': -10, 'WET': 0, 'Y': -12, - 'CST': -6, 'EADT': 11, 'Z': 0, 'GMT': 0, 'WETDST': 1, - 'C': 3, 'WEST': 1, 'CDT': -5, 'MET': 1, 'N': -1, 'V': -9, - 'EDT': -4, 'UT': 0, 'PST': -8, 'MEZ': 1, 'BST': 1, - 'ACS': 9.5, 'ATL': -4, 'ALA': -9, 'HAW': -10, 'AKDT': -8, - 'AKST': -9, +TimeZones = {'KST': 9, 'CADT': 10.5, 'EETDST': 3, 'MESZ': 2, 'WADT': 9, + 'EET': 2, 'MST':-7, 'WAST': 8, 'IST': 5.5, 'B': 2, + 'MSK': 3, 'X':-11, 'MSD': 4, 'CETDST': 2, 'AST':-4, + 'HKT': 8, 'JST': 9, 'CAST': 9.5, 'CET': 1, 'CEST': 2, + 'EEST': 3, 'EAST': 10, 'METDST': 2, 'MDT':-6, 'A': 1, + 'UTC': 0, 'ADT':-3, 'EST':-5, 'E': 5, 'D': 4, 'G': 7, + 'F': 6, 'I': 9, 'H': 8, 'K': 10, 'PDT':-7, 'M': 12, + 'L': 11, 'O':-2, 'MEST': 2, 'Q':-4, 'P':-3, 'S':-6, + 'R':-5, 'U':-8, 'T':-7, 'W':-10, 'WET': 0, 'Y':-12, + 'CST':-6, 'EADT': 11, 'Z': 0, 'GMT': 0, 'WETDST': 1, + 'C': 3, 'WEST': 1, 'CDT':-5, 'MET': 1, 'N':-1, 'V':-9, + 'EDT':-4, 'UT': 0, 'PST':-8, 'MEZ': 1, 'BST': 1, + 'ACS': 9.5, 'ATL':-4, 'ALA':-9, 'HAW':-10, 'AKDT':-8, + 'AKST':-9, 'BDST': 2} TZ1 = { - 'NDT': -2.5, - 'BRST': -2, - 'ADT': -3, - 'EDT': -4, - 'CDT': -5, - 'MDT': -6, - 'PDT': -7, - 'YDT': -8, - 'HDT': -9, - 'BST': 1, - 'MEST': 2, - 'SST': 2, - 'FST': 2, - 'CEST': 2, - 'EEST': 3, - 'WADT': 8, - 'KDT': 10, - 'EADT': 13, - 'NZD': 13, - 'NZDT': 13, - 'GMT': 0, - 'UT': 0, - 'UTC': 0, - 'WET': 0, - 'WAT': -1, - 'AT': -2, - 'FNT': -2, - 'BRT': -3, - 'MNT': -4, - 'EWT': -4, - 'AST': -4, - 'EST': -5, - 'ACT': -5, - 'CST': -6, - 'MST': -7, - 'PST': -8, - 'YST': -9, - 'HST': -10, - 'CAT': -10, - 'AHST': -10, - 'NT': -11, - 'IDLW': -12, - 'CET': 1, - 'MEZ': 1, - 'ECT': 1, - 'MET': 1, - 'MEWT': 1, - 'SWT': 1, - 'SET': 1, - 'FWT': 1, - 'EET': 2, - 'UKR': 2, - 'BT': 3, - 'ZP4': 4, - 'ZP5': 5, - 'ZP6': 6, - 'WST': 8, - 'HKT': 8, - 'CCT': 8, - 'JST': 9, - 'KST': 9, - 'EAST': 10, - 'GST': 10, - 'NZT': 12, - 'NZST': 12, + 'NDT':-2.5, + 'BRST':-2, + 'ADT':-3, + 'EDT':-4, + 'CDT':-5, + 'MDT':-6, + 'PDT':-7, + 'YDT':-8, + 'HDT':-9, + 'BST': 1, + 'MEST': 2, + 'SST': 2, + 'FST': 2, + 'CEST': 2, + 'EEST': 3, + 'WADT': 8, + 'KDT': 10, + 'EADT': 13, + 'NZD': 13, + 'NZDT': 13, + 'GMT': 0, + 'UT': 0, + 'UTC': 0, + 'WET': 0, + 'WAT':-1, + 'AT':-2, + 'FNT':-2, + 'BRT':-3, + 'MNT':-4, + 'EWT':-4, + 'AST':-4, + 'EST':-5, + 'ACT':-5, + 'CST':-6, + 'MST':-7, + 'PST':-8, + 'YST':-9, + 'HST':-10, + 'CAT':-10, + 'AHST':-10, + 'NT':-11, + 'IDLW':-12, + 'CET': 1, + 'MEZ': 1, + 'ECT': 1, + 'MET': 1, + 'MEWT': 1, + 'SWT': 1, + 'SET': 1, + 'FWT': 1, + 'EET': 2, + 'UKR': 2, + 'BT': 3, + 'ZP4': 4, + 'ZP5': 5, + 'ZP6': 6, + 'WST': 8, + 'HKT': 8, + 'CCT': 8, + 'JST': 9, + 'KST': 9, + 'EAST': 10, + 'GST': 10, + 'NZT': 12, + 'NZST': 12, 'IDLE': 12 } TZ2 = { - 'ACDT': 10.5, - 'ACST': 9.5, - 'ADT': 3, + 'ACDT': 10.5, + 'ACST': 9.5, + 'ADT': 3, 'AEDT': 11, # hmm 'AEST': 10, # hmm - 'AHDT': 9, - 'AHST': 10, - 'AST': 4, - 'AT': 2, - 'AWDT': -9, - 'AWST': -8, - 'BAT': -3, - 'BDST': -2, - 'BET': 11, - 'BST': -1, - 'BT': -3, - 'BZT2': 3, - 'CADT': -10.5, - 'CAST': -9.5, - 'CAT': 10, - 'CCT': -8, + 'AHDT': 9, + 'AHST': 10, + 'AST': 4, + 'AT': 2, + 'AWDT':-9, + 'AWST':-8, + 'BAT':-3, + 'BDST':-2, + 'BET': 11, + 'BST':-1, + 'BT':-3, + 'BZT2': 3, + 'CADT':-10.5, + 'CAST':-9.5, + 'CAT': 10, + 'CCT':-8, # 'CDT': 5, - 'CED': -2, - 'CET': -1, - 'CST': 6, - 'EAST': -10, + 'CED':-2, + 'CET':-1, + 'CST': 6, + 'EAST':-10, # 'EDT': 4, - 'EED': -3, - 'EET': -2, - 'EEST': -3, - 'EST': 5, - 'FST': -2, - 'FWT': -1, - 'GMT': 0, - 'GST': -10, - 'HDT': 9, - 'HST': 10, - 'IDLE': -12, - 'IDLW': 12, + 'EED':-3, + 'EET':-2, + 'EEST':-3, + 'EST': 5, + 'FST':-2, + 'FWT':-1, + 'GMT': 0, + 'GST':-10, + 'HDT': 9, + 'HST': 10, + 'IDLE':-12, + 'IDLW': 12, # 'IST': -5.5, - 'IT': -3.5, - 'JST': -9, - 'JT': -7, - 'KST': -9, - 'MDT': 6, - 'MED': -2, - 'MET': -1, - 'MEST': -2, - 'MEWT': -1, - 'MST': 7, - 'MT': -8, - 'NDT': 2.5, - 'NFT': 3.5, - 'NT': 11, - 'NST': -6.5, - 'NZ': -11, - 'NZST': -12, - 'NZDT': -13, - 'NZT': -12, - 'PDT': 7, - 'PST': 8, - 'ROK': -9, - 'SAD': -10, - 'SAST': -9, - 'SAT': -9, - 'SDT': -10, - 'SST': -2, - 'SWT': -1, - 'USZ3': -4, - 'USZ4': -5, - 'USZ5': -6, - 'USZ6': -7, - 'UT': 0, - 'UTC': 0, - 'UZ10': -11, - 'WAT': 1, - 'WET': 0, - 'WST': -8, - 'YDT': 8, - 'YST': 9, - 'ZP4': -4, - 'ZP5': -5, - 'ZP6': -6 + 'IT':-3.5, + 'JST':-9, + 'JT':-7, + 'KST':-9, + 'MDT': 6, + 'MED':-2, + 'MET':-1, + 'MEST':-2, + 'MEWT':-1, + 'MST': 7, + 'MT':-8, + 'NDT': 2.5, + 'NFT': 3.5, + 'NT': 11, + 'NST':-6.5, + 'NZ':-11, + 'NZST':-12, + 'NZDT':-13, + 'NZT':-12, + 'PDT': 7, + 'PST': 8, + 'ROK':-9, + 'SAD':-10, + 'SAST':-9, + 'SAT':-9, + 'SDT':-10, + 'SST':-2, + 'SWT':-1, + 'USZ3':-4, + 'USZ4':-5, + 'USZ5':-6, + 'USZ6':-7, + 'UT': 0, + 'UTC': 0, + 'UZ10':-11, + 'WAT': 1, + 'WET': 0, + 'WST':-8, + 'YDT': 8, + 'YST': 9, + 'ZP4':-4, + 'ZP5':-5, + 'ZP6':-6 } TZ3 = { - 'AEST': 10, + 'AEST': 10, 'AEDT': 11 } @@ -191,14 +194,14 @@ r_local = re.compile(r'\([a-z]+_[A-Z]+\)') def get_time(tz): TZ = tz.upper() - if (TZ == 'UTC') or (TZ == 'Z'): + if (TZ == 'UTC') or (TZ == 'Z'): msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02 GMT", time.gmtime()) return msg elif r_local.match(tz): # thanks to Mark Shoulsdon (clsn) locale.setlocale(locale.LC_TIME, (tz[1:-1], 'UTF-8')) msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" + str(TZ), time.gmtime()) return msg - elif TimeZones.has_key(TZ): + elif TimeZones.has_key(TZ): offset = TimeZones[TZ] * 3600 timenow = time.gmtime(time.time() + offset) msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" + str(TZ), timenow) @@ -207,19 +210,19 @@ def get_time(tz): # timenow = time.gmtime(time.time() + (int(tz[:3]) * 3600)) # msg = time.strftime("4\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" + str(tz), timenow) # return msg - else: + else: timenow = time.gmtime(time.time() + (int(tz) * 3600)) msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02 GMT" + str(tz), timenow) return msg @hook.command("time") -def timecommand(inp, say=None): +def timecommand(inp, say = None): ".time -- Gets the time in " white_re = re.compile(r'\s+') tags_re = re.compile(r'<[^<]*?>') - page = http.get('http://www.google.com/search', q="time in " + inp) + page = http.get('http://www.google.com/search', q = "time in " + inp) soup = BeautifulSoup(page) @@ -238,9 +241,7 @@ def timecommand(inp, say=None): return output else: try: - return get_time(inp) + output = get_time(inp) + return output except ValueError: return "Could not get the time for " + inp + "!" - - - From 36fd6af7eccdc7a0775fead8124f0ac8be7d5fc8 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Mon, 12 Mar 2012 11:47:22 +1300 Subject: [PATCH 039/205] Update plugins/todo.py --- plugins/todo.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/todo.py b/plugins/todo.py index 6a2d170..9239823 100755 --- a/plugins/todo.py +++ b/plugins/todo.py @@ -90,7 +90,7 @@ def db_search(db, nick, query): @hook.command def todo(inp, nick='', chan='', db=None, notice=None, bot=None): - ".todo (add|del|list|search) [@user] args -- Manipulates your list of todos." + ".todo (add|del|list|search) args -- Manipulates your list of todos." db_init(db) @@ -99,9 +99,11 @@ def todo(inp, nick='', chan='', db=None, notice=None, bot=None): args = parts[1:] - if len(args) and args[0].startswith("@"): - nick = args[0][1:] - args = args[1:] + # code to allow users to access each others factoids and a copy of help + # ".todo (add|del|list|search) [@user] args -- Manipulates your list of todos." + #if len(args) and args[0].startswith("@"): + # nick = args[0][1:] + # args = args[1:] if cmd == 'add': if not len(args): From fbd36b47bea6a38bf462160d39a77f6d6e57b800 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sun, 11 Mar 2012 22:24:52 -0800 Subject: [PATCH 040/205] Added admin command, cleaned up file --- plugins/admin.py | 54 +++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index e91afd6..fabdc9a 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -8,10 +8,22 @@ import sys import subprocess import time -@hook.command("quit", autohelp=False) -@hook.command("exit", autohelp=False) -@hook.command(autohelp=False) -def stop(inp, input=None, db=None, notice=None): + +@hook.command("owners", autohelp = False) +@hook.command(autohelp = False) +def admins(inp, bot = None): + admins = str(bot.config["admins"]) + admins = admins.replace("u'", "") + admins = admins.replace("'", "") + admins = admins.replace("[", "") + admins = admins.replace("]", "") + return admins + + +@hook.command("quit", autohelp = False) +@hook.command("exit", autohelp = False) +@hook.command(autohelp = False) +def stop(inp, input = None, db = None, notice = None): ".stop [reason] -- Kills the bot, with [reason] as its quit message." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") @@ -21,12 +33,12 @@ def stop(inp, input=None, db=None, notice=None): else: input.conn.send("QUIT :Killed by " + input.nick + " (no reason)") time.sleep(5) - subprocess.call("./cloudbot stop", shell=True) + subprocess.call("./cloudbot stop", shell = True) -@hook.command("reboot", autohelp=False) -@hook.command(autohelp=False) -def restart(inp, input=None, db=None, notice=None): +@hook.command("reboot", autohelp = False) +@hook.command(autohelp = False) +def restart(inp, input = None, db = None, notice = None): ".restart [reason] -- Restarts the bot, with [reason] as its quit message." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") @@ -38,19 +50,19 @@ def restart(inp, input=None, db=None, notice=None): time.sleep(5) os.execl("./cloudbot", "restart") -@hook.command("clearlogs", autohelp=False) -@hook.command(autohelp=False) -def clear(inp, input=None, db=None, notice=None): +@hook.command("clearlogs", autohelp = False) +@hook.command(autohelp = False) +def clear(inp, input = None, db = None, notice = None): ".clear -- Clears the bot's log(s)." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") return time.sleep(5) - subprocess.call("./cloudbot clear", shell=True) + subprocess.call("./cloudbot clear", shell = True) @hook.command -def join(inp, input=None, db=None, notice=None): +def join(inp, input = None, db = None, notice = None): ".join -- Joins ." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") @@ -60,7 +72,7 @@ def join(inp, input=None, db=None, notice=None): @hook.command -def cycle(inp, input=None, db=None, notice=None): +def cycle(inp, input = None, db = None, notice = None): ".cycle -- Cycles ." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") @@ -71,7 +83,7 @@ def cycle(inp, input=None, db=None, notice=None): @hook.command -def part(inp, input=None, notice=None): +def part(inp, input = None, notice = None): ".part -- Parts from ." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") @@ -81,7 +93,7 @@ def part(inp, input=None, notice=None): @hook.command -def nick(inp, input=None, notice=None): +def nick(inp, input = None, notice = None): ".nick -- Changes the bots nickname to ." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") @@ -91,7 +103,7 @@ def nick(inp, input=None, notice=None): @hook.command -def raw(inp, input=None, notice=None): +def raw(inp, input = None, notice = None): ".raw -- Sends a RAW IRC command." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") @@ -101,7 +113,7 @@ def raw(inp, input=None, notice=None): @hook.command -def kick(inp, input=None, notice=None): +def kick(inp, input = None, notice = None): ".kick [channel] [reason] -- kicks a user." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") @@ -133,7 +145,7 @@ def kick(inp, input=None, notice=None): @hook.command -def say(inp, input=None, notice=None): +def say(inp, input = None, notice = None): ".say [channel] -- Makes the bot say in [channel]. "\ "If [channel] is blank the bot will say the in "\ "the channel the command was used in." @@ -158,7 +170,7 @@ def say(inp, input=None, notice=None): @hook.command("me") @hook.command -def act(inp, input=None, notice=None): +def act(inp, input = None, notice = None): ".act [channel] -- Makes the bot act out in [channel] "\ "If [channel] is blank the bot will act the in "\ "the channel the command was used in." @@ -182,7 +194,7 @@ def act(inp, input=None, notice=None): @hook.command -def topic(inp, input=None, notice=None): +def topic(inp, input = None, notice = None): ".topic [channel] -- Change the topic of a channel." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") From f521c61b9bfb8415709b5b8207021a173c555f08 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sun, 11 Mar 2012 22:33:55 -0800 Subject: [PATCH 041/205] oops, messed up the pep8. fixed! --- plugins/admin.py | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index fabdc9a..e3e5618 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -9,9 +9,9 @@ import subprocess import time -@hook.command("owners", autohelp = False) -@hook.command(autohelp = False) -def admins(inp, bot = None): +@hook.command("owners", autohelp=False) +@hook.command(autohelp=False) +def admins(inp, bot=None): admins = str(bot.config["admins"]) admins = admins.replace("u'", "") admins = admins.replace("'", "") @@ -20,10 +20,10 @@ def admins(inp, bot = None): return admins -@hook.command("quit", autohelp = False) -@hook.command("exit", autohelp = False) -@hook.command(autohelp = False) -def stop(inp, input = None, db = None, notice = None): +@hook.command("quit", autohelp=False) +@hook.command("exit", autohelp=False) +@hook.command(autohelp=False) +def stop(inp, input=None, db=None, notice=None): ".stop [reason] -- Kills the bot, with [reason] as its quit message." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") @@ -33,12 +33,12 @@ def stop(inp, input = None, db = None, notice = None): else: input.conn.send("QUIT :Killed by " + input.nick + " (no reason)") time.sleep(5) - subprocess.call("./cloudbot stop", shell = True) + subprocess.call("./cloudbot stop", shell=True) -@hook.command("reboot", autohelp = False) -@hook.command(autohelp = False) -def restart(inp, input = None, db = None, notice = None): +@hook.command("reboot", autohelp=False) +@hook.command(autohelp=False) +def restart(inp, input=None, db=None, notice=None): ".restart [reason] -- Restarts the bot, with [reason] as its quit message." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") @@ -50,19 +50,19 @@ def restart(inp, input = None, db = None, notice = None): time.sleep(5) os.execl("./cloudbot", "restart") -@hook.command("clearlogs", autohelp = False) -@hook.command(autohelp = False) -def clear(inp, input = None, db = None, notice = None): +@hook.command("clearlogs", autohelp=False) +@hook.command(autohelp=False) +def clear(inp, input=None, db=None, notice=None): ".clear -- Clears the bot's log(s)." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") return time.sleep(5) - subprocess.call("./cloudbot clear", shell = True) + subprocess.call("./cloudbot clear", shell=True) @hook.command -def join(inp, input = None, db = None, notice = None): +def join(inp, input=None, db=None, notice=None): ".join -- Joins ." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") @@ -72,7 +72,7 @@ def join(inp, input = None, db = None, notice = None): @hook.command -def cycle(inp, input = None, db = None, notice = None): +def cycle(inp, input=None, db=None, notice=None): ".cycle -- Cycles ." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") @@ -83,7 +83,7 @@ def cycle(inp, input = None, db = None, notice = None): @hook.command -def part(inp, input = None, notice = None): +def part(inp, input=None, notice=None): ".part -- Parts from ." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") @@ -93,7 +93,7 @@ def part(inp, input = None, notice = None): @hook.command -def nick(inp, input = None, notice = None): +def nick(inp, input=None, notice=None): ".nick -- Changes the bots nickname to ." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") @@ -103,7 +103,7 @@ def nick(inp, input = None, notice = None): @hook.command -def raw(inp, input = None, notice = None): +def raw(inp, input=None, notice=None): ".raw -- Sends a RAW IRC command." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") @@ -113,7 +113,7 @@ def raw(inp, input = None, notice = None): @hook.command -def kick(inp, input = None, notice = None): +def kick(inp, input=None, notice=None): ".kick [channel] [reason] -- kicks a user." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") @@ -145,7 +145,7 @@ def kick(inp, input = None, notice = None): @hook.command -def say(inp, input = None, notice = None): +def say(inp, input=None, notice=None): ".say [channel] -- Makes the bot say in [channel]. "\ "If [channel] is blank the bot will say the in "\ "the channel the command was used in." @@ -170,7 +170,7 @@ def say(inp, input = None, notice = None): @hook.command("me") @hook.command -def act(inp, input = None, notice = None): +def act(inp, input=None, notice=None): ".act [channel] -- Makes the bot act out in [channel] "\ "If [channel] is blank the bot will act the in "\ "the channel the command was used in." @@ -194,7 +194,7 @@ def act(inp, input = None, notice = None): @hook.command -def topic(inp, input = None, notice = None): +def topic(inp, input=None, notice=None): ".topic [channel] -- Change the topic of a channel." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") From 10648e9bb2d794089c482543528f6b48aac4c702 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Mon, 12 Mar 2012 22:36:09 +1300 Subject: [PATCH 042/205] Update plugins/admin.py --- plugins/admin.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index e3e5618..e9962d3 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -12,12 +12,8 @@ import time @hook.command("owners", autohelp=False) @hook.command(autohelp=False) def admins(inp, bot=None): - admins = str(bot.config["admins"]) - admins = admins.replace("u'", "") - admins = admins.replace("'", "") - admins = admins.replace("[", "") - admins = admins.replace("]", "") - return admins + admins = bot.config["admins"] + return ", ".join(admins) @hook.command("quit", autohelp=False) From d39fdc51afc341bda5bb41fc4b6c67b35834f6fb Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 00:11:51 +1300 Subject: [PATCH 043/205] Tweaked plugins/time.py - more coming soon :) --- .gitignore | 1 + plugins/time.py | 23 ++++++++--------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 7d9d181..0541584 100755 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ gitflow *.orig .project .pydevproject +.geany diff --git a/plugins/time.py b/plugins/time.py index 8598c63..7895f8f 100755 --- a/plugins/time.py +++ b/plugins/time.py @@ -191,6 +191,7 @@ TimeZones.update(TZ3) r_local = re.compile(r'\([a-z]+_[A-Z]+\)') +# gets the time from a timezone (code from phenny) def get_time(tz): TZ = tz.upper() @@ -206,20 +207,19 @@ def get_time(tz): timenow = time.gmtime(time.time() + offset) msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" + str(TZ), timenow) return msg - #elif tz and tz[0] in ('+', '-') and 4 <= len(tz) <= 6: - # timenow = time.gmtime(time.time() + (int(tz[:3]) * 3600)) - # msg = time.strftime("4\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" + str(tz), timenow) - # return msg + elif tz and tz[0] in ('+', '-') and 4 <= len(tz) <= 6: + timenow = time.gmtime(time.time() + (int(tz[:3]) * 3600)) + msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02 GMT" + str(tz), timenow) + return msg else: timenow = time.gmtime(time.time() + (int(tz) * 3600)) - msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02 GMT" + str(tz), timenow) + msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02 GMT " + str(tz), timenow) return msg @hook.command("time") def timecommand(inp, say = None): ".time -- Gets the time in " - - white_re = re.compile(r'\s+') + tags_re = re.compile(r'<[^<]*?>') page = http.get('http://www.google.com/search', q = "time in " + inp) @@ -230,18 +230,11 @@ def timecommand(inp, say = None): if response: output = response.renderContents() - - output = ' '.join(output.splitlines()) - output = output.replace("\xa0", ",") - - output = white_re.sub(' ', output.strip()) output = tags_re.sub('\x02', output.strip()) - output = output.decode('utf-8', 'ignore') return output else: try: - output = get_time(inp) - return output + return get_time(inp) except ValueError: return "Could not get the time for " + inp + "!" From cb742f4e93c9346d3cb2f2851f40bbafae36eaa7 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 00:21:05 +1300 Subject: [PATCH 044/205] PEP8 baby! (my pep8 says it does need a space in 'CAT':-10, so I re-added them --- plugins/time.py | 243 +++++++++++++++++++++++++----------------------- 1 file changed, 125 insertions(+), 118 deletions(-) diff --git a/plugins/time.py b/plugins/time.py index 7895f8f..d705884 100755 --- a/plugins/time.py +++ b/plugins/time.py @@ -10,31 +10,31 @@ import datetime from BeautifulSoup import BeautifulSoup TimeZones = {'KST': 9, 'CADT': 10.5, 'EETDST': 3, 'MESZ': 2, 'WADT': 9, - 'EET': 2, 'MST':-7, 'WAST': 8, 'IST': 5.5, 'B': 2, - 'MSK': 3, 'X':-11, 'MSD': 4, 'CETDST': 2, 'AST':-4, + 'EET': 2, 'MST': -7, 'WAST': 8, 'IST': 5.5, 'B': 2, + 'MSK': 3, 'X': -11, 'MSD': 4, 'CETDST': 2, 'AST': -4, 'HKT': 8, 'JST': 9, 'CAST': 9.5, 'CET': 1, 'CEST': 2, - 'EEST': 3, 'EAST': 10, 'METDST': 2, 'MDT':-6, 'A': 1, - 'UTC': 0, 'ADT':-3, 'EST':-5, 'E': 5, 'D': 4, 'G': 7, - 'F': 6, 'I': 9, 'H': 8, 'K': 10, 'PDT':-7, 'M': 12, - 'L': 11, 'O':-2, 'MEST': 2, 'Q':-4, 'P':-3, 'S':-6, - 'R':-5, 'U':-8, 'T':-7, 'W':-10, 'WET': 0, 'Y':-12, - 'CST':-6, 'EADT': 11, 'Z': 0, 'GMT': 0, 'WETDST': 1, - 'C': 3, 'WEST': 1, 'CDT':-5, 'MET': 1, 'N':-1, 'V':-9, - 'EDT':-4, 'UT': 0, 'PST':-8, 'MEZ': 1, 'BST': 1, - 'ACS': 9.5, 'ATL':-4, 'ALA':-9, 'HAW':-10, 'AKDT':-8, - 'AKST':-9, + 'EEST': 3, 'EAST': 10, 'METDST': 2, 'MDT': -6, 'A': 1, + 'UTC': 0, 'ADT': -3, 'EST': -5, 'E': 5, 'D': 4, 'G': 7, + 'F': 6, 'I': 9, 'H': 8, 'K': 10, 'PDT': -7, 'M': 12, + 'L': 11, 'O': -2, 'MEST': 2, 'Q': -4, 'P': -3, 'S': -6, + 'R': -5, 'U': -8, 'T': -7, 'W': -10, 'WET': 0, 'Y': -12, + 'CST': -6, 'EADT': 11, 'Z': 0, 'GMT': 0, 'WETDST': 1, + 'C': 3, 'WEST': 1, 'CDT': -5, 'MET': 1, 'N': -1, 'V': -9, + 'EDT': -4, 'UT': 0, 'PST': -8, 'MEZ': 1, 'BST': 1, + 'ACS': 9.5, 'ATL': -4, 'ALA': -9, 'HAW': -10, 'AKDT': -8, + 'AKST': -9, 'BDST': 2} TZ1 = { - 'NDT':-2.5, - 'BRST':-2, - 'ADT':-3, - 'EDT':-4, - 'CDT':-5, - 'MDT':-6, - 'PDT':-7, - 'YDT':-8, - 'HDT':-9, + 'NDT': -2.5, + 'BRST': -2, + 'ADT': -3, + 'EDT': -4, + 'CDT': -5, + 'MDT': -6, + 'PDT': -7, + 'YDT': -8, + 'HDT': -9, 'BST': 1, 'MEST': 2, 'SST': 2, @@ -50,24 +50,24 @@ TZ1 = { 'UT': 0, 'UTC': 0, 'WET': 0, - 'WAT':-1, - 'AT':-2, - 'FNT':-2, - 'BRT':-3, - 'MNT':-4, - 'EWT':-4, - 'AST':-4, - 'EST':-5, - 'ACT':-5, - 'CST':-6, - 'MST':-7, - 'PST':-8, - 'YST':-9, - 'HST':-10, - 'CAT':-10, - 'AHST':-10, - 'NT':-11, - 'IDLW':-12, + 'WAT': -1, + 'AT': -2, + 'FNT': -2, + 'BRT': -3, + 'MNT': -4, + 'EWT': -4, + 'AST': -4, + 'EST': -5, + 'ACT': -5, + 'CST': -6, + 'MST': -7, + 'PST': -8, + 'YST': -9, + 'HST': -10, + 'CAT': -10, + 'AHST': -10, + 'NT': -11, + 'IDLW': -12, 'CET': 1, 'MEZ': 1, 'ECT': 1, @@ -98,86 +98,86 @@ TZ2 = { 'ACDT': 10.5, 'ACST': 9.5, 'ADT': 3, - 'AEDT': 11, # hmm - 'AEST': 10, # hmm + 'AEDT': 11, + 'AEST': 10, 'AHDT': 9, 'AHST': 10, 'AST': 4, 'AT': 2, - 'AWDT':-9, - 'AWST':-8, - 'BAT':-3, - 'BDST':-2, + 'AWDT': -9, + 'AWST': -8, + 'BAT': -3, + 'BDST': -2, 'BET': 11, - 'BST':-1, - 'BT':-3, + 'BST': -1, + 'BT': -3, 'BZT2': 3, - 'CADT':-10.5, - 'CAST':-9.5, + 'CADT': -10.5, + 'CAST': -9.5, 'CAT': 10, - 'CCT':-8, - # 'CDT': 5, - 'CED':-2, - 'CET':-1, + 'CCT': -8, + # 'CDT': 5, + 'CED': -2, + 'CET': -1, 'CST': 6, - 'EAST':-10, - # 'EDT': 4, - 'EED':-3, - 'EET':-2, - 'EEST':-3, + 'EAST': -10, + # 'EDT': 4, + 'EED': -3, + 'EET': -2, + 'EEST': -3, 'EST': 5, - 'FST':-2, - 'FWT':-1, + 'FST': -2, + 'FWT': -1, 'GMT': 0, - 'GST':-10, + 'GST': -10, 'HDT': 9, 'HST': 10, - 'IDLE':-12, + 'IDLE': -12, 'IDLW': 12, - # 'IST': -5.5, - 'IT':-3.5, - 'JST':-9, - 'JT':-7, - 'KST':-9, + # 'IST': -5.5, + 'IT': -3.5, + 'JST': -9, + 'JT': -7, + 'KST': -9, 'MDT': 6, - 'MED':-2, - 'MET':-1, - 'MEST':-2, - 'MEWT':-1, + 'MED': -2, + 'MET': -1, + 'MEST': -2, + 'MEWT': -1, 'MST': 7, - 'MT':-8, + 'MT': -8, 'NDT': 2.5, 'NFT': 3.5, 'NT': 11, - 'NST':-6.5, - 'NZ':-11, - 'NZST':-12, - 'NZDT':-13, - 'NZT':-12, + 'NST': -6.5, + 'NZ': -11, + 'NZST': -12, + 'NZDT': -13, + 'NZT': -12, 'PDT': 7, 'PST': 8, - 'ROK':-9, - 'SAD':-10, - 'SAST':-9, - 'SAT':-9, - 'SDT':-10, - 'SST':-2, - 'SWT':-1, - 'USZ3':-4, - 'USZ4':-5, - 'USZ5':-6, - 'USZ6':-7, + 'ROK': -9, + 'SAD': -10, + 'SAST': -9, + 'SAT': -9, + 'SDT': -10, + 'SST': -2, + 'SWT': -1, + 'USZ3': -4, + 'USZ4': -5, + 'USZ5': -6, + 'USZ6': -7, 'UT': 0, 'UTC': 0, - 'UZ10':-11, + 'UZ10': -11, 'WAT': 1, 'WET': 0, - 'WST':-8, + 'WST': -8, 'YDT': 8, 'YST': 9, - 'ZP4':-4, - 'ZP5':-5, - 'ZP6':-6 + 'ZP4': -4, + 'ZP5': -5, + 'ZP6': -6 } TZ3 = { @@ -191,42 +191,49 @@ TimeZones.update(TZ3) r_local = re.compile(r'\([a-z]+_[A-Z]+\)') + # gets the time from a timezone (code from phenny) def get_time(tz): - TZ = tz.upper() + TZ = tz.upper() + + if (TZ == 'UTC') or (TZ == 'Z'): + msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02 " + "GMT", time.gmtime()) + return msg + elif r_local.match(tz): + locale.setlocale(locale.LC_TIME, (tz[1:-1], 'UTF-8')) + msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" + + str(TZ), time.gmtime()) + return msg + elif TZ in TimeZones: + offset = TimeZones[TZ] * 3600 + timenow = time.gmtime(time.time() + offset) + msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" + + str(TZ), timenow) + return msg + elif tz and tz[0] in ('+', '-') and 4 <= len(tz) <= 6: + timenow = time.gmtime(time.time() + (int(tz[:3]) * 3600)) + msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02" + " GMT" + str(tz), timenow) + return msg + else: + timenow = time.gmtime(time.time() + (int(tz) * 3600)) + msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02" + " GMT " + str(tz), timenow) + return msg - if (TZ == 'UTC') or (TZ == 'Z'): - msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02 GMT", time.gmtime()) - return msg - elif r_local.match(tz): # thanks to Mark Shoulsdon (clsn) - locale.setlocale(locale.LC_TIME, (tz[1:-1], 'UTF-8')) - msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" + str(TZ), time.gmtime()) - return msg - elif TimeZones.has_key(TZ): - offset = TimeZones[TZ] * 3600 - timenow = time.gmtime(time.time() + offset) - msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" + str(TZ), timenow) - return msg - elif tz and tz[0] in ('+', '-') and 4 <= len(tz) <= 6: - timenow = time.gmtime(time.time() + (int(tz[:3]) * 3600)) - msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02 GMT" + str(tz), timenow) - return msg - else: - timenow = time.gmtime(time.time() + (int(tz) * 3600)) - msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02 GMT " + str(tz), timenow) - return msg @hook.command("time") -def timecommand(inp, say = None): +def timecommand(inp, say=None): ".time -- Gets the time in " - + tags_re = re.compile(r'<[^<]*?>') - page = http.get('http://www.google.com/search', q = "time in " + inp) + page = http.get('http://www.google.com/search', q="time in " + inp) soup = BeautifulSoup(page) - response = soup.find('td', {'style' : 'font-size:medium'}) + response = soup.find('td', {'style': 'font-size:medium'}) if response: output = response.renderContents() From 222e49b35693099e3820c8f017b82095436b1532 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 00:25:38 +1300 Subject: [PATCH 045/205] pepified plugins/admin.py --- plugins/admin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/admin.py b/plugins/admin.py index e9962d3..9bdbf22 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -46,6 +46,7 @@ def restart(inp, input=None, db=None, notice=None): time.sleep(5) os.execl("./cloudbot", "restart") + @hook.command("clearlogs", autohelp=False) @hook.command(autohelp=False) def clear(inp, input=None, db=None, notice=None): From c108e8b4ddc0df60fbad5c19898577ff5995548a Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 00:26:01 +1300 Subject: [PATCH 046/205] tidied top comment --- plugins/admin.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index 9bdbf22..4966ffa 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -1,7 +1,4 @@ -# Shitty plugin made by iloveportalz0r -# Broken by The Noodle -# Improved by Lukeroge -# Further improved by neersighted +# Plugin made by iloveportalz0r, TheNoodle, Lukeroge and neersighted from util import hook import os import sys From b1dece0edd21361e63c83012d3f740a8782f3a16 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 00:36:58 +1300 Subject: [PATCH 047/205] standardised multiline strings --- plugins/time.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/time.py b/plugins/time.py index d705884..4c6c5ea 100755 --- a/plugins/time.py +++ b/plugins/time.py @@ -197,28 +197,28 @@ def get_time(tz): TZ = tz.upper() if (TZ == 'UTC') or (TZ == 'Z'): - msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02 " + msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02 " \ "GMT", time.gmtime()) return msg elif r_local.match(tz): locale.setlocale(locale.LC_TIME, (tz[1:-1], 'UTF-8')) - msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" + msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" \ + str(TZ), time.gmtime()) return msg elif TZ in TimeZones: offset = TimeZones[TZ] * 3600 timenow = time.gmtime(time.time() + offset) - msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" + msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" \ + str(TZ), timenow) return msg elif tz and tz[0] in ('+', '-') and 4 <= len(tz) <= 6: timenow = time.gmtime(time.time() + (int(tz[:3]) * 3600)) - msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02" + msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02" \ " GMT" + str(tz), timenow) return msg else: timenow = time.gmtime(time.time() + (int(tz) * 3600)) - msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02" + msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02" \ " GMT " + str(tz), timenow) return msg From a1eb155b145a1d6aa702a34270d7a0f9d1d25add Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 00:40:37 +1300 Subject: [PATCH 048/205] Small tweaks --- plugins/coin.py | 2 +- plugins/dice.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/coin.py b/plugins/coin.py index ddbd853..6cd4ace 100755 --- a/plugins/coin.py +++ b/plugins/coin.py @@ -41,5 +41,5 @@ def coin(inp): return "You flip a coin and get " + sidename + "." else: flips = flip_simple(count) - return "You flip %s coins and get "\ + return "You flip %s coins and get " \ "%s heads and %s tails." % (str(count), str(flips[0]), str(flips[1])) diff --git a/plugins/dice.py b/plugins/dice.py index c70f7f6..dd2ee2f 100755 --- a/plugins/dice.py +++ b/plugins/dice.py @@ -9,7 +9,8 @@ from util import hook whitespace_re = re.compile(r'\s+') -valid_diceroll = r'^([+-]?(?:\d+|\d*d(?:\d+|F))(?:[+-](?:\d+|\d*d(?:\d+|F)))*)( .+)?$' +valid_diceroll = r'^([+-]?(?:\d+|\d*d(?:\d+|F))(?:[+-](?:\d+|\d*d(?:\d+|' \ + 'F)))*)( .+)?$' valid_diceroll_re = re.compile(valid_diceroll, re.I) sign_re = re.compile(r'[+-]?(?:\d*d)?(?:\d+|F)', re.I) split_re = re.compile(r'([\d+-]*)d?(F|\d*)', re.I) @@ -23,12 +24,12 @@ def nrolls(count, n): if count < 100: return [random.randint(0, 1) for x in xrange(count)] else: # fake it - return [int(random.normalvariate(.5*count, (.75*count)**.5))] + return [int(random.normalvariate(.5 * count, (.75 * count) ** .5))] else: if count < 100: return [random.randint(1, n) for x in xrange(count)] else: # fake it - return [int(random.normalvariate(.5*(1+n)*count, + return [int(random.normalvariate(.5 * (1 + n) * count, (((n+1)*(2*n+1)/6.-(.5*(1+n))**2)*count)**.5))] @@ -36,8 +37,8 @@ def nrolls(count, n): #@hook.regex(valid_diceroll, re.I) @hook.command def dice(inp): - ".dice -- Simulates dicerolls. Example of : '.dice 2d20-d5+4 roll 2'." \ - "D20s, subtract 1D5, add 4" + ".dice -- Simulates dicerolls. Example of :" \ + " '.dice 2d20-d5+4 roll 2'. D20s, subtract 1D5, add 4" try: # if inp is a re.match object... (inp, desc) = inp.groups() From 923e829068283962294ae4224c480b728beb6910 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 07:13:32 +1300 Subject: [PATCH 049/205] pep8 tweaks --- plugins/gcalc.py | 5 +++-- plugins/geoip.py | 5 ++++- plugins/gitio.py | 9 ++++++--- plugins/google.py | 10 +++++----- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/plugins/gcalc.py b/plugins/gcalc.py index a568f53..68333b1 100755 --- a/plugins/gcalc.py +++ b/plugins/gcalc.py @@ -3,8 +3,9 @@ import re from util import hook, http, misc from BeautifulSoup import BeautifulSoup -@hook.command("calc") + @hook.command("math") +@hook.command def calc(inp): ".calc -- Calculate with Google Calc." @@ -14,7 +15,7 @@ def calc(inp): soup = BeautifulSoup(page) - response = soup.find('h2', {'class' : 'r'}) + response = soup.find('h2', {'class': 'r'}) if response is None: return "Could not calculate " + inp diff --git a/plugins/geoip.py b/plugins/geoip.py index 97a3fc7..b8d540c 100755 --- a/plugins/geoip.py +++ b/plugins/geoip.py @@ -1,9 +1,11 @@ from util import hook + def find_location(ip, api): import string import urllib - response = urllib.urlopen("http://api.ipinfodb.com/v3/ip-city/?key="+api+"&ip="+ip).read() + response = urllib.urlopen("http://api.ipinfodb.com/v3/ip-city/?key=" \ + + api + "&ip=" + ip).read() response = response.split(";") give = {} give["country"] = response[4].title() @@ -13,6 +15,7 @@ def find_location(ip, api): give["timezone"] = response[10].title() return give + def timezone(ip): time = find_location(ip)["timezone"] time = time.replace(":", ".") diff --git a/plugins/gitio.py b/plugins/gitio.py index be40835..287eed0 100755 --- a/plugins/gitio.py +++ b/plugins/gitio.py @@ -2,6 +2,7 @@ from util import hook import urllib2 + @hook.command def gitio(inp): ".gitio [code] -- Shorten Github URLs with git.io. [code] is a optional custom short code." @@ -13,13 +14,14 @@ def gitio(inp): except: code = None - # if the first 8 chars of "url" are not "https://" then append "https://" to the url, also convert "http://" to "https://" + # if the first 8 chars of "url" are not "https://" then append + # "https://" to the url, also convert "http://" to "https://" if url[:8] != "https://": if url[:7] != "http://": url = "https://" + url else: url = "https://" + url[7:] - url='url='+str(url) + url = 'url=' + str(url) if code: url = url + '&code=' + str(code) req = urllib2.Request(url='http://git.io', data=url) @@ -31,7 +33,8 @@ def gitio(inp): return "Failed to get URL!" urlinfo = str(f.info()) - # loop over the rows in urlinfo and pick out location and status (this is pretty odd code, but urllib2.Request is weird) + # loop over the rows in urlinfo and pick out location and + # status (this is pretty odd code, but urllib2.Request is weird) for row in urlinfo.split("\n"): if row.find("Status") != -1: status = row diff --git a/plugins/google.py b/plugins/google.py index 7293099..5d6f9ac 100755 --- a/plugins/google.py +++ b/plugins/google.py @@ -15,12 +15,12 @@ def gis(inp): parsed = api_get('images', inp) if not 200 <= parsed['responseStatus'] < 300: - raise IOError('error searching for images: %d: %s' % ( - parsed['responseStatus'], '')) + raise IOError('error searching for images: %d: %s' % ( \ + parsed['responseStatus'], '')) if not parsed['responseData']['results']: return 'no images found' - return random.choice(parsed['responseData']['results'][:10])\ - ['unescapedUrl'] # squares is dumb + return random.choice(parsed['responseData']['results'][:10]) \ + ['unescapedUrl'] # squares is dumb @hook.command('g') @@ -31,7 +31,7 @@ def google(inp): parsed = api_get('web', inp) if not 200 <= parsed['responseStatus'] < 300: raise IOError('error searching for pages: %d: %s' % ( - parsed['responseStatus'], '')) + parsed['responseStatus'], '')) if not parsed['responseData']['results']: return 'No results found.' From e9ae52c80fadf50b7cc89e2f3401ba37d76cf2b7 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 07:23:41 +1300 Subject: [PATCH 050/205] fixed command aliases in plugins/remember.py --- plugins/factoids.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/factoids.py b/plugins/factoids.py index f26fab7..f6c3b4e 100755 --- a/plugins/factoids.py +++ b/plugins/factoids.py @@ -6,7 +6,7 @@ from util import hook import re -# the dictionary has target_word : replacement_word pairs +# some simple "shortcodes" for formatting purposes shortcodes = { '': '\x02', '': '\x02', @@ -44,6 +44,7 @@ def multiwordReplace(text, wordDic): @hook.command("r") +@hook.command def remember(inp, nick='', db=None, say=None, input=None, notice=None): ".remember [+] -- Remembers with . Add + to to append." if input.nick not in input.bot.config["admins"]: @@ -89,6 +90,7 @@ def remember(inp, nick='', db=None, say=None, input=None, notice=None): @hook.command("f") +@hook.command def forget(inp, db=None, input=None, notice=None): ".forget -- Forgets a remembered ." if input.nick not in input.bot.config["admins"]: @@ -102,7 +104,7 @@ def forget(inp, db=None, input=None, notice=None): db.execute("delete from mem where word=lower(?)", [inp]) db.commit() - notice('`%s` has been forgotten.' % data.replace('`', "'")) + notice('"%s" has been forgotten.' % data.replace('`', "'")) return else: notice("I don't know about that.") From 7e00677c038e245f5292c3bed763fe63451cd73a Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 08:10:01 +1300 Subject: [PATCH 051/205] removed some useless code --- plugins/util/molecular.py | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/plugins/util/molecular.py b/plugins/util/molecular.py index 4094d4b..3de9c00 100755 --- a/plugins/util/molecular.py +++ b/plugins/util/molecular.py @@ -33,6 +33,8 @@ """molecular.py -- molecular (ngenoid) name generator +Modified for CloudBot by Lukeroge. + This module knows how to generate "random" names for RPG characters. It uses the same method as the "ngen" name generator by Kimmo Kulovesi, and in fact it can use the same name files. molecular.py knows how @@ -201,26 +203,3 @@ class Molecule: if len(self.nametbl["final"]) > 0: n.append(random.choice(self.nametbl["final"])) return string.join(n, "") - -if __name__ == "__main__": - - if len(sys.argv) <= 1: - sys.stderr.write( \ - "Usage: molecular.py [ -r file ] [ nn ]\n") - sys.exit(0) - - name = Molecule() - - i = 1 - - while i < len(sys.argv): - arg = sys.argv[i] - if arg == "-r": - i += 1 - name.load(sys.argv[i]) - else: - n = int(sys.argv[i]) - lst = [] - for i in range(n): - print name.name() - i += 1 From df94d61d7016fe7559838f056bc93875495a9a8e Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 12 Mar 2012 13:28:10 -0700 Subject: [PATCH 052/205] Fixed up insult to make it match violence/flirt.py --- plugins/insult.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/plugins/insult.py b/plugins/insult.py index 3f0c62d..e8a98a8 100755 --- a/plugins/insult.py +++ b/plugins/insult.py @@ -14,7 +14,7 @@ insults = ["You are the son of a motherless ogre.", "Shouldn't you have a license for being that ugly?", "Calling you an idiot would be an insult to all the stupid people.", "Why don't you slip into something more comfortable...like a coma.", - "Well, they do say opposites attact...so I sincerely hope you meet somebody who is attractive, honest, intelligent, and cultured..", + "Well, they do say opposites attract...so I sincerely hope you meet somebody who is attractive, honest, intelligent, and cultured..", "Are you always this stupid or are you just making a special effort today?", "Yo momma so fat when she sits around the house she sits AROUND the house.", "Yo momma so ugly she made an onion cry.", @@ -22,7 +22,7 @@ insults = ["You are the son of a motherless ogre.", "Bite my shiny metal ass!", "Up yours, meatbag.", "Jam a bastard in it you crap!", - "Don't piss me off today, I'm running out of places to hide to bodies", + "Don't piss me off today, I'm running out of places to hide the bodies", "Why don't you go outside and play hide and go fuck yourself", "I'll use small words you're sure to understand, you warthog-faced buffoon.", "You are a sad, strange little man, and you have my pity.", @@ -36,14 +36,18 @@ insults = ["You are the son of a motherless ogre.", "The village called, they want their idiot back."] @hook.command(autohelp=False) -def insult(inp, nick=None, say=None, input=None): +def insult(inp, nick=None, me=None, input=None): ".insult -- Makes the bot insult ." - - msg = "(" + nick + ") " + random.choice(insults) - if re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()) and inp != "": - msg = "(@" + inp + ") " + random.choice(insults) + inp = inp.strip() + if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): + notice("Invalid username!") + return + + target = nick + if inp.lower() and inp != "": + target = inp if inp == input.conn.nick.lower() or inp == "itself": - msg = "*stares at " + nick + "*" - - say(msg) + target = nick + msg = "insults " + target + "... \"" + random.choice(insults) + "\"" + me(msg) From c168a179e37dbd14c992ddf62d5ee6e132df627b Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 09:31:41 +1300 Subject: [PATCH 053/205] Changed method of checking for admin powers, small tweaks --- plugins/admin.py | 68 ++++++++++++--------------------------------- plugins/factoids.py | 10 +++---- plugins/help.py | 15 +++++----- plugins/sieve.py | 2 +- 4 files changed, 32 insertions(+), 63 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index 4966ffa..2131ad6 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -13,11 +13,9 @@ def admins(inp, bot=None): return ", ".join(admins) -@hook.command("quit", autohelp=False) -@hook.command("exit", autohelp=False) -@hook.command(autohelp=False) +@hook.command(autohelp=False, adminOnly=True) def stop(inp, input=None, db=None, notice=None): - ".stop [reason] -- Kills the bot, with [reason] as its quit message." + ".stop [reason] -- Kills the bot with [reason] as its quit message." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") return @@ -29,13 +27,10 @@ def stop(inp, input=None, db=None, notice=None): subprocess.call("./cloudbot stop", shell=True) -@hook.command("reboot", autohelp=False) -@hook.command(autohelp=False) +@hook.command("reboot", autohelp=False, adminonly=True) +@hook.command(autohelp=False, adminonly=True) def restart(inp, input=None, db=None, notice=None): - ".restart [reason] -- Restarts the bot, with [reason] as its quit message." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return + ".restart [reason] -- Restarts the bot with [reason] as its quit message." if inp: input.conn.send("QUIT :Restarted by " + input.nick + " (" + inp + ")") else: @@ -44,74 +39,53 @@ def restart(inp, input=None, db=None, notice=None): os.execl("./cloudbot", "restart") -@hook.command("clearlogs", autohelp=False) -@hook.command(autohelp=False) +@hook.command("clearlogs", autohelp=False, adminonly=True) +@hook.command(autohelp=False, adminonly=True) def clear(inp, input=None, db=None, notice=None): - ".clear -- Clears the bot's log(s)." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return + ".clear -- Clears the bots log(s)." time.sleep(5) subprocess.call("./cloudbot clear", shell=True) -@hook.command +@hook.command(adminonly=True) def join(inp, input=None, db=None, notice=None): ".join -- Joins ." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return notice("Attempting to join " + inp + "...") input.conn.send("JOIN " + inp) -@hook.command +@hook.command(adminonly=True) def cycle(inp, input=None, db=None, notice=None): ".cycle -- Cycles ." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return notice("Attempting to cycle " + inp + "...") input.conn.send("PART " + inp) input.conn.send("JOIN " + inp) -@hook.command +@hook.command(adminonly=True) def part(inp, input=None, notice=None): ".part -- Parts from ." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return notice("Attempting to part from " + inp + "...") input.conn.send("PART " + inp) -@hook.command +@hook.command(adminonly=True) def nick(inp, input=None, notice=None): ".nick -- Changes the bots nickname to ." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return notice("Changing nick to " + inp + ".") input.conn.send("NICK " + inp) -@hook.command +@hook.command(adminonly=True) def raw(inp, input=None, notice=None): ".raw -- Sends a RAW IRC command." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return notice("Raw command sent.") input.conn.send(inp) -@hook.command +@hook.command(adminonly=True) def kick(inp, input=None, notice=None): ".kick [channel] [reason] -- kicks a user." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return split = inp.split(" ") if split[0][0] == "#": chan = split[0] @@ -138,14 +112,11 @@ def kick(inp, input=None, notice=None): input.conn.send(out) -@hook.command +@hook.command(adminonly=True) def say(inp, input=None, notice=None): ".say [channel] -- Makes the bot say in [channel]. "\ "If [channel] is blank the bot will say the in "\ "the channel the command was used in." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return split = inp.split(" ") if split[0][0] == "#": message = "" @@ -162,8 +133,8 @@ def say(inp, input=None, notice=None): input.conn.send(out) -@hook.command("me") -@hook.command +@hook.command("me", adminonly=True) +@hook.command(adminonly=True) def act(inp, input=None, notice=None): ".act [channel] -- Makes the bot act out in [channel] "\ "If [channel] is blank the bot will act the in "\ @@ -187,12 +158,9 @@ def act(inp, input=None, notice=None): input.conn.send(out) -@hook.command +@hook.command(adminonly=True) def topic(inp, input=None, notice=None): ".topic [channel] -- Change the topic of a channel." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return split = inp.split(" ") if split[0][0] == "#": out = "PRIVMSG %s :%s" % (split[0], message) diff --git a/plugins/factoids.py b/plugins/factoids.py index f6c3b4e..0bccc64 100755 --- a/plugins/factoids.py +++ b/plugins/factoids.py @@ -43,8 +43,8 @@ def multiwordReplace(text, wordDic): return rc.sub(translate, text) -@hook.command("r") -@hook.command +@hook.command("r", adminonly=True) +@hook.command(adminonly=True) def remember(inp, nick='', db=None, say=None, input=None, notice=None): ".remember [+] -- Remembers with . Add + to to append." if input.nick not in input.bot.config["admins"]: @@ -89,8 +89,8 @@ def remember(inp, nick='', db=None, say=None, input=None, notice=None): return -@hook.command("f") -@hook.command +@hook.command("f", adminonly=True) +@hook.command(adminonly=True) def forget(inp, db=None, input=None, notice=None): ".forget -- Forgets a remembered ." if input.nick not in input.bot.config["admins"]: @@ -113,7 +113,7 @@ def forget(inp, db=None, input=None, notice=None): @hook.command("info") @hook.regex(r'^\? ?(.+)') -def question(inp, say=None, db=None, bot=None): +def factoid(inp, say=None, db=None, bot=None): "? -- Shows what data is associated with ." try: prefix_on = bot.config["plugins"]["factoids"]["prefix"] diff --git a/plugins/help.py b/plugins/help.py index 59e351f..bde3d17 100755 --- a/plugins/help.py +++ b/plugins/help.py @@ -12,13 +12,14 @@ def help(inp, input=None, bot=None, say=None, notice=None): for command, (func, args) in bot.commands.iteritems(): fn = re.match(r'^plugins.(.+).py$', func._filename) if fn.group(1).lower() not in disabled: - if command not in disabled_comm: - if func.__doc__ is not None: - if func in funcs: - if len(funcs[func]) < len(command): + if not args.get('adminonly', False) or input.nick in input.bot.config["admins"]: + if command not in disabled_comm: + if func.__doc__ is not None: + if func in funcs: + if len(funcs[func]) < len(command): + funcs[func] = command + else: funcs[func] = command - else: - funcs[func] = command commands = dict((value, key) for key, value in funcs.iteritems()) @@ -30,7 +31,7 @@ def help(inp, input=None, bot=None, say=None, notice=None): well.append(x) well.sort() for x in well: - if len(out[0]) + len(str(x)) > 440: + if len(out[0]) + len(str(x)) > 405: out[1] += " " + str(x) else: out[0] += " " + str(x) diff --git a/plugins/sieve.py b/plugins/sieve.py index 108390e..305c1e3 100755 --- a/plugins/sieve.py +++ b/plugins/sieve.py @@ -37,6 +37,6 @@ def sieve_suite(bot, input, func, kind, args): admins = bot.config.get('admins', []) if input.host not in admins and input.nick not in admins: - return None + return return input From 6edeb547f88fe7962cacf97eb256c89fbcf160d8 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 09:33:52 +1300 Subject: [PATCH 054/205] oops --- plugins/sieve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/sieve.py b/plugins/sieve.py index 305c1e3..108390e 100755 --- a/plugins/sieve.py +++ b/plugins/sieve.py @@ -37,6 +37,6 @@ def sieve_suite(bot, input, func, kind, args): admins = bot.config.get('admins', []) if input.host not in admins and input.nick not in admins: - return + return None return input From de2810662f2bd8cd1e313bc1ee970ad9981fb90a Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 12 Mar 2012 13:41:01 -0700 Subject: [PATCH 055/205] Merged flirt and insult.py => feelings.py --- plugins/{flirt.py => feelings.py} | 51 +++++++++++++++++++++++++++++ plugins/insult.py | 53 ------------------------------- 2 files changed, 51 insertions(+), 53 deletions(-) rename plugins/{flirt.py => feelings.py} (54%) delete mode 100755 plugins/insult.py diff --git a/plugins/flirt.py b/plugins/feelings.py similarity index 54% rename from plugins/flirt.py rename to plugins/feelings.py index fd610b3..4437d61 100755 --- a/plugins/flirt.py +++ b/plugins/feelings.py @@ -2,6 +2,39 @@ from util import hook import re import random +insults = ["You are the son of a motherless ogre.", + "Your mother was a hamster and your father smelled of elderberries.", + "I once owned a dog that was smarter than you. ", + "Go climb a wall of dicks.", + "You fight like a dairy farmer.", + "I've spoken to apes more polite than you.", + "Go and boil your bottom! Son of a silly person! ", + "I fart in your general direction.", + "Go away or I shall taunt you a second time. ", + "Shouldn't you have a license for being that ugly?", + "Calling you an idiot would be an insult to all the stupid people.", + "Why don't you slip into something more comfortable...like a coma.", + "Well, they do say opposites attract...so I sincerely hope you meet somebody who is attractive, honest, intelligent, and cultured..", + "Are you always this stupid or are you just making a special effort today?", + "Yo momma so fat when she sits around the house she sits AROUND the house.", + "Yo momma so ugly she made an onion cry.", + "Is your name Maple Syrup? It should be, you sap.", + "Bite my shiny metal ass!", + "Up yours, meatbag.", + "Jam a bastard in it you crap!", + "Don't piss me off today, I'm running out of places to hide the bodies", + "Why don't you go outside and play hide and go fuck yourself", + "I'll use small words you're sure to understand, you warthog-faced buffoon.", + "You are a sad, strange little man, and you have my pity.", + "Sit your five dollar ass down before I make change.", + "What you've just said is one of the most insanely idiotic things I've ever heard. Everyone in this room is now dumber for having listened to it. May God have mercy on your soul.", + "Look up Idiot in the dictionary. Know what you'll find? The definition of the word IDIOT, which you are.", + "You're dumber than a bag of hammers.", + "Why don't you go back to your home on Whore Island?", + "If I had a dick this is when I'd tell you to suck it.", + "Go play in traffic.", + "The village called, they want their idiot back."] + flirts = ["I bet your name's Mickey, 'cause you're so fine.", "Hey, pretty mama. You smell kinda pretty, wanna smell me?", "I better get out my library card, 'cause I'm checkin' you out.", @@ -44,6 +77,24 @@ flirts = ["I bet your name's Mickey, 'cause you're so fine.", "Your daddy must have been a baker, because you've got a nice set of buns."] +@hook.command(autohelp=False) +def insult(inp, nick=None, me=None, input=None): + ".insult -- Makes the bot insult ." + inp = inp.strip() + + if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): + notice("Invalid username!") + return + + target = nick + if inp.lower() and inp != "": + target = inp + if inp == input.conn.nick.lower() or inp == "itself": + target = nick + msg = "insults " + target + "... \"" + random.choice(insults) + "\"" + me(msg) + + @hook.command(autohelp=False) def flirt(inp, nick=None, me=None, input=None): ".flirt -- Make the bot flirt with ." diff --git a/plugins/insult.py b/plugins/insult.py deleted file mode 100755 index e8a98a8..0000000 --- a/plugins/insult.py +++ /dev/null @@ -1,53 +0,0 @@ -from util import hook -import re -import random - -insults = ["You are the son of a motherless ogre.", - "Your mother was a hamster and your father smelled of elderberries.", - "I once owned a dog that was smarter than you. ", - "Go climb a wall of dicks.", - "You fight like a dairy farmer.", - "I've spoken to apes more polite than you.", - "Go and boil your bottom! Son of a silly person! ", - "I fart in your general direction.", - "Go away or I shall taunt you a second time. ", - "Shouldn't you have a license for being that ugly?", - "Calling you an idiot would be an insult to all the stupid people.", - "Why don't you slip into something more comfortable...like a coma.", - "Well, they do say opposites attract...so I sincerely hope you meet somebody who is attractive, honest, intelligent, and cultured..", - "Are you always this stupid or are you just making a special effort today?", - "Yo momma so fat when she sits around the house she sits AROUND the house.", - "Yo momma so ugly she made an onion cry.", - "Is your name Maple Syrup? It should be, you sap.", - "Bite my shiny metal ass!", - "Up yours, meatbag.", - "Jam a bastard in it you crap!", - "Don't piss me off today, I'm running out of places to hide the bodies", - "Why don't you go outside and play hide and go fuck yourself", - "I'll use small words you're sure to understand, you warthog-faced buffoon.", - "You are a sad, strange little man, and you have my pity.", - "Sit your five dollar ass down before I make change.", - "What you've just said is one of the most insanely idiotic things I've ever heard. Everyone in this room is now dumber for having listened to it. May God have mercy on your soul.", - "Look up Idiot in the dictionary. Know what you'll find? The definition of the word IDIOT, which you are.", - "You're dumber than a bag of hammers.", - "Why don't you go back to your home on Whore Island?", - "If I had a dick this is when I'd tell you to suck it.", - "Go play in traffic.", - "The village called, they want their idiot back."] - -@hook.command(autohelp=False) -def insult(inp, nick=None, me=None, input=None): - ".insult -- Makes the bot insult ." - inp = inp.strip() - - if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): - notice("Invalid username!") - return - - target = nick - if inp.lower() and inp != "": - target = inp - if inp == input.conn.nick.lower() or inp == "itself": - target = nick - msg = "insults " + target + "... \"" + random.choice(insults) + "\"" - me(msg) From 056dbc5037627ce21ef37a084f2ad4f676939d4a Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 09:48:58 +1300 Subject: [PATCH 056/205] seen.py now records users hostmasks in the DB --- plugins/seen.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/seen.py b/plugins/seen.py index 4be75be..7becdf2 100755 --- a/plugins/seen.py +++ b/plugins/seen.py @@ -8,7 +8,7 @@ from util import hook, timesince def db_init(db): "check to see that our db has the the seen table and return a connection." - db.execute("create table if not exists seen(name, time, quote, chan, " + db.execute("create table if not exists seen_user(name, time, quote, chan, host, " "primary key(name, chan))") db.commit() @@ -17,9 +17,9 @@ def db_init(db): @hook.event('PRIVMSG', ignorebots=False) def seeninput(paraml, input=None, db=None, bot=None): db_init(db) - db.execute("insert or replace into seen(name, time, quote, chan)" - "values(?,?,?,?)", (input.nick.lower(), time.time(), input.msg, - input.chan)) + db.execute("insert or replace into seen_user(name, time, quote, chan, host)" + "values(?,?,?,?,?)", (input.nick.lower(), time.time(), input.msg, + input.chan, input.host)) db.commit() @@ -39,7 +39,7 @@ def seen(inp, nick='', chan='', db=None, input=None): db_init(db) - last_seen = db.execute("select name, time, quote from seen where name" + last_seen = db.execute("select name, time, quote from seen_user where name" " like ? and chan = ?", (inp, chan)).fetchone() if last_seen: From 77d86dc84029e9dac751f60719668e5d24c84335 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 09:50:55 +1300 Subject: [PATCH 057/205] Typo --- plugins/seen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/seen.py b/plugins/seen.py index 7becdf2..d26eb8f 100755 --- a/plugins/seen.py +++ b/plugins/seen.py @@ -35,7 +35,7 @@ def seen(inp, nick='', chan='', db=None, input=None): return "Have you looked in a mirror lately?" if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): - return "I cant look up that name, its impossible to use!" + return "I can't look up that name, its impossible to use!" db_init(db) From f1815037c02179e9ca3a2943b075b51247eaf91c Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 10:07:32 +1300 Subject: [PATCH 058/205] switched to proper nick change function --- plugins/admin.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index 2131ad6..63a474c 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -16,9 +16,6 @@ def admins(inp, bot=None): @hook.command(autohelp=False, adminOnly=True) def stop(inp, input=None, db=None, notice=None): ".stop [reason] -- Kills the bot with [reason] as its quit message." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return if inp: input.conn.send("QUIT :Killed by " + input.nick + " (" + inp + ")") else: @@ -70,10 +67,10 @@ def part(inp, input=None, notice=None): @hook.command(adminonly=True) -def nick(inp, input=None, notice=None): +def nick(inp, input=None, notice=None, set_nick=None): ".nick -- Changes the bots nickname to ." notice("Changing nick to " + inp + ".") - input.conn.send("NICK " + inp) + set_nick(inp) @hook.command(adminonly=True) @@ -139,9 +136,6 @@ def act(inp, input=None, notice=None): ".act [channel] -- Makes the bot act out in [channel] "\ "If [channel] is blank the bot will act the in "\ "the channel the command was used in." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return split = inp.split(" ") if split[0][0] == "#": message = "" From ae861d07c9d5a69a8f7dfc2f7914296b2e3ad324 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 10:14:23 +1300 Subject: [PATCH 059/205] core changes --- core/irc.py | 1 + core/main.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/core/irc.py b/core/irc.py index b14c828..c7fdfe1 100755 --- a/core/irc.py +++ b/core/irc.py @@ -180,6 +180,7 @@ class IRC(object): def set_nick(self, nick): self.cmd("NICK", [nick]) + self.nick = nick def join(self, channel): self.cmd("JOIN", [channel]) diff --git a/core/main.py b/core/main.py index 041d67e..1b872c3 100755 --- a/core/main.py +++ b/core/main.py @@ -33,6 +33,9 @@ class Input(dict): def notice(msg): conn.cmd('NOTICE', [nick, msg]) + + def cmd(command): + conn.cmd(command) dict.__init__(self, conn=conn, raw=raw, prefix=prefix, command=command, params=params, nick=nick, user=user, host=host, From 4c1ec8853673015e3699aafcb68ca41e70c2163a Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 10:18:51 +1300 Subject: [PATCH 060/205] Fixed bug --- plugins/admin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/admin.py b/plugins/admin.py index 63a474c..1bed513 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -4,6 +4,7 @@ import os import sys import subprocess import time +import re @hook.command("owners", autohelp=False) @@ -69,6 +70,9 @@ def part(inp, input=None, notice=None): @hook.command(adminonly=True) def nick(inp, input=None, notice=None, set_nick=None): ".nick -- Changes the bots nickname to ." + if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): + notice("Invalid username!") + return notice("Changing nick to " + inp + ".") set_nick(inp) From 063ded0f472d3c9f8ef23ac4fbeddcc078db4f95 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 10:29:51 +1300 Subject: [PATCH 061/205] durp --- core/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/main.py b/core/main.py index 1b872c3..e567a46 100755 --- a/core/main.py +++ b/core/main.py @@ -34,8 +34,8 @@ class Input(dict): def notice(msg): conn.cmd('NOTICE', [nick, msg]) - def cmd(command): - conn.cmd(command) + def raw(command): + conn.send(command) dict.__init__(self, conn=conn, raw=raw, prefix=prefix, command=command, params=params, nick=nick, user=user, host=host, From 75c17d5723ba0267e17ceaf3860a03c9c04bb744 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 10:43:28 +1300 Subject: [PATCH 062/205] another quick bugfix --- plugins/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/admin.py b/plugins/admin.py index 1bed513..d894d51 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -14,7 +14,7 @@ def admins(inp, bot=None): return ", ".join(admins) -@hook.command(autohelp=False, adminOnly=True) +@hook.command(autohelp=False, adminonly=True) def stop(inp, input=None, db=None, notice=None): ".stop [reason] -- Kills the bot with [reason] as its quit message." if inp: From e246512315a9b325e50e088267990f19473d959b Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 12 Mar 2012 14:35:36 -0800 Subject: [PATCH 063/205] fixed autohelp in lastfm.py --- plugins/lastfm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/lastfm.py b/plugins/lastfm.py index 9e7d508..84b197a 100755 --- a/plugins/lastfm.py +++ b/plugins/lastfm.py @@ -1,15 +1,15 @@ # Upgraded with tables/cacheing by ChauffeR of #freebnc on irc.esper.net from util import hook, http -@hook.command('l') -@hook.command('lfm') -@hook.command +@hook.command('l', autohelp=False) +@hook.command('lfm', autohelp=False) +@hook.command(autohelp=False) def lastfm(inp, nick='', say=None, db=None, bot=None): + ".lastfm -- Displays the now playing (or recent) tracks of LastFM user ." if inp: user = inp else: user = nick - ".lastfm -- Displays the now playing (or recent) tracks of LastFM user ." db.execute("create table if not exists lastfm(nick primary key, acc)") sql = db.execute("select acc from lastfm where nick=lower(?)", (nick,)).fetchone(); api_url = "http://ws.audioscrobbler.com/2.0/?format=json" From b228b635cf96db0f73ec3ba1517cf9d08d0389c8 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 12 Mar 2012 14:36:27 -0800 Subject: [PATCH 064/205] typo --- plugins/lastfm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/lastfm.py b/plugins/lastfm.py index 84b197a..5218a4d 100755 --- a/plugins/lastfm.py +++ b/plugins/lastfm.py @@ -1,4 +1,4 @@ -# Upgraded with tables/cacheing by ChauffeR of #freebnc on irc.esper.net +# Upgraded with tables/caching by ChauffeR of #freebnc on irc.esper.net from util import hook, http @hook.command('l', autohelp=False) From fa1bcb58a46ee1b5fe7b92f403e24a0b8fdc0150 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 18:20:47 +1300 Subject: [PATCH 065/205] Pep8 in core files --- core/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/main.py b/core/main.py index e567a46..09e4e66 100755 --- a/core/main.py +++ b/core/main.py @@ -33,7 +33,7 @@ class Input(dict): def notice(msg): conn.cmd('NOTICE', [nick, msg]) - + def raw(command): conn.send(command) From d08a64c0ad59854892dadcae80af5f22caa4a92b Mon Sep 17 00:00:00 2001 From: neersighted Date: Tue, 13 Mar 2012 11:53:04 -0700 Subject: [PATCH 066/205] minor tweaks --- plugins/admin.py | 1 + plugins/violence.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/admin.py b/plugins/admin.py index d894d51..b2d66be 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -10,6 +10,7 @@ import re @hook.command("owners", autohelp=False) @hook.command(autohelp=False) def admins(inp, bot=None): + ".admins -- Lists the bot's admins." admins = bot.config["admins"] return ", ".join(admins) diff --git a/plugins/violence.py b/plugins/violence.py index 888a5cd..286ca1c 100644 --- a/plugins/violence.py +++ b/plugins/violence.py @@ -157,7 +157,7 @@ kills = ["rips off 's and leaves them to die.", "crushes 's skull in with a spiked mace.", "unleashes the armies of Isengard on .", "packs into a SVN repo.", - "slices 's off with a Katana", + "slices 's off with a Katana.", "throws to Cthulu!", "feeds to an owlbear.", "turns into a snail and salts them.", From 4cb20608721e6255b49e505774c4759ca3021a97 Mon Sep 17 00:00:00 2001 From: neersighted Date: Tue, 13 Mar 2012 11:55:58 -0700 Subject: [PATCH 067/205] tweak lastfm help message --- plugins/lastfm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/lastfm.py b/plugins/lastfm.py index 5218a4d..e9dee3b 100755 --- a/plugins/lastfm.py +++ b/plugins/lastfm.py @@ -5,7 +5,7 @@ from util import hook, http @hook.command('lfm', autohelp=False) @hook.command(autohelp=False) def lastfm(inp, nick='', say=None, db=None, bot=None): - ".lastfm -- Displays the now playing (or recent) tracks of LastFM user ." + ".lastfm [user] -- Displays the now playing (or recent) tracks of LastFM user [user]." if inp: user = inp else: @@ -37,7 +37,7 @@ def lastfm(inp, nick='', say=None, db=None, bot=None): if inp: # specified a user name return "error: %s" % response["message"] else: - return "your nick is not a LastFM account. try '.lastfm '" + return "your nick is not a LastFM account. try '.lastfm [user]'" tracks = response["recenttracks"]["track"] From f720790b85730140c5279c7044f14dc8eca8812c Mon Sep 17 00:00:00 2001 From: neersighted Date: Tue, 13 Mar 2012 11:57:09 -0700 Subject: [PATCH 068/205] more lastfm tweaks --- plugins/lastfm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/lastfm.py b/plugins/lastfm.py index e9dee3b..a1616aa 100755 --- a/plugins/lastfm.py +++ b/plugins/lastfm.py @@ -5,7 +5,7 @@ from util import hook, http @hook.command('lfm', autohelp=False) @hook.command(autohelp=False) def lastfm(inp, nick='', say=None, db=None, bot=None): - ".lastfm [user] -- Displays the now playing (or recent) tracks of LastFM user [user]." + ".lastfm [user] -- Displays the now playing (or last played) track of LastFM user [user]." if inp: user = inp else: From 1907cbb389b13a8d57b1cb89201a783d5dec2fee Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Fri, 16 Mar 2012 16:20:13 +1300 Subject: [PATCH 069/205] push --- plugins/data/itemids.txt | 306 +++++++++++++++++++++++++++++++++++++++ plugins/data/recipes.txt | 0 plugins/mcitems.py | 99 +++++++++++++ 3 files changed, 405 insertions(+) create mode 100644 plugins/data/itemids.txt create mode 100644 plugins/data/recipes.txt create mode 100644 plugins/mcitems.py diff --git a/plugins/data/itemids.txt b/plugins/data/itemids.txt new file mode 100644 index 0000000..54f4885 --- /dev/null +++ b/plugins/data/itemids.txt @@ -0,0 +1,306 @@ +1 Stone +2 Grass Block +3 Dirt +4 Cobblestone +5 Wooden Planks +6 Sapling +7 Bedrock +8 Water +9 Water +10 Lava +11 Lava +12 Sand +13 Gravel +14 Gold Ore +15 Iron Ore +16 Coal Ore +17 Wood +18 Leaves +19 Sponge +20 Glass +21 Lapis Lazuli Ore +22 Lapis Lazuli Block +23 Dispenser +24 Sandstone +25 Note Block +26 Bed +27 Powered Rail +28 Detector Rail +29 Sticky Piston +30 Cobweb +31 Grass +32 Dead Bush +33 Piston +34 Unknown +35 Wool +36 Unknown +37 Flower +38 Rose +39 Mushroom +40 Mushroom +41 Block of Gold +42 Block of Iron +43 Double Slabs +44 Slabs +45 Bricks +46 TNT +47 Bookshelf +48 Moss Stone +49 Obsidian +50 Torch +51 Fire +52 Monster Spawner +53 Wooden Stairs +54 Chest +55 Redstone Dust +56 Diamond Ore +57 Block of Diamond +58 Crafting Table +59 Crops +60 Farmland +61 Furnace +62 Furnace +63 Sign +64 Wooden Door +65 Ladder +66 Rail +67 Stone Stairs +68 Sign +69 Lever +70 Pressure Plate +71 Iron Door +72 Pressure Plate +73 Redstone Ore +74 Redstone Ore +75 Redstone Torch +76 Redstone Torch +77 Button +78 Snow +79 Ice +80 Snow +81 Cactus +82 Clay +83 Sugar cane +84 Jukebox +85 Fence +86 Pumpkin +87 Netherrack +88 Soul Sand +89 Glowstone +90 Portal +91 Jack 'o' Lantern +92 Cake +93 Redstone Repeater (off) +94 Redstone Repeater (on) +95 Locked chest +96 Trapdoor +97 Hidden Silverfish +98 Stone Bricks +99 Mushroom +100 Mushroom +101 Iron Bars +102 Glass Pane +103 Melon +104 Pumpkin Stem +105 Melon Stem +106 Vines +107 Fence Gate +108 Brick Stairs +109 Stone Brick Stairs +110 Mycelium +111 Lily Pad +112 Nether Brick +113 Nether Brick Fence +114 Nether Brick Stairs +115 Nether Wart +116 Enchantment Table +117 Brewing stand +118 Cauldron +119 End Portal +120 End Portal Frame +121 White Stone +256 Iron Shovel +257 Iron Pickaxe +258 Iron Axe +259 Flint and Steel +260 Apple +261 Bow +262 Arrow +263 Coal +264 Diamond +265 Iron Ingot +266 Gold Ingot +267 Iron Sword +268 Wooden Sword +269 Wooden Shovel +270 Wooden Pickaxe +271 Wooden Axe +272 Stone Sword +273 Stone Shovel +274 Stone Pickaxe +275 Stone Axe +276 Diamond Sword +277 Diamond Shovel +278 Diamond Pickaxe +279 Diamond Axe +280 Stick +281 Bowl +282 Mushroom Stew +283 Golden Sword +284 Golden Shovel +285 Golden Pickaxe +286 Golden Axe +287 String +288 Feather +289 Gunpowder +290 Wooden Hoe +291 Stone Hoe +292 Iron Hoe +293 Diamond Hoe +294 Golden Hoe +295 Seeds +296 Wheat +297 Bread +298 Leather Cap +299 Leather Tunic +300 Leather Pants +301 Leather Boots +302 Chain Helmet +303 Chain Chestplate +304 Chain Leggings +305 Chain Boots +306 Iron Helmet +307 Iron Chestplate +308 Iron Leggings +309 Iron Boots +310 Diamond Helmet +311 Diamond Chestplate +312 Diamond Leggings +313 Diamond Boots +314 Golden Helmet +315 Golden Chestplate +316 Golden Leggings +317 Golden boots +318 Flint +319 Raw Porkchop +320 Cooked Porkchop +321 Painting +322 Golden Apple +323 Sign +324 Wooden Door +325 Bucket +326 Water Bucket +327 Lava bucket +328 Minecart +329 Saddle +330 Iron Door +331 Redstone +332 Snowball +333 Boat +334 Leather +335 Milk +336 Brick +337 Clay +338 Sugar Canes +339 Paper +340 Book +341 Slimeball +342 Minecart with Chest +343 Minecart with Furnace +344 Egg +345 Compass +346 Fishing Rod +347 Clock +348 Glowstone Dust +349 Raw Fish +350 Cooked Fish +351 Dye +352 Bone +353 Sugar +354 Cake +355 Bed +356 Redstone Repeater +357 Cookie +358 Map +359 Shears +360 Melon +361 Pumpkin Seeds +362 Melon Seeds +363 Raw Beef +364 Steak +365 Raw Chicken +366 Cooked Chicken +367 Rotten Flesh +368 Ender Pearl +369 Blaze Rod +370 Ghast Tear +371 Gold Nugget +372 Nether Wart +373 Potion +374 Glass Bottle +375 Spider Eye +376 Fermented Spider Eye +377 Blaze Powder +378 Magma Cream +379 Brewing Stand +380 Cauldron +381 Eye of Ender +382 Glistering Melon +2256 Music Disc 13 +2257 Music Disc Cat +2258 Music Disc Blocks +2259 Music Disc Chirp +2260 Music Disc Far +2261 Music Disc Mall +2262 Music Disc Mellohi +2263 Music Disc Stal +2264 Music Disc Strad +2265 Music Disc Ward +2266 Music Disc 11 +373:16 Awkward Potion +373:32 Thick Potion +373:64 Mundane Potion +373:8193 Regeneration Potion (0:45) +373:8194 Swiftness Potion (3:00) +373:8195 Fire Resistance Potion (3:00) +373:8196 Poison Potion (0:45) +373:8197 Healing Potion +373:8200 Weakness Potion (1:30) +373:8201 Strength Potion (3:00) +373:8202 Slowness Potion (1:30) +373:8204 Harming Potion +373:8225 Regeneration Potion II (0:22) +373:8226 Swiftness Potion II (1:30) +373:8228 Poison Potion II (0:22) +373:8229 Healing Potion II +373:8233 Strength Potion II (1:30) +373:8236 Harming Potion II +373:8257 Regeneration Potion (2:00) +373:8258 Swiftness Potion (8:00) +373:8259 Fire Resistance Potion (8:00) +373:8260 Poison Potion (2:00) +373:8264 Weakness Potion (4:00) +373:8265 Strength Potion (8:00) +373:8266 Slowness Potion (4:00) +373:16378 Fire Resistance Splash (2:15) +373:16385 Regeneration Splash (0:33) +373:16386 Swiftness Splash (2:15) +373:16388 Poison Splash (0:33) +373:16389 Healing Splash +373:16392 Weakness Splash (1:07) +373:16393 Strength Splash (2:15) +373:16394 Slowness Splash (1:07) +373:16396 Harming Splash +373:16418 Swiftness Splash II (1:07) +373:16420 Poison Splash II (0:16) +373:16421 Healing Splash II +373:16425 Strength Splash II (1:07) +373:16428 Harming Splash II +373:16449 Regeneration Splash (1:30) +373:16450 Swiftness Splash (6:00) +373:16451 Fire Resistance Splash (6:00) +373:16452 Poison Splash (1:30) +373:16456 Weakness Splash (3:00) +373:16457 Strength Splash (6:00) +373:16458 Slowness Splash (3:00) +373:16471 Regeneration Splash II (0:16) diff --git a/plugins/data/recipes.txt b/plugins/data/recipes.txt new file mode 100644 index 0000000..e69de29 diff --git a/plugins/mcitems.py b/plugins/mcitems.py new file mode 100644 index 0000000..adf20c8 --- /dev/null +++ b/plugins/mcitems.py @@ -0,0 +1,99 @@ +""" plugin by _303 (?) + pulled from by lukeroge +""" + +from util import hook +import re +import itertools + +pattern = re.compile(r'^(?P\d+)x (?P.+?): (?P.*)$') + +recipelist = [] + +class Recipe(object): + __slots__ = 'output', 'count', 'ingredients', 'line' + + def __init__(self, output, count, ingredients, line): + self.output = output + self.count = count + self.ingredients = ingredients + self.line = line + + def __str__(self): + return self.line + +with open("./plugins/data/recipes.txt") as f: + for line in f.readlines(): + line = line.strip() + match = pattern.match(line) + if not match: + continue + recipelist.append(Recipe(line=line, + output=match.group("name").lower(), + ingredients=match.group("ingredients"), + count=match.group("count"))) + +ids = [] + +with open("./plugins/data/itemids.txt") as f: + for line in f.readlines(): + parts = line.strip().split() + id = parts[0] + name = " ".join(parts[1:]) + ids.append((id,name)) + +@hook.command +def itemid(input, reply=None): + ".itemid -- gets the id from an item or vice versa" + input = input.lower().strip() + + + all = False + limit = 4 + parts = input.split() + + if parts[0] == "-all": + all = True + input = " ".join(parts[1:]) + + if input == "": + reply("no input") + return + + results = [] + + for id, name in ids: + if input == id or input in name.lower(): + results.append("%s %s" % (id, name)) + + if not len(results): + reply("no matches found") + return + + if not all and len(results) > limit: + reply("Displaying %d of %d matches, use -all to get all." % (limit, len(results))) + + for result in results if all else itertools.islice(results, limit): + reply(result) + + + +@hook.command +def recipe(input, reply=None): + ".recipe -- gets the crafting recipe for an item" + input = input.lower().strip() + + results = [] + + for recipe in recipelist: + if input in recipe.output: + results.append(recipe.line) + + if not len(results): + reply("no matches found") + return + + for result in results: + reply(result) + + From 4c39506b76fd71d443f4f0720cf07ba7ef3725e1 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Mon, 19 Mar 2012 12:35:20 +1300 Subject: [PATCH 070/205] Update plugins/dice.py --- plugins/dice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/dice.py b/plugins/dice.py index dd2ee2f..b32bb2d 100755 --- a/plugins/dice.py +++ b/plugins/dice.py @@ -9,7 +9,7 @@ from util import hook whitespace_re = re.compile(r'\s+') -valid_diceroll = r'^([+-]?(?:\d+|\d*d(?:\d+|F))(?:[+-](?:\d+|\d*d(?:\d+|' \ +valid_diceroll = r'^([+-]?(?:\d+|\d*d(?:\d+|F))(?:[+-](?:\d+|\d*d(?:\d+|' 'F)))*)( .+)?$' valid_diceroll_re = re.compile(valid_diceroll, re.I) sign_re = re.compile(r'[+-]?(?:\d*d)?(?:\d+|F)', re.I) @@ -37,7 +37,7 @@ def nrolls(count, n): #@hook.regex(valid_diceroll, re.I) @hook.command def dice(inp): - ".dice -- Simulates dicerolls. Example of :" \ + ".dice -- Simulates dicerolls. Example of :" " '.dice 2d20-d5+4 roll 2'. D20s, subtract 1D5, add 4" try: # if inp is a re.match object... From 9802e415bd1e36f150c6d3c6f49bd1c649e8f129 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 19 Mar 2012 15:26:31 +1300 Subject: [PATCH 071/205] UBERFACEPALM --- core/main.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/main.py b/core/main.py index 09e4e66..041d67e 100755 --- a/core/main.py +++ b/core/main.py @@ -34,9 +34,6 @@ class Input(dict): def notice(msg): conn.cmd('NOTICE', [nick, msg]) - def raw(command): - conn.send(command) - dict.__init__(self, conn=conn, raw=raw, prefix=prefix, command=command, params=params, nick=nick, user=user, host=host, paraml=paraml, msg=msg, server=conn.server, chan=chan, From efc52eb554ed397120647d0d60accc7ef0073afd Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 19 Mar 2012 15:31:19 +1300 Subject: [PATCH 072/205] Reverted earlier bugfix - this causes more issues then it solves --- core/irc.py | 1 - 1 file changed, 1 deletion(-) diff --git a/core/irc.py b/core/irc.py index c7fdfe1..b14c828 100755 --- a/core/irc.py +++ b/core/irc.py @@ -180,7 +180,6 @@ class IRC(object): def set_nick(self, nick): self.cmd("NICK", [nick]) - self.nick = nick def join(self, channel): self.cmd("JOIN", [channel]) From 51ccb3e84494f000d1deedb5d7a71a60fbcc119d Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 19 Mar 2012 15:50:18 +1300 Subject: [PATCH 073/205] More lukederps --- plugins/data/recipes.txt | 161 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) diff --git a/plugins/data/recipes.txt b/plugins/data/recipes.txt index e69de29..bca8151 100644 --- a/plugins/data/recipes.txt +++ b/plugins/data/recipes.txt @@ -0,0 +1,161 @@ +1x Wooden Pickaxe: Wooden Planks, Wooden Planks, Wooden Planks | None, Stick, None | None, Stick, None +1x Stone Pickaxe: Cobblestone, Cobblestone, Cobblestone | None, Stick, None | None, Stick, None +1x Iron Pickaxe: Iron Ingot, Iron Ingot, Iron Ingot | None, Stick, None | None, Stick, None +1x Diamond Pickaxe: Diamond, Diamond, Diamond | None, Stick, None | None, Stick, None +1x Golden Pickaxe: Gold Ingot, Gold Ingot, Gold Ingot | None, Stick, None | None, Stick, None +1x Bow: None, Stick, String | Stick, None, String | None, Stick, String +1x Block of Gold: Gold Ingot, Gold Ingot, Gold Ingot | Gold Ingot, Gold Ingot, Gold Ingot | Gold Ingot, Gold Ingot, Gold Ingot +1x Block of Iron: Iron Ingot, Iron Ingot, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot +1x Block of Diamond: Diamond, Diamond, Diamond | Diamond, Diamond, Diamond | Diamond, Diamond, Diamond +1x Lapis Lazuli Block: Lapis Lazuli, Lapis Lazuli, Lapis Lazuli | Lapis Lazuli, Lapis Lazuli, Lapis Lazuli | Lapis Lazuli, Lapis Lazuli, Lapis Lazuli +1x Melon: Melon, Melon, Melon | Melon, Melon, Melon | Melon, Melon, Melon +1x Chest: Wooden Planks, Wooden Planks, Wooden Planks | Wooden Planks, None, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks +1x Furnace: Cobblestone, Cobblestone, Cobblestone | Cobblestone, None, Cobblestone | Cobblestone, Cobblestone, Cobblestone +1x Leather Tunic: Leather, None, Leather | Leather, Leather, Leather | Leather, Leather, Leather +1x Leather Pants: Leather, Leather, Leather | Leather, None, Leather | Leather, None, Leather +1x Chain Chestplate: Fire, None, Fire | Fire, Fire, Fire | Fire, Fire, Fire +1x Chain Leggings: Fire, Fire, Fire | Fire, None, Fire | Fire, None, Fire +1x Iron Chestplate: Iron Ingot, None, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot +1x Iron Leggings: Iron Ingot, Iron Ingot, Iron Ingot | Iron Ingot, None, Iron Ingot | Iron Ingot, None, Iron Ingot +1x Diamond Chestplate: Diamond, None, Diamond | Diamond, Diamond, Diamond | Diamond, Diamond, Diamond +1x Diamond Leggings: Diamond, Diamond, Diamond | Diamond, None, Diamond | Diamond, None, Diamond +1x Golden Chestplate: Gold Ingot, None, Gold Ingot | Gold Ingot, Gold Ingot, Gold Ingot | Gold Ingot, Gold Ingot, Gold Ingot +1x Golden Leggings: Gold Ingot, Gold Ingot, Gold Ingot | Gold Ingot, None, Gold Ingot | Gold Ingot, None, Gold Ingot +1x Jukebox: Wooden Planks, Wooden Planks, Wooden Planks | Wooden Planks, Diamond, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks +1x Note Block: Wooden Planks, Wooden Planks, Wooden Planks | Wooden Planks, Redstone, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks +1x Bookshelf: Wooden Planks, Wooden Planks, Wooden Planks | Book, Book, Book | Wooden Planks, Wooden Planks, Wooden Planks +1x TNT: Gunpowder, Sand, Gunpowder | Sand, Gunpowder, Sand | Gunpowder, Sand, Gunpowder +2x Ladder: Stick, None, Stick | Stick, Stick, Stick | Stick, None, Stick +1x Sign: Wooden Planks, Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks | None, Stick, None +1x Cake: Milk, Milk, Milk | Sugar, Egg, Sugar | Wheat, Wheat, Wheat +16x Rail: Iron Ingot, None, Iron Ingot | Iron Ingot, Stick, Iron Ingot | Iron Ingot, None, Iron Ingot +6x Powered Rail: Gold Ingot, None, Gold Ingot | Gold Ingot, Stick, Gold Ingot | Gold Ingot, Redstone, Gold Ingot +6x Detector Rail: Iron Ingot, None, Iron Ingot | Iron Ingot, Pressure Plate, Iron Ingot | Iron Ingot, Redstone, Iron Ingot +4x Wooden Stairs: Wooden Planks, None, None | Wooden Planks, Wooden Planks, None | Wooden Planks, Wooden Planks, Wooden Planks +1x Fishing Rod: None, None, Stick | None, Stick, String | Stick, None, String +4x Stone Stairs: Cobblestone, None, None | Cobblestone, Cobblestone, None | Cobblestone, Cobblestone, Cobblestone +4x Brick Stairs: Bricks, None, None | Bricks, Bricks, None | Bricks, Bricks, Bricks +4x Stone Brick Stairs: Stone Bricks, None, None | Stone Bricks, Stone Bricks, None | Stone Bricks, Stone Bricks, Stone Bricks +1x Painting: Stick, Stick, Stick | Stick, Black Wool, Stick | Stick, Stick, Stick +1x Golden Apple: Block of Gold, Block of Gold, Block of Gold | Block of Gold, Apple, Block of Gold | Block of Gold, Block of Gold, Block of Gold +1x Clock: None, Gold Ingot, None | Gold Ingot, Redstone, Gold Ingot | None, Gold Ingot, None +1x Compass: None, Iron Ingot, None | Iron Ingot, Redstone, Iron Ingot | None, Iron Ingot, None +1x Map: Paper, Paper, Paper | Paper, Compass, Paper | Paper, Paper, Paper +1x Dispenser: Cobblestone, Cobblestone, Cobblestone | Cobblestone, Bow, Cobblestone | Cobblestone, Redstone, Cobblestone +1x Piston: Wooden Planks, Wooden Planks, Wooden Planks | Cobblestone, Iron Ingot, Cobblestone | Cobblestone, Redstone, Cobblestone +1x Wooden Axe: Wooden Planks, Wooden Planks | Wooden Planks, Stick | None, Stick +1x Wooden Hoe: Wooden Planks, Wooden Planks | None, Stick | None, Stick +1x Stone Axe: Cobblestone, Cobblestone | Cobblestone, Stick | None, Stick +1x Stone Hoe: Cobblestone, Cobblestone | None, Stick | None, Stick +1x Iron Axe: Iron Ingot, Iron Ingot | Iron Ingot, Stick | None, Stick +1x Iron Hoe: Iron Ingot, Iron Ingot | None, Stick | None, Stick +1x Diamond Axe: Diamond, Diamond | Diamond, Stick | None, Stick +1x Diamond Hoe: Diamond, Diamond | None, Stick | None, Stick +1x Golden Axe: Gold Ingot, Gold Ingot | Gold Ingot, Stick | None, Stick +1x Golden Hoe: Gold Ingot, Gold Ingot | None, Stick | None, Stick +16x Iron Bars: Iron Ingot, Iron Ingot, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot +16x Glass Pane: Glass, Glass, Glass | Glass, Glass, Glass +1x Leather Cap: Leather, Leather, Leather | Leather, None, Leather +1x Leather Boots: Leather, None, Leather | Leather, None, Leather +1x Chain Helmet: Fire, Fire, Fire | Fire, None, Fire +1x Chain Boots: Fire, None, Fire | Fire, None, Fire +1x Iron Helmet: Iron Ingot, Iron Ingot, Iron Ingot | Iron Ingot, None, Iron Ingot +1x Iron Boots: Iron Ingot, None, Iron Ingot | Iron Ingot, None, Iron Ingot +1x Diamond Helmet: Diamond, Diamond, Diamond | Diamond, None, Diamond +1x Diamond Boots: Diamond, None, Diamond | Diamond, None, Diamond +1x Golden Helmet: Gold Ingot, Gold Ingot, Gold Ingot | Gold Ingot, None, Gold Ingot +1x Golden boots: Gold Ingot, None, Gold Ingot | Gold Ingot, None, Gold Ingot +2x Fence: Stick, Stick, Stick | Stick, Stick, Stick +1x Fence Gate: Stick, Wooden Planks, Stick | Stick, Wooden Planks, Stick +1x Wooden Door: Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks +2x Trapdoor: Wooden Planks, Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks +1x Iron Door: Iron Ingot, Iron Ingot | Iron Ingot, Iron Ingot | Iron Ingot, Iron Ingot +4x Bowl: Wooden Planks, None, Wooden Planks | None, Wooden Planks, None +1x Minecart: Iron Ingot, None, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot +1x Boat: Wooden Planks, None, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks +1x Bucket: Iron Ingot, None, Iron Ingot | None, Iron Ingot, None +1x Redstone Repeater: Redstone Torch, Redstone, Redstone Torch | Stone, Stone, Stone +1x Bed: Black Wool, Black Wool, Black Wool | Wooden Planks, Wooden Planks, Wooden Planks +1x Shears: None, Iron Ingot | Iron Ingot, None +1x Crafting Table: Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks +1x Sandstone: Sand, Sand | Sand, Sand +4x Stone Bricks: Stone, Stone | Stone, Stone +1x Snow: Snowball, Snowball | Snowball, Snowball +1x Clay: Clay, Clay | Clay, Clay +1x Bricks: Brick, Brick | Brick, Brick +1x Glowstone: Glowstone Dust, Glowstone Dust | Glowstone Dust, Glowstone Dust +1x Wool: String, String | String, String +1x Flint and Steel: Iron Ingot, None | None, Flint +1x Wooden Shovel: Wooden Planks | Stick | Stick +1x Stone Shovel: Cobblestone | Stick | Stick +1x Iron Shovel: Iron Ingot | Stick | Stick +1x Diamond Shovel: Diamond | Stick | Stick +1x Golden Shovel: Gold Ingot | Stick | Stick +1x Wooden Sword: Wooden Planks | Wooden Planks | Stick +1x Stone Sword: Cobblestone | Cobblestone | Stick +1x Iron Sword: Iron Ingot | Iron Ingot | Stick +1x Diamond Sword: Diamond | Diamond | Stick +1x Golden Sword: Gold Ingot | Gold Ingot | Stick +4x Arrow: Flint | Stick | Feather +1x Mushroom Stew: Mushroom | Mushroom | Bowl +1x Mushroom Stew: Mushroom | Mushroom | Bowl +8x Cookie: Wheat, Cocoa Beans, Wheat +3x Paper: Sugar Canes, Sugar Canes, Sugar Canes +1x Book: Paper | Paper | Paper +3x Cobblestone Slab: Cobblestone, Cobblestone, Cobblestone +3x Stone Slab: Stone, Stone, Stone +3x Sandstone Slab: Sandstone, Sandstone, Sandstone +3x Wooden Slab: Wooden Planks, Wooden Planks, Wooden Planks +3x Bricks Slab: Bricks, Bricks, Bricks +3x Stone Bricks Slab: Stone Bricks, Stone Bricks, Stone Bricks +1x Bread: Wheat, Wheat, Wheat +4x Stick: Wooden Planks | Wooden Planks +4x Torch: Coal | Stick +4x Torch: Charcoal | Stick +1x Jack 'o' Lantern: Pumpkin | Torch +1x Minecart with Chest: Chest | Minecart +1x Minecart with Furnace: Furnace | Minecart +1x Lever: Stick | Cobblestone +1x Redstone Torch: Redstone | Stick +1x Button: Stone | Stone +1x Pressure Plate: Stone, Stone +1x Pressure Plate: Wooden Planks, Wooden Planks +1x Sticky Piston: Slimeball | Piston +9x Gold Ingot: Block of Gold +9x Iron Ingot: Block of Iron +9x Diamond: Block of Diamond +9x Lapis Lazuli: Lapis Lazuli Block +1x Melon Seeds: Melon +1x Sugar: Sugar Canes +4x Wooden Planks: Wood +4x Magenta Dye: Lapis Lazuli, Rose Red, Rose Red, Bone Meal +3x Light Gray Dye: Ink Sac, Bone Meal, Bone Meal +3x Magenta Dye: Lapis Lazuli, Rose Red, Pink Dye +1x Black Wool: Ink Sac, Wool +1x Red Wool: Rose Red, Wool +1x Green Wool: Cactus Green, Wool +1x Brown Wool: Cocoa Beans, Wool +1x Blue Wool: Lapis Lazuli, Wool +1x Purple Wool: Purple Dye, Wool +1x Cyan Wool: Cyan Dye, Wool +1x Light Gray Wool: Light Gray Dye, Wool +1x Gray Wool: Gray Dye, Wool +1x Pink Wool: Pink Dye, Wool +1x Lime Wool: Lime Dye, Wool +1x Yellow Wool: Dandelion Yellow, Wool +1x Light Blue Wool: Light Blue Dye, Wool +1x Magenta Wool: Magenta Dye, Wool +1x Orange Wool: Orange Dye, Wool +1x Wool: Bone Meal, Wool +2x Pink Dye: Rose Red, Bone Meal +2x Orange Dye: Rose Red, Dandelion Yellow +2x Lime Dye: Cactus Green, Bone Meal +2x Gray Dye: Ink Sac, Bone Meal +2x Light Gray Dye: Gray Dye, Bone Meal +2x Light Blue Dye: Lapis Lazuli, Bone Meal +2x Cyan Dye: Lapis Lazuli, Cactus Green +2x Purple Dye: Lapis Lazuli, Rose Red +2x Magenta Dye: Purple Dye, Pink Dye +2x Dandelion Yellow: Flower +2x Rose Red: Rose +3x Bone Meal: Bone From 1a1e1f8479a99217a77977bbbef78cc128baa4f7 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 19 Mar 2012 15:57:43 +1300 Subject: [PATCH 074/205] Fixed up spammy commands --- plugins/mcitems.py | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/plugins/mcitems.py b/plugins/mcitems.py index adf20c8..5c3b758 100644 --- a/plugins/mcitems.py +++ b/plugins/mcitems.py @@ -47,37 +47,30 @@ def itemid(input, reply=None): ".itemid -- gets the id from an item or vice versa" input = input.lower().strip() - - all = False - limit = 4 - parts = input.split() - - if parts[0] == "-all": - all = True - input = " ".join(parts[1:]) - if input == "": - reply("no input") + reply("No input.") return results = [] for id, name in ids: if input == id or input in name.lower(): - results.append("%s %s" % (id, name)) + results.append("\x02[%s]\x02 %s" % (id, name)) if not len(results): - reply("no matches found") + reply("No matches found.") return - - if not all and len(results) > limit: - reply("Displaying %d of %d matches, use -all to get all." % (limit, len(results))) - - for result in results if all else itertools.islice(results, limit): - reply(result) - + + out = ", ".join(results) + + if len(out) > 200: + out = out[:out.rfind(' ')] + '...' + + return out + +@hook.command("crafting") @hook.command def recipe(input, reply=None): ".recipe -- gets the crafting recipe for an item" @@ -90,7 +83,11 @@ def recipe(input, reply=None): results.append(recipe.line) if not len(results): - reply("no matches found") + reply("No matches found.") + return + + if len(results) > 3: + reply("Too many results (%s)" % len(results)) return for result in results: From 8538d2a6760004ec554fce59eaf999792befc259 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sun, 18 Mar 2012 20:07:10 -0700 Subject: [PATCH 075/205] Tweaked error messages in mcitems.py --- plugins/mcitems.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/mcitems.py b/plugins/mcitems.py index 5c3b758..2fbb92c 100644 --- a/plugins/mcitems.py +++ b/plugins/mcitems.py @@ -48,7 +48,7 @@ def itemid(input, reply=None): input = input.lower().strip() if input == "": - reply("No input.") + reply("error: no input.") return results = [] @@ -58,7 +58,7 @@ def itemid(input, reply=None): results.append("\x02[%s]\x02 %s" % (id, name)) if not len(results): - reply("No matches found.") + reply("error: No matches found.") return out = ", ".join(results) @@ -83,11 +83,11 @@ def recipe(input, reply=None): results.append(recipe.line) if not len(results): - reply("No matches found.") + reply("error: no matches found.") return if len(results) > 3: - reply("Too many results (%s)" % len(results)) + reply("error: too many results (%s)" % len(results)) return for result in results: From 9161fae6d6ae2cd8d3cce51e4974e2950280cd52 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sun, 18 Mar 2012 20:09:26 -0700 Subject: [PATCH 076/205] Fixed help message in mctools.py --- plugins/mctools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mctools.py b/plugins/mctools.py index f70bb73..399c4fd 100755 --- a/plugins/mctools.py +++ b/plugins/mctools.py @@ -62,7 +62,7 @@ from util import hook @hook.command def mcping(inp): - ".mcping server[:port] - Ping a Minecraft server to check status." + ".mcping [:port] - Ping a Minecraft server to check status." inp = inp.strip().split(" ")[0] if ":" in inp: @@ -70,7 +70,7 @@ def mcping(inp): try: port = int(port) except: - return "Invalid port!" + return "error: invalid port!" else: host = inp port = 25565 From 03f82203e14a7d6983071fbbb0c5261b9b6bf7d7 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 19 Mar 2012 23:31:54 +1300 Subject: [PATCH 077/205] small plugin tweaks --- plugins/dice.py | 2 +- plugins/twitter.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/dice.py b/plugins/dice.py index b32bb2d..d5aff31 100755 --- a/plugins/dice.py +++ b/plugins/dice.py @@ -9,7 +9,7 @@ from util import hook whitespace_re = re.compile(r'\s+') -valid_diceroll = r'^([+-]?(?:\d+|\d*d(?:\d+|F))(?:[+-](?:\d+|\d*d(?:\d+|' +valid_diceroll = r'^([+-]?(?:\d+|\d*d(?:\d+|F))(?:[+-](?:\d+|\d*d(?:\d+|' \ 'F)))*)( .+)?$' valid_diceroll_re = re.compile(valid_diceroll, re.I) sign_re = re.compile(r'[+-]?(?:\d*d)?(?:\d+|F)', re.I) diff --git a/plugins/twitter.py b/plugins/twitter.py index 076de72..7acaa19 100755 --- a/plugins/twitter.py +++ b/plugins/twitter.py @@ -159,4 +159,4 @@ def twitter(inp): text = unescape_xml(tweet.find(text).text.replace('\n', '')) screen_name = tweet.find(screen_name).text - return "\x02@%s\x02: %s [ %s ago ]" % (screen_name, text, time_pretty) + return "\x02@%s\x02: %s (%s ago)" % (screen_name, text, time_pretty) From 988d46d797aeed5bacce5c88fe4e3384759ab04d Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 20 Mar 2012 00:14:20 +1300 Subject: [PATCH 078/205] Tweaks to admin.py + new command --- plugins/admin.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index b2d66be..4a92cd3 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -7,16 +7,22 @@ import time import re -@hook.command("owners", autohelp=False) @hook.command(autohelp=False) def admins(inp, bot=None): ".admins -- Lists the bot's admins." admins = bot.config["admins"] return ", ".join(admins) + + +@hook.command(autohelp=False) +def channels(inp, conn=None): + ".channels -- Lists the channels that the bot is in." + channels = conn.channels + return "I am in these channels: " + ", ".join(channels) @hook.command(autohelp=False, adminonly=True) -def stop(inp, input=None, db=None, notice=None): +def stop(inp, input=None): ".stop [reason] -- Kills the bot with [reason] as its quit message." if inp: input.conn.send("QUIT :Killed by " + input.nick + " (" + inp + ")") @@ -28,7 +34,7 @@ def stop(inp, input=None, db=None, notice=None): @hook.command("reboot", autohelp=False, adminonly=True) @hook.command(autohelp=False, adminonly=True) -def restart(inp, input=None, db=None, notice=None): +def restart(inp, input=None): ".restart [reason] -- Restarts the bot with [reason] as its quit message." if inp: input.conn.send("QUIT :Restarted by " + input.nick + " (" + inp + ")") @@ -40,14 +46,14 @@ def restart(inp, input=None, db=None, notice=None): @hook.command("clearlogs", autohelp=False, adminonly=True) @hook.command(autohelp=False, adminonly=True) -def clear(inp, input=None, db=None, notice=None): +def clear(inp, input=None): ".clear -- Clears the bots log(s)." time.sleep(5) subprocess.call("./cloudbot clear", shell=True) @hook.command(adminonly=True) -def join(inp, input=None, db=None, notice=None): +def join(inp, input=None, notice=None): ".join -- Joins ." notice("Attempting to join " + inp + "...") input.conn.send("JOIN " + inp) @@ -74,7 +80,7 @@ def nick(inp, input=None, notice=None, set_nick=None): if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): notice("Invalid username!") return - notice("Changing nick to " + inp + ".") + notice("Attempting to change nick to " + inp + ".") set_nick(inp) From 304be8fd2658fe663fa0e9ed0bfb9148234b4a86 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 20 Mar 2012 09:01:31 +1300 Subject: [PATCH 079/205] improved .urban --- plugins/dictionary.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/plugins/dictionary.py b/plugins/dictionary.py index 84f9982..ca9d50f 100755 --- a/plugins/dictionary.py +++ b/plugins/dictionary.py @@ -6,16 +6,34 @@ from util import hook, http @hook.command('u') @hook.command def urban(inp): - ".urban -- Looks up on urbandictionary.com." + ".urban [id] -- Looks up on urbandictionary.com." + + # set a default definition number + id = 1 + + # clean and split the input + input = inp.lower().strip() + parts = input.split() + + # if the last word is a number, set the ID to that number + if parts[-1].isdigit(): + id = int(parts[-1]) + del parts[-1] + input = " ".join(parts) url = 'http://www.urbandictionary.com/iphone/search/define' - page = http.get_json(url, term=inp) + page = http.get_json(url, term=input) defs = page['list'] if page['result_type'] == 'no_results': return 'Not found.' - - out = defs[0]['word'] + ': ' + defs[0]['definition'] + + # try getting the requested definition + try: + out = "(%s/%s) %s: %s" % \ + (str(id), str(len(defs)), defs[id-1]['word'], defs[id-1]['definition']) + except IndexError: + return 'Not found.' if len(out) > 400: out = out[:out.rfind(' ', 0, 400)] + '...' From 35c1a159f00870a7bc3f9cdfe72dc6176a8ed0c2 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Tue, 20 Mar 2012 11:25:33 +1300 Subject: [PATCH 080/205] Changed gold block to nugget --- plugins/data/recipes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/data/recipes.txt b/plugins/data/recipes.txt index bca8151..c0b8fa4 100644 --- a/plugins/data/recipes.txt +++ b/plugins/data/recipes.txt @@ -37,7 +37,7 @@ 4x Brick Stairs: Bricks, None, None | Bricks, Bricks, None | Bricks, Bricks, Bricks 4x Stone Brick Stairs: Stone Bricks, None, None | Stone Bricks, Stone Bricks, None | Stone Bricks, Stone Bricks, Stone Bricks 1x Painting: Stick, Stick, Stick | Stick, Black Wool, Stick | Stick, Stick, Stick -1x Golden Apple: Block of Gold, Block of Gold, Block of Gold | Block of Gold, Apple, Block of Gold | Block of Gold, Block of Gold, Block of Gold +1x Golden Apple: Gold Nugget, Gold Nugget, Gold Nugget | Gold Nugget, Apple, Gold Nugget | Gold Nugget, Gold Nugget, Gold Nugget 1x Clock: None, Gold Ingot, None | Gold Ingot, Redstone, Gold Ingot | None, Gold Ingot, None 1x Compass: None, Iron Ingot, None | Iron Ingot, Redstone, Iron Ingot | None, Iron Ingot, None 1x Map: Paper, Paper, Paper | Paper, Compass, Paper | Paper, Paper, Paper From ec1c491918b51fcb669767ff5277fa33616b9783 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Tue, 20 Mar 2012 11:31:49 +1300 Subject: [PATCH 081/205] added nether brick items --- plugins/data/recipes.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/data/recipes.txt b/plugins/data/recipes.txt index c0b8fa4..806ee3c 100644 --- a/plugins/data/recipes.txt +++ b/plugins/data/recipes.txt @@ -1,4 +1,4 @@ -1x Wooden Pickaxe: Wooden Planks, Wooden Planks, Wooden Planks | None, Stick, None | None, Stick, None +n1x Wooden Pickaxe: Wooden Planks, Wooden Planks, Wooden Planks | None, Stick, None | None, Stick, None 1x Stone Pickaxe: Cobblestone, Cobblestone, Cobblestone | None, Stick, None | None, Stick, None 1x Iron Pickaxe: Iron Ingot, Iron Ingot, Iron Ingot | None, Stick, None | None, Stick, None 1x Diamond Pickaxe: Diamond, Diamond, Diamond | None, Stick, None | None, Stick, None @@ -35,6 +35,7 @@ 1x Fishing Rod: None, None, Stick | None, Stick, String | Stick, None, String 4x Stone Stairs: Cobblestone, None, None | Cobblestone, Cobblestone, None | Cobblestone, Cobblestone, Cobblestone 4x Brick Stairs: Bricks, None, None | Bricks, Bricks, None | Bricks, Bricks, Bricks +4x Nether Brick Stairs: Nether Bricks, None, None | Nether Bricks, Nether Bricks, None | Nether Bricks, Nether Bricks, Nether Bricks 4x Stone Brick Stairs: Stone Bricks, None, None | Stone Bricks, Stone Bricks, None | Stone Bricks, Stone Bricks, Stone Bricks 1x Painting: Stick, Stick, Stick | Stick, Black Wool, Stick | Stick, Stick, Stick 1x Golden Apple: Gold Nugget, Gold Nugget, Gold Nugget | Gold Nugget, Apple, Gold Nugget | Gold Nugget, Gold Nugget, Gold Nugget @@ -66,6 +67,7 @@ 1x Golden Helmet: Gold Ingot, Gold Ingot, Gold Ingot | Gold Ingot, None, Gold Ingot 1x Golden boots: Gold Ingot, None, Gold Ingot | Gold Ingot, None, Gold Ingot 2x Fence: Stick, Stick, Stick | Stick, Stick, Stick +2x Nether Brick Fence: Nether Brick, Nether Brick, Nether Brick | Nether Brick, Nether Brick, Nether Brick 1x Fence Gate: Stick, Wooden Planks, Stick | Stick, Wooden Planks, Stick 1x Wooden Door: Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks 2x Trapdoor: Wooden Planks, Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks From fd4e605ffa76bef52696b54b4a1bd3f7713703cb Mon Sep 17 00:00:00 2001 From: lukeroge Date: Tue, 20 Mar 2012 11:33:00 +1300 Subject: [PATCH 082/205] Fixed derp --- plugins/data/recipes.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/data/recipes.txt b/plugins/data/recipes.txt index 806ee3c..13050c8 100644 --- a/plugins/data/recipes.txt +++ b/plugins/data/recipes.txt @@ -1,4 +1,4 @@ -n1x Wooden Pickaxe: Wooden Planks, Wooden Planks, Wooden Planks | None, Stick, None | None, Stick, None +1x Wooden Pickaxe: Wooden Planks, Wooden Planks, Wooden Planks | None, Stick, None | None, Stick, None 1x Stone Pickaxe: Cobblestone, Cobblestone, Cobblestone | None, Stick, None | None, Stick, None 1x Iron Pickaxe: Iron Ingot, Iron Ingot, Iron Ingot | None, Stick, None | None, Stick, None 1x Diamond Pickaxe: Diamond, Diamond, Diamond | None, Stick, None | None, Stick, None @@ -65,7 +65,7 @@ n1x Wooden Pickaxe: Wooden Planks, Wooden Planks, Wooden Planks | None, Stick, N 1x Diamond Helmet: Diamond, Diamond, Diamond | Diamond, None, Diamond 1x Diamond Boots: Diamond, None, Diamond | Diamond, None, Diamond 1x Golden Helmet: Gold Ingot, Gold Ingot, Gold Ingot | Gold Ingot, None, Gold Ingot -1x Golden boots: Gold Ingot, None, Gold Ingot | Gold Ingot, None, Gold Ingot +1x Golden Boots: Gold Ingot, None, Gold Ingot | Gold Ingot, None, Gold Ingot 2x Fence: Stick, Stick, Stick | Stick, Stick, Stick 2x Nether Brick Fence: Nether Brick, Nether Brick, Nether Brick | Nether Brick, Nether Brick, Nether Brick 1x Fence Gate: Stick, Wooden Planks, Stick | Stick, Wooden Planks, Stick From e4ba0ea3a9283894c135fed41b73d651932c03f3 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Tue, 20 Mar 2012 11:42:48 +1300 Subject: [PATCH 083/205] 1.0 items part one --- plugins/data/recipes.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/data/recipes.txt b/plugins/data/recipes.txt index 13050c8..acc969d 100644 --- a/plugins/data/recipes.txt +++ b/plugins/data/recipes.txt @@ -99,8 +99,14 @@ 1x Diamond Sword: Diamond | Diamond | Stick 1x Golden Sword: Gold Ingot | Gold Ingot | Stick 4x Arrow: Flint | Stick | Feather -1x Mushroom Stew: Mushroom | Mushroom | Bowl -1x Mushroom Stew: Mushroom | Mushroom | Bowl +1x Mushroom Stew: Brown Mushroom | Red Mushroom | Bowl +1x Fermented Spider Eye: Spider Eye | Brown Mushroom, Sugar +1x Eye of Ender: Blaze Powder | Ender Pearl +1x Glistering Melon: Melon Slice, Gold Nugget +2x Blaze Powder: Blaze Rod +1x Magma Cream: Ender Pearl | Blaze Powder +9x Gold Nugget: Gold Ingot +1x Gold Ingot: Gold Nugget, Gold Nugget, Gold Nugget | Gold Nugget, Gold Nugget, Gold Nugget | Gold Nugget, Gold Nugget, Gold Nugget 8x Cookie: Wheat, Cocoa Beans, Wheat 3x Paper: Sugar Canes, Sugar Canes, Sugar Canes 1x Book: Paper | Paper | Paper From d8a348ff7cc4e718a834ba97a1353e38ef60916c Mon Sep 17 00:00:00 2001 From: lukeroge Date: Tue, 20 Mar 2012 11:49:18 +1300 Subject: [PATCH 084/205] More 1.0+ stuff --- plugins/data/recipes.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/data/recipes.txt b/plugins/data/recipes.txt index acc969d..098c248 100644 --- a/plugins/data/recipes.txt +++ b/plugins/data/recipes.txt @@ -107,6 +107,10 @@ 1x Magma Cream: Ender Pearl | Blaze Powder 9x Gold Nugget: Gold Ingot 1x Gold Ingot: Gold Nugget, Gold Nugget, Gold Nugget | Gold Nugget, Gold Nugget, Gold Nugget | Gold Nugget, Gold Nugget, Gold Nugget +3x Fire Charge: Blaze Powder | Coal/Charcoal | Gunpowder +1x Brewing Stand: None, Blaze Rod, None | Cobblestone, Cobblestone, Cobblestonr +1x Cauldron: Iron Ingot, None, Iron Ingot | Iron Ingot, None, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot +3x Glass Bottle: Glass, None, Glass | None, Glass, None 8x Cookie: Wheat, Cocoa Beans, Wheat 3x Paper: Sugar Canes, Sugar Canes, Sugar Canes 1x Book: Paper | Paper | Paper From 70ca461830d3bf5696bacb187b7bf6fa7796d578 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Tue, 20 Mar 2012 11:56:23 +1300 Subject: [PATCH 085/205] Added redstone lamp --- plugins/data/recipes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/data/recipes.txt b/plugins/data/recipes.txt index 098c248..f96d162 100644 --- a/plugins/data/recipes.txt +++ b/plugins/data/recipes.txt @@ -77,6 +77,7 @@ 1x Boat: Wooden Planks, None, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks 1x Bucket: Iron Ingot, None, Iron Ingot | None, Iron Ingot, None 1x Redstone Repeater: Redstone Torch, Redstone, Redstone Torch | Stone, Stone, Stone +1x Redstone Lamp: None, Redstone, None | Redstone, Glowstone, Redstone | None, Redstone, None 1x Bed: Black Wool, Black Wool, Black Wool | Wooden Planks, Wooden Planks, Wooden Planks 1x Shears: None, Iron Ingot | Iron Ingot, None 1x Crafting Table: Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks From c35f53407af6bb57e9e86ac20f3b6e91eb446ff8 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 20 Mar 2012 15:52:49 +1300 Subject: [PATCH 086/205] updated itemids by _frozen --- plugins/data/itemids.txt | 114 ++++++++++++++++++++++++++++++--------- 1 file changed, 89 insertions(+), 25 deletions(-) diff --git a/plugins/data/itemids.txt b/plugins/data/itemids.txt index 54f4885..917d88f 100644 --- a/plugins/data/itemids.txt +++ b/plugins/data/itemids.txt @@ -1,3 +1,6 @@ +// obtained from +// edited by Lukeroge and _frozen +// Block id 1 Stone 2 Grass Block 3 Dirt @@ -31,13 +34,29 @@ 31 Grass 32 Dead Bush 33 Piston -34 Unknown +34 Piston Extended 35 Wool -36 Unknown +35:1 Orange Wool +35:2 Magenta Wool +35:3 Light Blue Wool +35:4 Yellow Wool +35:5 Lime Wool +35:6 Pink Wool +35:7 Gray Wool +35:8 Light Gray Wool +35:9 Cyan Wool +35:10 Purple Wool +35:11 Blue Wool +35:12 Brown Wool +35:13 Green Wool +35:14 Red Wool +35:15 Black Wool +35:0 White Wool +36 Block Moved by Piston 37 Flower 38 Rose -39 Mushroom -40 Mushroom +39 Brown Mushroom +40 Red Mushroom 41 Block of Gold 42 Block of Iron 43 Double Slabs @@ -118,7 +137,11 @@ 118 Cauldron 119 End Portal 120 End Portal Frame -121 White Stone +121 End Stone +122 Dragon Egg +123 Redstone Lamp (Off) +124 Redstone Lamp (On) +// Items Ids 256 Iron Shovel 257 Iron Pickaxe 258 Iron Axe @@ -215,6 +238,22 @@ 349 Raw Fish 350 Cooked Fish 351 Dye +351:0 Ink Sac +351:1 Rose Red +351:2 Cactus Green +351:3 Cocoa Beans +351:4 Lapis Lazuli +351:5 Purple Dye +351:6 Cyan Dye +351:7 Light Gray Dye +351:8 Gray Dye +351:9 Pink Dye +351:10 Lime Dye +351:11 Dandelion Yellow +351:12 Light Blue Dye +351:13 Magenta Dye +351:14 Orange Dye +351:15 Bone Meal 352 Bone 353 Sugar 354 Cake @@ -237,26 +276,6 @@ 371 Gold Nugget 372 Nether Wart 373 Potion -374 Glass Bottle -375 Spider Eye -376 Fermented Spider Eye -377 Blaze Powder -378 Magma Cream -379 Brewing Stand -380 Cauldron -381 Eye of Ender -382 Glistering Melon -2256 Music Disc 13 -2257 Music Disc Cat -2258 Music Disc Blocks -2259 Music Disc Chirp -2260 Music Disc Far -2261 Music Disc Mall -2262 Music Disc Mellohi -2263 Music Disc Stal -2264 Music Disc Strad -2265 Music Disc Ward -2266 Music Disc 11 373:16 Awkward Potion 373:32 Thick Potion 373:64 Mundane Potion @@ -304,3 +323,48 @@ 373:16457 Strength Splash (6:00) 373:16458 Slowness Splash (3:00) 373:16471 Regeneration Splash II (0:16) +374 Glass Bottle +375 Spider Eye +376 Fermented Spider Eye +377 Blaze Powder +378 Magma Cream +379 Brewing Stand +380 Cauldron +381 Eye of Ender +382 Glistering Melon +383 Spawn Egg +383:50 Creeper Egg +383:51 Skeleton Egg +383:52 Spider Egg +383:54 Zombie Egg +383:55 Slime Egg +383:56 Ghast Egg +383:57 Zombie Pigman Egg +383:58 Enderman Egg +383:59 Cave Spider Egg +383:60 Silverfish Egg +383:61 Blaze Egg +383:62 Magma Cube Egg +383:90 Pig Egg +383:91 Sheep Egg +383:92 Cow Egg +383:93 Chicken Egg +383:94 Squid Egg +383:95 Wolf Egg +383:96 Mooshroom Egg +383:98 Ocelot Egg +383:120 Villager Egg +384 Bottle Of Enchanting +385 Fire Charge +// Records +2256 Music Disc 13 +2257 Music Disc Cat +2258 Music Disc Blocks +2259 Music Disc Chirp +2260 Music Disc Far +2261 Music Disc Mall +2262 Music Disc Mellohi +2263 Music Disc Stal +2264 Music Disc Strad +2265 Music Disc Ward +2266 Music Disc 11 From c06012ffcd74f5ac93e94014d03c712a7db7b2e2 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 20 Mar 2012 15:53:33 +1300 Subject: [PATCH 087/205] added comment support to mcitems.py --- plugins/mcitems.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/mcitems.py b/plugins/mcitems.py index 2fbb92c..588900b 100644 --- a/plugins/mcitems.py +++ b/plugins/mcitems.py @@ -24,6 +24,8 @@ class Recipe(object): with open("./plugins/data/recipes.txt") as f: for line in f.readlines(): + if line.startswith("//"): + continue line = line.strip() match = pattern.match(line) if not match: @@ -37,6 +39,8 @@ ids = [] with open("./plugins/data/itemids.txt") as f: for line in f.readlines(): + if line.startswith("//"): + continue parts = line.strip().split() id = parts[0] name = " ".join(parts[1:]) From ebfb6bd8094fb57aba325eca67f75898a3872875 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 20 Mar 2012 16:10:25 +1300 Subject: [PATCH 088/205] Changed the way mcitems limits stuff --- plugins/mcitems.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/plugins/mcitems.py b/plugins/mcitems.py index 588900b..fb9f905 100644 --- a/plugins/mcitems.py +++ b/plugins/mcitems.py @@ -58,17 +58,21 @@ def itemid(input, reply=None): results = [] for id, name in ids: - if input == id or input in name.lower(): + if input == id: + results = ["\x02[%s]\x02 %s" % (id, name)] + break + elif input in name.lower(): results.append("\x02[%s]\x02 %s" % (id, name)) if not len(results): - reply("error: No matches found.") + reply("No matches found.") + return + + if len(results) > 12: + reply("There are too many options, please narrow your search. (%s)" % len(results)) return out = ", ".join(results) - - if len(out) > 200: - out = out[:out.rfind(' ')] + '...' return out @@ -87,11 +91,11 @@ def recipe(input, reply=None): results.append(recipe.line) if not len(results): - reply("error: no matches found.") + reply("No matches found.") return if len(results) > 3: - reply("error: too many results (%s)" % len(results)) + reply("There are too many options, please narrow your search. (%s)" % len(results)) return for result in results: From 35806b1958a901f65c486878502e3dca0f813741 Mon Sep 17 00:00:00 2001 From: frozen- Date: Mon, 19 Mar 2012 21:51:49 -0700 Subject: [PATCH 089/205] Update & Organized Recipes in accordance to minecraftwiki.net/wiki/crafting for easier future updates --- plugins/data/recipes.txt | 315 ++++++++++++++++++++++----------------- 1 file changed, 179 insertions(+), 136 deletions(-) diff --git a/plugins/data/recipes.txt b/plugins/data/recipes.txt index f96d162..14ce8cf 100644 --- a/plugins/data/recipes.txt +++ b/plugins/data/recipes.txt @@ -1,174 +1,217 @@ -1x Wooden Pickaxe: Wooden Planks, Wooden Planks, Wooden Planks | None, Stick, None | None, Stick, None -1x Stone Pickaxe: Cobblestone, Cobblestone, Cobblestone | None, Stick, None | None, Stick, None -1x Iron Pickaxe: Iron Ingot, Iron Ingot, Iron Ingot | None, Stick, None | None, Stick, None -1x Diamond Pickaxe: Diamond, Diamond, Diamond | None, Stick, None | None, Stick, None -1x Golden Pickaxe: Gold Ingot, Gold Ingot, Gold Ingot | None, Stick, None | None, Stick, None -1x Bow: None, Stick, String | Stick, None, String | None, Stick, String +//Minecraft Recipes List +//Created by _303 +//Obtained from https://github.com/ClouDev/CloudBot/blob/develop/plugins/data/recipes.txt +//Edited by _frozen +// +//Summary of Use: Each column is seperated by a comma (,) and rows by a vertical bar (|). Order of Recipes & Categories taken from +//www.minecraftwiki.net/wiki/Crafting for easier updating in the future (The Future!) +// +//Basic Recipes +// +4x Wooden Planks: Wood +4x Stick: Wooden Planks | Wooden Planks +4x Torch: Coal | Stick +4x Torch: Charcoal | Stick +1x Crafting Table: Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks +1x Furnace: Cobblestone, Cobblestone, Cobblestone | Cobblestone, None, Cobblestone | Cobblestone, Cobblestone, Cobblestone +1x Chest: Wooden Planks, Wooden Planks, Wooden Planks | Wooden Planks, None, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks +// +//Block Recipes +// 1x Block of Gold: Gold Ingot, Gold Ingot, Gold Ingot | Gold Ingot, Gold Ingot, Gold Ingot | Gold Ingot, Gold Ingot, Gold Ingot 1x Block of Iron: Iron Ingot, Iron Ingot, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot 1x Block of Diamond: Diamond, Diamond, Diamond | Diamond, Diamond, Diamond | Diamond, Diamond, Diamond 1x Lapis Lazuli Block: Lapis Lazuli, Lapis Lazuli, Lapis Lazuli | Lapis Lazuli, Lapis Lazuli, Lapis Lazuli | Lapis Lazuli, Lapis Lazuli, Lapis Lazuli -1x Melon: Melon, Melon, Melon | Melon, Melon, Melon | Melon, Melon, Melon -1x Chest: Wooden Planks, Wooden Planks, Wooden Planks | Wooden Planks, None, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks -1x Furnace: Cobblestone, Cobblestone, Cobblestone | Cobblestone, None, Cobblestone | Cobblestone, Cobblestone, Cobblestone -1x Leather Tunic: Leather, None, Leather | Leather, Leather, Leather | Leather, Leather, Leather -1x Leather Pants: Leather, Leather, Leather | Leather, None, Leather | Leather, None, Leather -1x Chain Chestplate: Fire, None, Fire | Fire, Fire, Fire | Fire, Fire, Fire -1x Chain Leggings: Fire, Fire, Fire | Fire, None, Fire | Fire, None, Fire -1x Iron Chestplate: Iron Ingot, None, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot -1x Iron Leggings: Iron Ingot, Iron Ingot, Iron Ingot | Iron Ingot, None, Iron Ingot | Iron Ingot, None, Iron Ingot -1x Diamond Chestplate: Diamond, None, Diamond | Diamond, Diamond, Diamond | Diamond, Diamond, Diamond -1x Diamond Leggings: Diamond, Diamond, Diamond | Diamond, None, Diamond | Diamond, None, Diamond -1x Golden Chestplate: Gold Ingot, None, Gold Ingot | Gold Ingot, Gold Ingot, Gold Ingot | Gold Ingot, Gold Ingot, Gold Ingot -1x Golden Leggings: Gold Ingot, Gold Ingot, Gold Ingot | Gold Ingot, None, Gold Ingot | Gold Ingot, None, Gold Ingot -1x Jukebox: Wooden Planks, Wooden Planks, Wooden Planks | Wooden Planks, Diamond, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks -1x Note Block: Wooden Planks, Wooden Planks, Wooden Planks | Wooden Planks, Redstone, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks -1x Bookshelf: Wooden Planks, Wooden Planks, Wooden Planks | Book, Book, Book | Wooden Planks, Wooden Planks, Wooden Planks +1x Glowstone: Glowstone Dust, Glowstone Dust | Glowstone Dust, Glowstone Dust +1x Wool: String, String | String, String 1x TNT: Gunpowder, Sand, Gunpowder | Sand, Gunpowder, Sand | Gunpowder, Sand, Gunpowder -2x Ladder: Stick, None, Stick | Stick, Stick, Stick | Stick, None, Stick -1x Sign: Wooden Planks, Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks | None, Stick, None -1x Cake: Milk, Milk, Milk | Sugar, Egg, Sugar | Wheat, Wheat, Wheat -16x Rail: Iron Ingot, None, Iron Ingot | Iron Ingot, Stick, Iron Ingot | Iron Ingot, None, Iron Ingot -6x Powered Rail: Gold Ingot, None, Gold Ingot | Gold Ingot, Stick, Gold Ingot | Gold Ingot, Redstone, Gold Ingot -6x Detector Rail: Iron Ingot, None, Iron Ingot | Iron Ingot, Pressure Plate, Iron Ingot | Iron Ingot, Redstone, Iron Ingot +3x Cobblestone Slab: Cobblestone, Cobblestone, Cobblestone +3x Stone Slab: Stone, Stone, Stone +3x Sandstone Slab: Sandstone, Sandstone, Sandstone +3x Wooden Slab: Wooden Planks, Wooden Planks, Wooden Planks +3x Stone Bricks Slab: Stone Bricks, Stone Bricks, Stone Bricks +3x Bricks Slab: Bricks, Bricks, Bricks 4x Wooden Stairs: Wooden Planks, None, None | Wooden Planks, Wooden Planks, None | Wooden Planks, Wooden Planks, Wooden Planks -1x Fishing Rod: None, None, Stick | None, Stick, String | Stick, None, String 4x Stone Stairs: Cobblestone, None, None | Cobblestone, Cobblestone, None | Cobblestone, Cobblestone, Cobblestone 4x Brick Stairs: Bricks, None, None | Bricks, Bricks, None | Bricks, Bricks, Bricks 4x Nether Brick Stairs: Nether Bricks, None, None | Nether Bricks, Nether Bricks, None | Nether Bricks, Nether Bricks, Nether Bricks 4x Stone Brick Stairs: Stone Bricks, None, None | Stone Bricks, Stone Bricks, None | Stone Bricks, Stone Bricks, Stone Bricks -1x Painting: Stick, Stick, Stick | Stick, Black Wool, Stick | Stick, Stick, Stick -1x Golden Apple: Gold Nugget, Gold Nugget, Gold Nugget | Gold Nugget, Apple, Gold Nugget | Gold Nugget, Gold Nugget, Gold Nugget -1x Clock: None, Gold Ingot, None | Gold Ingot, Redstone, Gold Ingot | None, Gold Ingot, None -1x Compass: None, Iron Ingot, None | Iron Ingot, Redstone, Iron Ingot | None, Iron Ingot, None -1x Map: Paper, Paper, Paper | Paper, Compass, Paper | Paper, Paper, Paper -1x Dispenser: Cobblestone, Cobblestone, Cobblestone | Cobblestone, Bow, Cobblestone | Cobblestone, Redstone, Cobblestone -1x Piston: Wooden Planks, Wooden Planks, Wooden Planks | Cobblestone, Iron Ingot, Cobblestone | Cobblestone, Redstone, Cobblestone +1x Snow: Snowball, Snowball | Snowball, Snowball +1x Clay Block: Clay, Clay | Clay, Clay +1x Brick Block: Brick, Brick | Brick, Brick +4x Stone Bricks: Stone, Stone | Stone, Stone +1x Bookshelf: Wooden Planks, Wooden Planks, Wooden Planks | Book, Book, Book | Wooden Planks, Wooden Planks, Wooden Planks +1x Sandstone: Sand, Sand | Sand, Sand +1x Jack 'o' Lantern: Pumpkin | Torch +// +//Tool Recipes +// +1x Wooden Pickaxe: Wooden Planks, Wooden Planks, Wooden Planks | None, Stick, None | None, Stick, None 1x Wooden Axe: Wooden Planks, Wooden Planks | Wooden Planks, Stick | None, Stick 1x Wooden Hoe: Wooden Planks, Wooden Planks | None, Stick | None, Stick +1x Wooden Shovel: Wooden Planks | Stick | Stick +1x Stone Pickaxe: Cobblestone, Cobblestone, Cobblestone | None, Stick, None | None, Stick, None 1x Stone Axe: Cobblestone, Cobblestone | Cobblestone, Stick | None, Stick 1x Stone Hoe: Cobblestone, Cobblestone | None, Stick | None, Stick +1x Stone Shovel: Cobblestone | Stick | Stick +1x Iron Pickaxe: Iron Ingot, Iron Ingot, Iron Ingot | None, Stick, None | None, Stick, None 1x Iron Axe: Iron Ingot, Iron Ingot | Iron Ingot, Stick | None, Stick 1x Iron Hoe: Iron Ingot, Iron Ingot | None, Stick | None, Stick +1x Iron Shovel: Iron Ingot | Stick | Stick +1x Diamond Pickaxe: Diamond, Diamond, Diamond | None, Stick, None | None, Stick, None 1x Diamond Axe: Diamond, Diamond | Diamond, Stick | None, Stick 1x Diamond Hoe: Diamond, Diamond | None, Stick | None, Stick +1x Diamond Shovel: Diamond | Stick | Stick +1x Golden Pickaxe: Gold Ingot, Gold Ingot, Gold Ingot | None, Stick, None | None, Stick, None 1x Golden Axe: Gold Ingot, Gold Ingot | Gold Ingot, Stick | None, Stick 1x Golden Hoe: Gold Ingot, Gold Ingot | None, Stick | None, Stick -16x Iron Bars: Iron Ingot, Iron Ingot, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot -16x Glass Pane: Glass, Glass, Glass | Glass, Glass, Glass -1x Leather Cap: Leather, Leather, Leather | Leather, None, Leather -1x Leather Boots: Leather, None, Leather | Leather, None, Leather -1x Chain Helmet: Fire, Fire, Fire | Fire, None, Fire -1x Chain Boots: Fire, None, Fire | Fire, None, Fire -1x Iron Helmet: Iron Ingot, Iron Ingot, Iron Ingot | Iron Ingot, None, Iron Ingot -1x Iron Boots: Iron Ingot, None, Iron Ingot | Iron Ingot, None, Iron Ingot -1x Diamond Helmet: Diamond, Diamond, Diamond | Diamond, None, Diamond -1x Diamond Boots: Diamond, None, Diamond | Diamond, None, Diamond -1x Golden Helmet: Gold Ingot, Gold Ingot, Gold Ingot | Gold Ingot, None, Gold Ingot -1x Golden Boots: Gold Ingot, None, Gold Ingot | Gold Ingot, None, Gold Ingot -2x Fence: Stick, Stick, Stick | Stick, Stick, Stick -2x Nether Brick Fence: Nether Brick, Nether Brick, Nether Brick | Nether Brick, Nether Brick, Nether Brick -1x Fence Gate: Stick, Wooden Planks, Stick | Stick, Wooden Planks, Stick -1x Wooden Door: Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks -2x Trapdoor: Wooden Planks, Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks -1x Iron Door: Iron Ingot, Iron Ingot | Iron Ingot, Iron Ingot | Iron Ingot, Iron Ingot -4x Bowl: Wooden Planks, None, Wooden Planks | None, Wooden Planks, None -1x Minecart: Iron Ingot, None, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot -1x Boat: Wooden Planks, None, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks -1x Bucket: Iron Ingot, None, Iron Ingot | None, Iron Ingot, None -1x Redstone Repeater: Redstone Torch, Redstone, Redstone Torch | Stone, Stone, Stone -1x Redstone Lamp: None, Redstone, None | Redstone, Glowstone, Redstone | None, Redstone, None -1x Bed: Black Wool, Black Wool, Black Wool | Wooden Planks, Wooden Planks, Wooden Planks -1x Shears: None, Iron Ingot | Iron Ingot, None -1x Crafting Table: Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks -1x Sandstone: Sand, Sand | Sand, Sand -4x Stone Bricks: Stone, Stone | Stone, Stone -1x Snow: Snowball, Snowball | Snowball, Snowball -1x Clay: Clay, Clay | Clay, Clay -1x Bricks: Brick, Brick | Brick, Brick -1x Glowstone: Glowstone Dust, Glowstone Dust | Glowstone Dust, Glowstone Dust -1x Wool: String, String | String, String -1x Flint and Steel: Iron Ingot, None | None, Flint -1x Wooden Shovel: Wooden Planks | Stick | Stick -1x Stone Shovel: Cobblestone | Stick | Stick -1x Iron Shovel: Iron Ingot | Stick | Stick -1x Diamond Shovel: Diamond | Stick | Stick 1x Golden Shovel: Gold Ingot | Stick | Stick +1x Flint and Steel: Iron Ingot, None | None, Flint +1x Bucket: Iron Ingot, None, Iron Ingot | None, Iron Ingot, None +1x Compass: None, Iron Ingot, None | Iron Ingot, Redstone, Iron Ingot | None, Iron Ingot, None +1x Map: Paper, Paper, Paper | Paper, Compass, Paper | Paper, Paper, Paper +1x Clock: None, Gold Ingot, None | Gold Ingot, Redstone, Gold Ingot | None, Gold Ingot, None +1x Fishing Rod: None, None, Stick | None, Stick, String | Stick, None, String +1x Shears: None, Iron Ingot | Iron Ingot, None +3x Fire Charge: Gunpowder, None, None | Blaze Powder, Coal/Charcoal, None +// +//Weapon Recipes +// 1x Wooden Sword: Wooden Planks | Wooden Planks | Stick 1x Stone Sword: Cobblestone | Cobblestone | Stick 1x Iron Sword: Iron Ingot | Iron Ingot | Stick 1x Diamond Sword: Diamond | Diamond | Stick 1x Golden Sword: Gold Ingot | Gold Ingot | Stick +1x Bow: None, Stick, String | Stick, None, String | None, Stick, String 4x Arrow: Flint | Stick | Feather -1x Mushroom Stew: Brown Mushroom | Red Mushroom | Bowl -1x Fermented Spider Eye: Spider Eye | Brown Mushroom, Sugar -1x Eye of Ender: Blaze Powder | Ender Pearl -1x Glistering Melon: Melon Slice, Gold Nugget -2x Blaze Powder: Blaze Rod -1x Magma Cream: Ender Pearl | Blaze Powder -9x Gold Nugget: Gold Ingot -1x Gold Ingot: Gold Nugget, Gold Nugget, Gold Nugget | Gold Nugget, Gold Nugget, Gold Nugget | Gold Nugget, Gold Nugget, Gold Nugget -3x Fire Charge: Blaze Powder | Coal/Charcoal | Gunpowder -1x Brewing Stand: None, Blaze Rod, None | Cobblestone, Cobblestone, Cobblestonr -1x Cauldron: Iron Ingot, None, Iron Ingot | Iron Ingot, None, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot -3x Glass Bottle: Glass, None, Glass | None, Glass, None -8x Cookie: Wheat, Cocoa Beans, Wheat -3x Paper: Sugar Canes, Sugar Canes, Sugar Canes -1x Book: Paper | Paper | Paper -3x Cobblestone Slab: Cobblestone, Cobblestone, Cobblestone -3x Stone Slab: Stone, Stone, Stone -3x Sandstone Slab: Sandstone, Sandstone, Sandstone -3x Wooden Slab: Wooden Planks, Wooden Planks, Wooden Planks -3x Bricks Slab: Bricks, Bricks, Bricks -3x Stone Bricks Slab: Stone Bricks, Stone Bricks, Stone Bricks -1x Bread: Wheat, Wheat, Wheat -4x Stick: Wooden Planks | Wooden Planks -4x Torch: Coal | Stick -4x Torch: Charcoal | Stick -1x Jack 'o' Lantern: Pumpkin | Torch +// +//Armor Recipes +// +1x Leather Tunic: Leather, None, Leather | Leather, Leather, Leather | Leather, Leather, Leather +1x Leather Pants: Leather, Leather, Leather | Leather, None, Leather | Leather, None, Leather +1x Leather Cap: Leather, Leather, Leather | Leather, None, Leather +1x Leather Boots: Leather, None, Leather | Leather, None, Leather +1x Chain Chestplate: Fire, None, Fire | Fire, Fire, Fire | Fire, Fire, Fire +1x Chain Leggings: Fire, Fire, Fire | Fire, None, Fire | Fire, None, Fire +1x Chain Helmet: Fire, Fire, Fire | Fire, None, Fire +1x Chain Boots: Fire, None, Fire | Fire, None, Fire +1x Iron Chestplate: Iron Ingot, None, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot +1x Iron Leggings: Iron Ingot, Iron Ingot, Iron Ingot | Iron Ingot, None, Iron Ingot | Iron Ingot, None, Iron Ingot +1x Iron Helmet: Iron Ingot, Iron Ingot, Iron Ingot | Iron Ingot, None, Iron Ingot +1x Iron Boots: Iron Ingot, None, Iron Ingot | Iron Ingot, None, Iron Ingot +1x Diamond Chestplate: Diamond, None, Diamond | Diamond, Diamond, Diamond | Diamond, Diamond, Diamond +1x Diamond Leggings: Diamond, Diamond, Diamond | Diamond, None, Diamond | Diamond, None, Diamond +1x Diamond Helmet: Diamond, Diamond, Diamond | Diamond, None, Diamond +1x Diamond Boots: Diamond, None, Diamond | Diamond, None, Diamond +1x Golden Chestplate: Gold Ingot, None, Gold Ingot | Gold Ingot, Gold Ingot, Gold Ingot | Gold Ingot, Gold Ingot, Gold Ingot +1x Golden Leggings: Gold Ingot, Gold Ingot, Gold Ingot | Gold Ingot, None, Gold Ingot | Gold Ingot, None, Gold Ingot +1x Golden Helmet: Gold Ingot, Gold Ingot, Gold Ingot | Gold Ingot, None, Gold Ingot +1x Golden Boots: Gold Ingot, None, Gold Ingot | Gold Ingot, None, Gold Ingot +// +//Transportation Recipes +// +1x Minecart: Iron Ingot, None, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot 1x Minecart with Chest: Chest | Minecart 1x Minecart with Furnace: Furnace | Minecart -1x Lever: Stick | Cobblestone -1x Redstone Torch: Redstone | Stick +16x Rail: Iron Ingot, None, Iron Ingot | Iron Ingot, Stick, Iron Ingot | Iron Ingot, None, Iron Ingot +6x Powered Rail: Gold Ingot, None, Gold Ingot | Gold Ingot, Stick, Gold Ingot | Gold Ingot, Redstone, Gold Ingot +6x Detector Rail: Iron Ingot, None, Iron Ingot | Iron Ingot, Pressure Plate, Iron Ingot | Iron Ingot, Redstone, Iron Ingot +1x Boat: Wooden Planks, None, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks +// +//Mechanism Recipes +// +1x Wooden Door: Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks +1x Iron Door: Iron Ingot, Iron Ingot | Iron Ingot, Iron Ingot | Iron Ingot, Iron Ingot +2x Trapdoor: Wooden Planks, Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks +1x Stone Pressure Plate: Stone, Stone +1x Wooden Pressure Plate: Wooden Planks, Wooden Planks 1x Button: Stone | Stone -1x Pressure Plate: Stone, Stone -1x Pressure Plate: Wooden Planks, Wooden Planks -1x Sticky Piston: Slimeball | Piston +1x Redstone Torch: Redstone | Stick +1x Lever: Stick | Cobblestone +1x Note Block: Wooden Planks, Wooden Planks, Wooden Planks | Wooden Planks, Redstone, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks +1x Jukebox: Wooden Planks, Wooden Planks, Wooden Planks | Wooden Planks, Diamond, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks +1x Dispenser: Cobblestone, Cobblestone, Cobblestone | Cobblestone, Bow, Cobblestone | Cobblestone, Redstone, Cobblestone +1x Redstone Repeater: Redstone Torch, Redstone, Redstone Torch | Stone, Stone, Stone +1x Piston: Wooden Planks, Wooden Planks, Wooden Planks | Cobblestone, Iron Ingot, Cobblestone | Cobblestone, Redstone, Cobblestone +1x Sticky Piston: none, slime ball, none | none, piston, none +1x Redstone Lamp: none, redstone dust, none | redstone dust, glowstone block, redstone | none, redstone dust, none +// +//Food Recipes +// +4x Bowl: Wooden Planks, None, Wooden Planks | None, Wooden Planks, None +1x Mushroom Stew: Brown Mushroom, Red Mushroom | Bowl +1x Bread: Wheat, Wheat, Wheat +1x Sugar: Sugar Canes +1x Cake: Milk, Milk, Milk | Sugar, Egg, Sugar | Wheat, Wheat, Wheat +8x Cookie: Wheat, Cocoa Beans, Wheat +1x Golden Apple: Gold Nugget, Gold Nugget, Gold Nugget | Gold Nugget, Apple, Gold Nugget | Gold Nugget, Gold Nugget, Gold Nugget +1x Melon Block: Melon, Melon, Melon | Melon, Melon, Melon | Melon, Melon, Melon +1x Melon Seeds: Melon Slice +4x Pumpkin Seeds: Pumpkin +// +//Miscellaneous Recipes +// 9x Gold Ingot: Block of Gold 9x Iron Ingot: Block of Iron 9x Diamond: Block of Diamond 9x Lapis Lazuli: Lapis Lazuli Block -1x Melon Seeds: Melon -1x Sugar: Sugar Canes -4x Wooden Planks: Wood -4x Magenta Dye: Lapis Lazuli, Rose Red, Rose Red, Bone Meal -3x Light Gray Dye: Ink Sac, Bone Meal, Bone Meal -3x Magenta Dye: Lapis Lazuli, Rose Red, Pink Dye -1x Black Wool: Ink Sac, Wool -1x Red Wool: Rose Red, Wool -1x Green Wool: Cactus Green, Wool -1x Brown Wool: Cocoa Beans, Wool -1x Blue Wool: Lapis Lazuli, Wool -1x Purple Wool: Purple Dye, Wool -1x Cyan Wool: Cyan Dye, Wool -1x Light Gray Wool: Light Gray Dye, Wool -1x Gray Wool: Gray Dye, Wool -1x Pink Wool: Pink Dye, Wool -1x Lime Wool: Lime Dye, Wool -1x Yellow Wool: Dandelion Yellow, Wool -1x Light Blue Wool: Light Blue Dye, Wool -1x Magenta Wool: Magenta Dye, Wool -1x Orange Wool: Orange Dye, Wool -1x Wool: Bone Meal, Wool -2x Pink Dye: Rose Red, Bone Meal -2x Orange Dye: Rose Red, Dandelion Yellow -2x Lime Dye: Cactus Green, Bone Meal -2x Gray Dye: Ink Sac, Bone Meal +2x Ladder: Stick, None, Stick | Stick, Stick, Stick | Stick, None, Stick +1x Sign: Wooden Planks, Wooden Planks, Wooden Planks | Wooden Planks, Wooden Planks, Wooden Planks | None, Stick, None +1x Painting: Stick, Stick, Stick | Stick, Black Wool, Stick | Stick, Stick, Stick +16x Iron Bars: Iron Ingot, Iron Ingot, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot +16x Glass Pane: Glass, Glass, Glass | Glass, Glass, Glass +3x Paper: Sugar Canes, Sugar Canes, Sugar Canes +1x Book: Paper | Paper | Paper +2x Fence: Stick, Stick, Stick | Stick, Stick, Stick +2x Nether Brick Fence: Nether Brick, Nether Brick, Nether Brick | Nether Brick, Nether Brick, Nether Brick +1x Fence Gate: Stick, Wooden Planks, Stick | Stick, Wooden Planks, Stick +1x Bed: Wool, Wool, Wool | Wooden Planks, Wooden Planks, Wooden Planks +9x Gold Nugget: Gold Ingot +1x Gold Ingot: Gold Nugget, Gold Nugget, Gold Nugget | Gold Nugget, Gold Nugget, Gold Nugget | Gold Nugget, Gold Nugget, Gold Nugget +1x Eye of Ender: Ender Pearl | Blaze Powder +// +//Dye Recipes +// +3x Bone Meal: Bone 2x Light Gray Dye: Gray Dye, Bone Meal +2x Gray Dye: Ink Sac, Bone Meal +2x Rose Red: Rose +2x Orange Dye: Rose Red, Dandelion Yellow +2x Dandelion Yellow: Flower +2x Lime Dye: Cactus Green, Bone Meal 2x Light Blue Dye: Lapis Lazuli, Bone Meal 2x Cyan Dye: Lapis Lazuli, Cactus Green 2x Purple Dye: Lapis Lazuli, Rose Red -2x Magenta Dye: Purple Dye, Pink Dye -2x Dandelion Yellow: Flower -2x Rose Red: Rose -3x Bone Meal: Bone +4x Magenta Dye: Lapis Lazuli, Rose Red, Rose Red, Bone Meal +2x Pink Dye: Rose Red, Bone Meal +// +//Wool Recipes +// +1x Light Gray Wool: Light Gray Dye, Wool +1x Gray Wool: Gray Dye, Wool +1x Black Wool: Ink Sac, Wool +1x Red Wool: Rose Red, Wool +1x Orange Wool: Orange Dye, Wool +1x Yellow Wool: Dandelion Yellow, Wool +1x Lime Wool: Lime Dye, Wool +1x Green Wool: Cactus Green, Wool +1x Light Blue Wool: Light Blue Dye, Wool +1x Cyan Wool: Cyan Dye, Wool +1x Blue Wool: Lapis Lazuli, Wool +1x Purple Wool: Purple Dye, Wool +1x Magenta Wool: Magenta Dye, Wool +1x Pink Wool: Pink Dye, Wool +1x Brown Wool: Cocoa Beans, Wool +1x Wool: Bone Meal, Wool +// +//Enchancement & Brewing Recipes +// +3x Glass Bottle: Glass, None, Glass | None, Glass, None +1x Cauldron: Iron Ingot, None, Iron Ingot | Iron Ingot, None, Iron Ingot | Iron Ingot, Iron Ingot, Iron Ingot +1x Brewing Stand: None, Blaze Rod, None | Cobblestone, Cobblestone, Cobblestone +2x Blaze Powder: Blaze Rod +1x Magma Cream: Slimeball | Blaze Powder +1x Fermented Spider Eye: Spider Eye | Brown Mushroom, Sugar +1x Glistering Melon: Melon Slice, Gold Nugget +9x Gold Nugget: Gold Ingot +1x Enchantment Table: None, Book, None | Diamond, Obsidian, Diamond | Obsidian, Obsidian, Obsidian \ No newline at end of file From 3a14d78daaaaf8f925dee99bd1ce1027b213ca87 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 19 Mar 2012 23:58:04 -0700 Subject: [PATCH 090/205] updated links --- DOCUMENTATION | 2 +- bot.py | 2 +- cloudbot | 2 +- core/config.py | 4 ++-- plugins/ctcp.py | 2 +- plugins/misc.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/DOCUMENTATION b/DOCUMENTATION index 1675060..a5daa54 100755 --- a/DOCUMENTATION +++ b/DOCUMENTATION @@ -1 +1 @@ -Please see the wiki @ http://git.io/cloudbotwiki \ No newline at end of file +Please see the wiki @ http://git.io/cloudbotircwiki \ No newline at end of file diff --git a/bot.py b/bot.py index 45fac16..2a6fb10 100755 --- a/bot.py +++ b/bot.py @@ -13,7 +13,7 @@ os.chdir(sys.path[0] or '.') # do stuff relative to the install directory class Bot(object): pass -print 'Welcome to Cloudbot - Version DEV - http://git.io/cloudbot' +print 'Welcome to Cloudbot - Version DEV - http://git.io/cloudbotirc' bot = Bot() diff --git a/cloudbot b/cloudbot index 3d7ac49..b422659 100755 --- a/cloudbot +++ b/cloudbot @@ -5,7 +5,7 @@ echo " / ____/ /___ __ ______/ / __ )____ / /_" echo " / / / / __ \/ / / / __ / __ / __ \/ __/" echo "/ /___/ / /_/ / /_/ / /_/ / /_/ / /_/ / /_ " echo "\____/_/\____/\__,_/\__,_/_____/\____/\__/ " -echo " http://git.io/cloudbot by ClouDev " +echo " http://git.io/cloudbotirc by ClouDev " echo "" locatefiles() { botfile="/bot.py" diff --git a/core/config.py b/core/config.py index 5c39127..0401d3a 100755 --- a/core/config.py +++ b/core/config.py @@ -17,7 +17,7 @@ if not os.path.exists('config'): "server": "irc.esper.net", "nick": "MyNewCloudBot", "user": "cloudbot", - "realname": "CloudBot - http://git.io/cloudbot", + "realname": "CloudBot - http://git.io/cloudbotirc", "nickserv_password": "", "channels": ["#cloudbot"], "invitejoin": true, @@ -61,7 +61,7 @@ if not os.path.exists('config'): }''') + '\n') print "Config generated!" print "Please edit the config now!" - print "For help, see http://git.io/cloudbotwiki" + print "For help, see http://git.io/cloudbotircwiki" print "Thank you for using CloudBot!" sys.exit() diff --git a/plugins/ctcp.py b/plugins/ctcp.py index 083f294..800115b 100755 --- a/plugins/ctcp.py +++ b/plugins/ctcp.py @@ -4,7 +4,7 @@ from util import hook # CTCP responses @hook.regex(r'^\x01VERSION\x01$') def ctcpversion(inp, notice=None): - notice('\x01VERSION: CloudBot - http://git.io/cloudbot') + notice('\x01VERSION: CloudBot - http://git.io/cloudbotirc') @hook.regex(r'^\x01PING\x01$') diff --git a/plugins/misc.py b/plugins/misc.py index 4a82252..de62cb8 100755 --- a/plugins/misc.py +++ b/plugins/misc.py @@ -51,7 +51,7 @@ def onjoin(paraml, conn=None, bot=None): time.sleep(1) # HTTP Useragent - http.ua_cloudbot = 'CloudBot - http://git.io/cloudbot' + http.ua_cloudbot = 'CloudBot - http://git.io/cloudbotirc' # Stay-alive code stayalive = conn.conf.get('stayalive') From 42384f9981a3a6a045e5aba1a6cee492c5595cd3 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Wed, 21 Mar 2012 15:41:44 +1300 Subject: [PATCH 091/205] Update plugins/dictionary.py --- plugins/dictionary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dictionary.py b/plugins/dictionary.py index ca9d50f..5efbf9c 100755 --- a/plugins/dictionary.py +++ b/plugins/dictionary.py @@ -30,7 +30,7 @@ def urban(inp): # try getting the requested definition try: - out = "(%s/%s) %s: %s" % \ + out = "[%s/%s] %s: %s" % \ (str(id), str(len(defs)), defs[id-1]['word'], defs[id-1]['definition']) except IndexError: return 'Not found.' From d935cccd1833af7f6f201211aa27cee54b4dd4b6 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 21 Mar 2012 23:52:15 +1300 Subject: [PATCH 092/205] Dumped the buggy auto parser. replaced it with a faster command-based system that doesn't fail as much --- plugins/urlparse.py | 69 ++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/plugins/urlparse.py b/plugins/urlparse.py index fc6b7aa..f3cabed 100755 --- a/plugins/urlparse.py +++ b/plugins/urlparse.py @@ -4,46 +4,37 @@ from urllib2 import urlopen, Request, HTTPError import re import BeautifulSoup -ignored_urls = ["http://google.com", "http://youtube.com", - "http://pastebin.com", "http://mibpaste.com", - "http://fpaste.com", "http://git.io"] +titler = re.compile(r'(?si)(.+?)'); -def parse(match): - url = urlnorm.normalize(match.encode('utf-8')) - if url not in ignored_urls: - url = url.decode('utf-8') - try: - soup = BeautifulSoup.BeautifulSoup(http.get(url)) - return soup.title.string - except: - return "fail" - -# there should be " after the ' in the regex string but I was unable to escape it properly -@hook.regex(r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'.,<>?«»“”‘’]))") -def urlparser(match, say=None, bot=None): +def parse(url): + """ an improved version of our parsing code - now regex powered """ + url = urlnorm.normalize(url.encode('utf-8')) + url = url.decode('utf-8') + # add http if its missing + if url[:7] != "http://" and url[:8] != "https://": + url = "http://" + url try: - enabled = bot.config["plugins"]["urlparse"]["enabled"] - except KeyError: - enabled = False - - if not enabled: - return - - url = urlnorm.normalize(match.group().encode('utf-8')) - if url[:7] != "http://": - if url[:8] != "https://": - url = "http://" + url - for x in ignored_urls: - if x in url: - return - title = parse(url) - if title == "fail": - return + # get the title + print url + request = http.open(url) + real_url = request.geturl() + text = request.read() + text = text.decode('utf8') + match = titler.search(text) + title = match.group(1) + except: + return "Could not parse URL! Are you sure its valid?" + title = http.unescape(title) - realurl = http.get_url(url) - if realurl == url: - say(u"(Link) %s" % title) - return + + # if the url has been redirected, show us + if real_url == url: + return title else: - say(u"(Link) %s [%s]" % (title, realurl)) - return + return u"%s [%s]" % (title, real_url) + +@hook.command +def title(inp): + ".title -- gets the title of a web page" + return parse(inp) + From b47482a07a4ffef2ea4ec46c05f24b83648775c9 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 21 Mar 2012 23:55:38 +1300 Subject: [PATCH 093/205] removed useless imports and debug code --- plugins/urlparse.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/urlparse.py b/plugins/urlparse.py index f3cabed..088bc85 100755 --- a/plugins/urlparse.py +++ b/plugins/urlparse.py @@ -1,8 +1,5 @@ from util import hook, http, urlnorm -import urllib -from urllib2 import urlopen, Request, HTTPError import re -import BeautifulSoup titler = re.compile(r'(?si)(.+?)'); @@ -15,7 +12,6 @@ def parse(url): url = "http://" + url try: # get the title - print url request = http.open(url) real_url = request.geturl() text = request.read() From 0c3e78bdce7fa6b387fffba6502410a0d3eb66aa Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Thu, 22 Mar 2012 16:17:45 +1300 Subject: [PATCH 094/205] admin is now granted by hostmask user@host --- plugins/sieve.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/sieve.py b/plugins/sieve.py index 108390e..46e54b7 100755 --- a/plugins/sieve.py +++ b/plugins/sieve.py @@ -36,7 +36,11 @@ def sieve_suite(bot, input, func, kind, args): if args.get('adminonly', False): admins = bot.config.get('admins', []) - if input.host not in admins and input.nick not in admins: + # admins = ["u3601@irccloud.com", "brjannc@smurfed.org"] + + mask = input.user + "@" + input.host + + if mask not in admins: return None return input From 3e5c2c94d97aeb32870cfd3558102854447c5a5a Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Thu, 22 Mar 2012 17:04:48 +1300 Subject: [PATCH 095/205] added input.mask. returns 'user@host' --- core/irc.py | 6 ++++-- core/main.py | 4 ++-- plugins/help.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/irc.py b/core/irc.py index b14c828..ff9a45f 100755 --- a/core/irc.py +++ b/core/irc.py @@ -163,6 +163,7 @@ class IRC(object): else: prefix, command, params = irc_noprefix_rem(msg).groups() nick, user, host = irc_netmask_rem(prefix).groups() + mask = user + "@" + host paramlist = irc_param_ref(params) lastparam = "" if paramlist: @@ -170,7 +171,7 @@ class IRC(object): paramlist[-1] = paramlist[-1][1:] lastparam = paramlist[-1] self.out.put([msg, prefix, command, params, nick, user, host, - paramlist, lastparam]) + mask, paramlist, lastparam]) if command == "PING": self.cmd("PONG", paramlist) @@ -225,6 +226,7 @@ class FakeIRC(IRC): else: prefix, command, params = irc_noprefix_rem(msg).groups() nick, user, host = irc_netmask_rem(prefix).groups() + mask = user + "@" + host paramlist = irc_param_ref(params) lastparam = "" if paramlist: @@ -232,7 +234,7 @@ class FakeIRC(IRC): paramlist[-1] = paramlist[-1][1:] lastparam = paramlist[-1] self.out.put([msg, prefix, command, params, nick, user, host, - paramlist, lastparam]) + mask, paramlist, lastparam]) if command == "PING": self.cmd("PONG", [params]) diff --git a/core/main.py b/core/main.py index 041d67e..93f53c4 100755 --- a/core/main.py +++ b/core/main.py @@ -7,7 +7,7 @@ thread.stack_size(1024 * 512) # reduce vm size class Input(dict): def __init__(self, conn, raw, prefix, command, params, - nick, user, host, paraml, msg): + nick, user, host, mask, paraml, msg): chan = paraml[0].lower() if chan == conn.nick.lower(): # is a PM @@ -35,7 +35,7 @@ class Input(dict): conn.cmd('NOTICE', [nick, msg]) dict.__init__(self, conn=conn, raw=raw, prefix=prefix, command=command, - params=params, nick=nick, user=user, host=host, + params=params, nick=nick, user=user, host=host, mask=mask, paraml=paraml, msg=msg, server=conn.server, chan=chan, notice=notice, say=say, reply=reply, pm=pm, bot=bot, me=me, set_nick=set_nick, lastparam=paraml[-1]) diff --git a/plugins/help.py b/plugins/help.py index bde3d17..70ac3be 100755 --- a/plugins/help.py +++ b/plugins/help.py @@ -12,7 +12,7 @@ def help(inp, input=None, bot=None, say=None, notice=None): for command, (func, args) in bot.commands.iteritems(): fn = re.match(r'^plugins.(.+).py$', func._filename) if fn.group(1).lower() not in disabled: - if not args.get('adminonly', False) or input.nick in input.bot.config["admins"]: + if not args.get('adminonly', False) or input.mask in input.bot.config["admins"]: if command not in disabled_comm: if func.__doc__ is not None: if func in funcs: From b89e7589d037e2de29f6ee0d60f0f00665d86a63 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Thu, 22 Mar 2012 17:16:27 +1300 Subject: [PATCH 096/205] removed ghastly yellow --- plugins/8ball.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/8ball.py b/plugins/8ball.py index 3f576d7..e69b95a 100755 --- a/plugins/8ball.py +++ b/plugins/8ball.py @@ -4,7 +4,7 @@ import re r = "\x02\x0305" # red g = "\x02\x0303" # green -y = "\x02\x0308" # yellow +y = "\x02" # yellow (not really) answers = [g + "As I see it, yes", g + "It is certain", From a36ef950e0b63905ad2ee46f7a2aa4d51d443035 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Thu, 22 Mar 2012 21:59:55 +1300 Subject: [PATCH 097/205] added .search as alias for .google --- plugins/google.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/google.py b/plugins/google.py index 5d6f9ac..c4593b2 100755 --- a/plugins/google.py +++ b/plugins/google.py @@ -22,7 +22,7 @@ def gis(inp): return random.choice(parsed['responseData']['results'][:10]) \ ['unescapedUrl'] # squares is dumb - +@hook.command('search') @hook.command('g') @hook.command def google(inp): From 4edac9338a674ea796d06f3709fdd486438b7ea8 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Thu, 22 Mar 2012 22:02:21 +1300 Subject: [PATCH 098/205] added .brainfuck as alias for .bf --- plugins/bf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/bf.py b/plugins/bf.py index a3bd724..e51500b 100755 --- a/plugins/bf.py +++ b/plugins/bf.py @@ -10,7 +10,7 @@ from util import hook BUFFER_SIZE = 5000 MAX_STEPS = 1000000 - +@hook.command('brainfuck') @hook.command def bf(inp): ".bf -- Executes as Brainfuck code." From 2c71c75e662daa1fc62a06ea0d52aeba00b41850 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Fri, 23 Mar 2012 07:34:48 +1300 Subject: [PATCH 099/205] added mute command (didn't use the feature branch, git-flow was acting up) --- plugins/mute.py | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 plugins/mute.py diff --git a/plugins/mute.py b/plugins/mute.py new file mode 100755 index 0000000..0efa75b --- /dev/null +++ b/plugins/mute.py @@ -0,0 +1,73 @@ +# mute plugin by lukeroge and neersighted +from util import hook + +muted = [] + + +def mute_target(target): + muted.append(target) + + +def unmute_target(target): + muted.remove(target) + + +def is_muted(target): + if target in muted: + return True + else: + return False + + +@hook.sieve +def mutesieve(bot, input, func, type, args): +# if type == "event": +# print "type: event, dying" +# return input + if is_muted(input.chan) or is_muted(input.nick): + if input.command == "PRIVMSG" and input.lastparam[1:] == "unmute": + return input + else: + return None + return input + + +@hook.command("muted") +@hook.command(autohelp=False) +def listmuted(inp, bot=None): + ".muted -- Lists the muted users/channels." + return "Muted users/channels are: " + ", ".join(muted) + + +@hook.command(autohelp=False, adminonly=True) +def mute(inp, input=None, db=None): + ".mute -- Makes the bot ignore ." + "If no channel is specified, it is muted in the current channel." + if inp: + target = inp + else: + target = input.chan + + if is_muted(target): + input.notice("%s is already muted." % target) + else: + mute_target(target) + input.notice("%s has been muted." % target) + + +@hook.command(autohelp=False, adminonly=True) +def unmute(inp, input=None, db=None): + ".unmute -- Makes the bot listen to ." + "If no channel is specified, it is unmuted in the current channel." + if inp: + target = inp + else: + target = input.chan + + if is_muted(target): + unmute_target(target) + input.notice("%s has been unmuted." % target) + return + else: + input.notice("%s is not muted." % target) + return From d74a57d3876c8ffa7450a53d14594b376c201cb1 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Fri, 23 Mar 2012 07:36:00 +1300 Subject: [PATCH 100/205] removed default action --- plugins/mute.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/plugins/mute.py b/plugins/mute.py index 0efa75b..d3000cb 100755 --- a/plugins/mute.py +++ b/plugins/mute.py @@ -39,14 +39,11 @@ def listmuted(inp, bot=None): return "Muted users/channels are: " + ", ".join(muted) -@hook.command(autohelp=False, adminonly=True) +@hook.command(adminonly=True) def mute(inp, input=None, db=None): ".mute -- Makes the bot ignore ." "If no channel is specified, it is muted in the current channel." - if inp: - target = inp - else: - target = input.chan + target = inp if is_muted(target): input.notice("%s is already muted." % target) @@ -55,15 +52,12 @@ def mute(inp, input=None, db=None): input.notice("%s has been muted." % target) -@hook.command(autohelp=False, adminonly=True) +@hook.command(adminonly=True) def unmute(inp, input=None, db=None): ".unmute -- Makes the bot listen to ." "If no channel is specified, it is unmuted in the current channel." - if inp: - target = inp - else: - target = input.chan - + target = inp + if is_muted(target): unmute_target(target) input.notice("%s has been unmuted." % target) From d6e2dc8f854a6567c4be655a347431d6bf2c0506 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Fri, 23 Mar 2012 07:54:57 +1300 Subject: [PATCH 101/205] a few fixes --- plugins/mute.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/mute.py b/plugins/mute.py index d3000cb..a579dd8 100755 --- a/plugins/mute.py +++ b/plugins/mute.py @@ -21,9 +21,8 @@ def is_muted(target): @hook.sieve def mutesieve(bot, input, func, type, args): -# if type == "event": -# print "type: event, dying" -# return input + if type == "event": + return input if is_muted(input.chan) or is_muted(input.nick): if input.command == "PRIVMSG" and input.lastparam[1:] == "unmute": return input @@ -35,8 +34,11 @@ def mutesieve(bot, input, func, type, args): @hook.command("muted") @hook.command(autohelp=False) def listmuted(inp, bot=None): - ".muted -- Lists the muted users/channels." - return "Muted users/channels are: " + ", ".join(muted) + ".listmuted -- Lists the muted users/channels." + if muted: + return "Muted users/channels are: " + ", ".join(muted) + else: + return "No users are currently muted." @hook.command(adminonly=True) From 3e2dad827f49ac7e6776386f5287405dbb6b25c2 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Fri, 23 Mar 2012 10:53:35 +1300 Subject: [PATCH 102/205] Fixed bug --- plugins/mute.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/mute.py b/plugins/mute.py index a579dd8..ecb9f28 100755 --- a/plugins/mute.py +++ b/plugins/mute.py @@ -5,14 +5,17 @@ muted = [] def mute_target(target): + target = target.lower() muted.append(target) def unmute_target(target): + target = target.lower() muted.remove(target) def is_muted(target): + target = target.lower() if target in muted: return True else: @@ -31,10 +34,9 @@ def mutesieve(bot, input, func, type, args): return input -@hook.command("muted") @hook.command(autohelp=False) def listmuted(inp, bot=None): - ".listmuted -- Lists the muted users/channels." + ".listmuted -- Lists muted users/channels." if muted: return "Muted users/channels are: " + ", ".join(muted) else: From b23d54df4440b035a3a1e316bcfd6393a66e4e41 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Fri, 23 Mar 2012 10:57:02 +1300 Subject: [PATCH 103/205] More fixes --- plugins/mute.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/mute.py b/plugins/mute.py index ecb9f28..f755855 100755 --- a/plugins/mute.py +++ b/plugins/mute.py @@ -5,16 +5,19 @@ muted = [] def mute_target(target): + """ mutes someone """ target = target.lower() muted.append(target) def unmute_target(target): + """ unmutes someone """ target = target.lower() muted.remove(target) def is_muted(target): + """ checks of someone is muted """ target = target.lower() if target in muted: return True @@ -24,8 +27,10 @@ def is_muted(target): @hook.sieve def mutesieve(bot, input, func, type, args): + """ blocks input from muted channels/users """ + # don't block input to event hooks if type == "event": - return input + return input if is_muted(input.chan) or is_muted(input.nick): if input.command == "PRIVMSG" and input.lastparam[1:] == "unmute": return input @@ -46,7 +51,6 @@ def listmuted(inp, bot=None): @hook.command(adminonly=True) def mute(inp, input=None, db=None): ".mute -- Makes the bot ignore ." - "If no channel is specified, it is muted in the current channel." target = inp if is_muted(target): @@ -59,7 +63,6 @@ def mute(inp, input=None, db=None): @hook.command(adminonly=True) def unmute(inp, input=None, db=None): ".unmute -- Makes the bot listen to ." - "If no channel is specified, it is unmuted in the current channel." target = inp if is_muted(target): From 8c3bc4634386c19be8153c5c2616f2a42dc774f3 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Fri, 23 Mar 2012 11:00:59 +1300 Subject: [PATCH 104/205] Fixed bug --- plugins/factoids.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/plugins/factoids.py b/plugins/factoids.py index 0bccc64..74b3e1f 100755 --- a/plugins/factoids.py +++ b/plugins/factoids.py @@ -47,9 +47,6 @@ def multiwordReplace(text, wordDic): @hook.command(adminonly=True) def remember(inp, nick='', db=None, say=None, input=None, notice=None): ".remember [+] -- Remembers with . Add + to to append." - if input.nick not in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return db_init(db) append = False @@ -93,9 +90,6 @@ def remember(inp, nick='', db=None, say=None, input=None, notice=None): @hook.command(adminonly=True) def forget(inp, db=None, input=None, notice=None): ".forget -- Forgets a remembered ." - if input.nick not in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return db_init(db) data = get_memory(db, inp) From ffbeab7e14291a52a0a2bf53e132055681c8e090 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Fri, 23 Mar 2012 13:00:22 +1300 Subject: [PATCH 105/205] PEP-8 --- plugins/mcitems.py | 27 ++++++++++++++------------- plugins/mute.py | 3 +-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/mcitems.py b/plugins/mcitems.py index fb9f905..b97ce30 100644 --- a/plugins/mcitems.py +++ b/plugins/mcitems.py @@ -1,5 +1,4 @@ """ plugin by _303 (?) - pulled from by lukeroge """ from util import hook @@ -10,6 +9,7 @@ pattern = re.compile(r'^(?P\d+)x (?P.+?): (?P.*)$') recipelist = [] + class Recipe(object): __slots__ = 'output', 'count', 'ingredients', 'line' @@ -21,7 +21,8 @@ class Recipe(object): def __str__(self): return self.line - + + with open("./plugins/data/recipes.txt") as f: for line in f.readlines(): if line.startswith("//"): @@ -44,7 +45,8 @@ with open("./plugins/data/itemids.txt") as f: parts = line.strip().split() id = parts[0] name = " ".join(parts[1:]) - ids.append((id,name)) + ids.append((id, name)) + @hook.command def itemid(input, reply=None): @@ -67,21 +69,21 @@ def itemid(input, reply=None): if not len(results): reply("No matches found.") return - + if len(results) > 12: - reply("There are too many options, please narrow your search. (%s)" % len(results)) + reply("There are too many options, please narrow your search." + "(%s)" % len(results)) return - + out = ", ".join(results) - + return out - -@hook.command("crafting") +@hook.command("craft") @hook.command def recipe(input, reply=None): - ".recipe -- gets the crafting recipe for an item" + ".recipe/.craft -- gets the crafting recipe for an item" input = input.lower().strip() results = [] @@ -95,10 +97,9 @@ def recipe(input, reply=None): return if len(results) > 3: - reply("There are too many options, please narrow your search. (%s)" % len(results)) + reply("There are too many options, please narrow your search." + "(%s)" % len(results)) return for result in results: reply(result) - - diff --git a/plugins/mute.py b/plugins/mute.py index f755855..d59ded5 100755 --- a/plugins/mute.py +++ b/plugins/mute.py @@ -1,4 +1,3 @@ -# mute plugin by lukeroge and neersighted from util import hook muted = [] @@ -64,7 +63,7 @@ def mute(inp, input=None, db=None): def unmute(inp, input=None, db=None): ".unmute -- Makes the bot listen to ." target = inp - + if is_muted(target): unmute_target(target) input.notice("%s has been unmuted." % target) From e7d69e63c07aa4c0856a4ef61af131883e5806c9 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Fri, 23 Mar 2012 13:22:23 +1300 Subject: [PATCH 106/205] Pep-8 --- plugins/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/admin.py b/plugins/admin.py index 4a92cd3..4b77638 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -12,7 +12,7 @@ def admins(inp, bot=None): ".admins -- Lists the bot's admins." admins = bot.config["admins"] return ", ".join(admins) - + @hook.command(autohelp=False) def channels(inp, conn=None): From 549bb70690e4f89cc9e3ff1c808255cf64c0f456 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Fri, 23 Mar 2012 13:32:48 +1300 Subject: [PATCH 107/205] PEP-8 --- plugins/factoids.py | 10 ++++++---- plugins/gitio.py | 3 ++- plugins/shorten.py | 19 +++++++------------ plugins/slogan.py | 2 ++ plugins/twitter.py | 14 ++++---------- 5 files changed, 21 insertions(+), 27 deletions(-) diff --git a/plugins/factoids.py b/plugins/factoids.py index 74b3e1f..106aa14 100755 --- a/plugins/factoids.py +++ b/plugins/factoids.py @@ -24,7 +24,8 @@ def db_init(db): def get_memory(db, word): - row = db.execute("select data from mem where word=lower(?)", [word]).fetchone() + row = db.execute("select data from mem where word=lower(?)", + [word]).fetchone() if row: return row[0] else: @@ -46,7 +47,8 @@ def multiwordReplace(text, wordDic): @hook.command("r", adminonly=True) @hook.command(adminonly=True) def remember(inp, nick='', db=None, say=None, input=None, notice=None): - ".remember [+] -- Remembers with . Add + to to append." + ".remember [+] -- Remembers with . Add +" + " to to append." db_init(db) append = False @@ -78,8 +80,8 @@ def remember(inp, nick='', db=None, say=None, input=None, notice=None): if append: notice("Appending %s to %s" % (new, data.replace('"', "''"))) else: - notice('Forgetting existing data (%s), remembering this instead!' % \ - data.replace('"', "''")) + notice('Forgetting existing data (%s), remembering this instead!' + % data.replace('"', "''")) return else: notice('Remembered!') diff --git a/plugins/gitio.py b/plugins/gitio.py index 287eed0..3aa825d 100755 --- a/plugins/gitio.py +++ b/plugins/gitio.py @@ -5,7 +5,8 @@ import urllib2 @hook.command def gitio(inp): - ".gitio [code] -- Shorten Github URLs with git.io. [code] is a optional custom short code." + ".gitio [code] -- Shorten Github URLs with git.io. [code] is" + " a optional custom short code." split = inp.split(" ") url = split[0] diff --git a/plugins/shorten.py b/plugins/shorten.py index 8a028a4..7e7daf2 100755 --- a/plugins/shorten.py +++ b/plugins/shorten.py @@ -1,4 +1,4 @@ -# Plugin by Lukeroge +# Plugin by Lukeroge # from util import hook, http @@ -6,6 +6,7 @@ from re import match from urllib2 import urlopen, Request, HTTPError from urllib import urlencode + class ShortenError(Exception): def __init__(self, value): self.value = value @@ -13,13 +14,15 @@ class ShortenError(Exception): def __str__(self): return repr(self.value) + def bitly(url, user, apikey): try: if url[:8] == "https://": pass elif url[:7] != "http://": url = "http://" + url - params = urlencode({'longUrl': url, 'login': user, 'apiKey': apikey, 'format': 'json'}) + params = urlencode({'longUrl': url, 'login': user, 'apiKey': apikey, + 'format': 'json'}) j = http.get_json("http://api.bit.ly/v3/shorten?%s" % params) if j['status_code'] == 200: return j['data']['url'] @@ -27,20 +30,12 @@ def bitly(url, user, apikey): except (HTTPError, ShortenError): return "Could not shorten %s!" % url + @hook.command -def shorten(inp, bot = None): +def shorten(inp, bot=None): ".shorten - Makes an j.mp/bit.ly shortlink to the url provided." api_user = bot.config.get("api_keys", {}).get("bitly_user", None) api_key = bot.config.get("api_keys", {}).get("bitly_api", None) if api_key is None: return "error: no api key set" return bitly(inp, api_user, api_key) - -@hook.command -def expand(inp, bot = None): - ".expand - Gets the original URL from a shortened link." - try: - url = http.get_url(inp) - except HTTPError, e: - return "Failed to expand URL." - return url diff --git a/plugins/slogan.py b/plugins/slogan.py index bc31db6..711fe6c 100755 --- a/plugins/slogan.py +++ b/plugins/slogan.py @@ -2,10 +2,12 @@ from util import hook, http, misc import re import string + def sloganize(word): bytes = http.get('http://www.sloganizer.net/en/outbound.php', slogan=word) return bytes + @hook.command("slogan") def sloganizr(inp, nick=None, say=None, input=None): ".slogan -- Makes a slogan for ." diff --git a/plugins/twitter.py b/plugins/twitter.py index 7acaa19..9b78fef 100755 --- a/plugins/twitter.py +++ b/plugins/twitter.py @@ -12,19 +12,13 @@ from util import hook, http, timesince def unescape_xml(string): - # unescape the 5 chars that might be escaped in xml - - # gratuitously functional - # return reduce(lambda x, y: x.replace(*y), (string, - # zip('> < ' "e; &'.split(), '> < \' " &'.split())) - - # boring, normal return string.replace('>', '>').replace('<', '<').replace(''', "'").replace('"e;', '"').replace('&', '&') history = [] history_max_size = 250 + def parseDateTime(s): if s is None: return None @@ -40,7 +34,7 @@ def parseDateTime(s): tzname = 'UTC' tz = FixedOffset(timedelta(hours=tzhour, minutes=tzmin), tzname) - + x = datetime.strptime(datestr, "%Y-%m-%d %H:%M:%S") if fractional is None: fractional = '0' @@ -154,9 +148,9 @@ def twitter(inp): strptime(time.text, '%a %b %d %H:%M:%S +0000 %Y')) - time_pretty = timesince.timesince(parseDateTime(time_raw), datetime.utcnow()) + time_nice = timesince.timesince(parseDateTime(time_raw), datetime.utcnow()) text = unescape_xml(tweet.find(text).text.replace('\n', '')) screen_name = tweet.find(screen_name).text - return "\x02@%s\x02: %s (%s ago)" % (screen_name, text, time_pretty) + return "\x02@%s\x02: %s (%s ago)" % (screen_name, text, time_nice) From 954ea57fce4f3590d0c9883bd20c346ce59cc307 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Fri, 23 Mar 2012 14:51:34 +1300 Subject: [PATCH 108/205] standardised multiline command docstrings --- plugins/8ball.py | 2 +- plugins/bf.py | 1 + plugins/choose.py | 2 +- plugins/dice.py | 2 +- plugins/gitio.py | 2 +- plugins/quote.py | 2 +- plugins/weather.py | 4 ++-- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/8ball.py b/plugins/8ball.py index e69b95a..392c333 100755 --- a/plugins/8ball.py +++ b/plugins/8ball.py @@ -36,7 +36,7 @@ answers = [g + "As I see it, yes", @hook.command('8ball') def eightball(inp, me=None): - ".8ball -- The all knowing magic eight ball, "\ + ".8ball -- The all knowing magic eight ball, " \ "in electronic form. Ask and it shall be answered!" global nextresponsenumber inp = inp.strip() diff --git a/plugins/bf.py b/plugins/bf.py index e51500b..32e9f3c 100755 --- a/plugins/bf.py +++ b/plugins/bf.py @@ -10,6 +10,7 @@ from util import hook BUFFER_SIZE = 5000 MAX_STEPS = 1000000 + @hook.command('brainfuck') @hook.command def bf(inp): diff --git a/plugins/choose.py b/plugins/choose.py index 62e87d7..1ba5b2e 100755 --- a/plugins/choose.py +++ b/plugins/choose.py @@ -6,7 +6,7 @@ from util import hook @hook.command def choose(inp): - ".choose , [choice2], [choice3], [choice4], ... -- "\ + ".choose , [choice2], [choice3], [choice4], ... -- " \ "Randomly picks one of the given choices." c = re.findall(r'([^,]+)', inp) diff --git a/plugins/dice.py b/plugins/dice.py index d5aff31..dd2ee2f 100755 --- a/plugins/dice.py +++ b/plugins/dice.py @@ -37,7 +37,7 @@ def nrolls(count, n): #@hook.regex(valid_diceroll, re.I) @hook.command def dice(inp): - ".dice -- Simulates dicerolls. Example of :" + ".dice -- Simulates dicerolls. Example of :" \ " '.dice 2d20-d5+4 roll 2'. D20s, subtract 1D5, add 4" try: # if inp is a re.match object... diff --git a/plugins/gitio.py b/plugins/gitio.py index 3aa825d..6c5c8fa 100755 --- a/plugins/gitio.py +++ b/plugins/gitio.py @@ -5,7 +5,7 @@ import urllib2 @hook.command def gitio(inp): - ".gitio [code] -- Shorten Github URLs with git.io. [code] is" + ".gitio [code] -- Shorten Github URLs with git.io. [code] is" \ " a optional custom short code." split = inp.split(" ") url = split[0] diff --git a/plugins/quote.py b/plugins/quote.py index dd1680b..6553018 100755 --- a/plugins/quote.py +++ b/plugins/quote.py @@ -115,7 +115,7 @@ def get_quote_by_chan(db, chan, num=False): @hook.command def quote(inp, nick='', chan='', db=None, notice=None): ".quote [#chan] [nick] [#n]/.quote add -- Gets " \ - "random or [#n]th quote by or from <#chan>/adds quote." + "random or [#n]th quote by or from <#chan>/adds quote." create_table_if_not_exists(db) add = re.match(r"add[^\w@]+(\S+?)>?\s+(.*)", inp, re.I) diff --git a/plugins/weather.py b/plugins/weather.py index 9f6193d..daff1df 100755 --- a/plugins/weather.py +++ b/plugins/weather.py @@ -5,8 +5,8 @@ from util import hook, http @hook.command(autohelp=False) def forecast(inp, nick='', server='', reply=None, db=None, notice=None, say=None): - ".forecast [dontsave] -- Gets a weather forecast "\ - "for from Google." + ".forecast [dontsave] -- Gets a weather forecast" \ + " for from Google." loc = inp dontsave = loc.endswith(" dontsave") From 90aa8976fcd6df50d97712c87c302128d34f04d2 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Fri, 23 Mar 2012 17:51:02 +1300 Subject: [PATCH 109/205] upgraded ping.py --- plugins/ping.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/plugins/ping.py b/plugins/ping.py index 310ace0..e2f6fe2 100755 --- a/plugins/ping.py +++ b/plugins/ping.py @@ -3,6 +3,8 @@ from util import hook import subprocess import re +PING_REGEX = "rtt min/avg/max/mdev = (\d+.\d+)/(\d+.\d+)/(\d+.\d+)/(\d+.\d+)" + @hook.command def ping(inp, reply=None): @@ -12,8 +14,7 @@ def ping(inp, reply=None): host = args[0] if len(args) > 1: - count = args[1] - count = int(count) + count = int(args[1]) if count > 20: count = 20 else: @@ -25,14 +26,10 @@ def ping(inp, reply=None): reply("Attempting to ping %s %s times..." % (host, count)) - pingcmd = subprocess.check_output("ping -c "\ - + count + " " + host, shell=True) + pingcmd = subprocess.check_output(["ping", "-c", count, host]) if 'request timed out' in pingcmd or 'unknown host' in pingcmd: return "error: could not ping host" else: - m = re.search(r"rtt min/avg/max/mdev = "\ - "(\d+.\d+)/(\d+.\d+)/(\d+.\d+)/(\d+.\d+)", pingcmd) - return "min: %sms, max: %sms, average: %sms, range: %sms, count: %s"\ + m = re.search(PING_REGEX, pingcmd) + return "min: %sms, max: %sms, average: %sms, range: %sms, count: %s" \ % (m.group(1), m.group(3), m.group(2), m.group(4), count) - - From 3224bbe37005ec0bbec29fc271c984e3b72f96a9 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Fri, 23 Mar 2012 18:08:58 +1300 Subject: [PATCH 110/205] started cleaning up admin.py --- plugins/admin.py | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index 4b77638..4b65124 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -17,21 +17,19 @@ def admins(inp, bot=None): @hook.command(autohelp=False) def channels(inp, conn=None): ".channels -- Lists the channels that the bot is in." - channels = conn.channels - return "I am in these channels: " + ", ".join(channels) + return "I am in these channels: " + ", ".join(conn.channels) @hook.command(autohelp=False, adminonly=True) -def stop(inp, input=None): +def stop(inp, nick=None, conn=None): ".stop [reason] -- Kills the bot with [reason] as its quit message." if inp: - input.conn.send("QUIT :Killed by " + input.nick + " (" + inp + ")") + conn.cmd("QUIT", ["Killed by %s (%s)" % (nick, inp)]) else: - input.conn.send("QUIT :Killed by " + input.nick + " (no reason)") + conn.cmd("QUIT", ["Killed by %s." % nick]) time.sleep(5) subprocess.call("./cloudbot stop", shell=True) - @hook.command("reboot", autohelp=False, adminonly=True) @hook.command(autohelp=False, adminonly=True) def restart(inp, input=None): @@ -44,34 +42,32 @@ def restart(inp, input=None): os.execl("./cloudbot", "restart") -@hook.command("clearlogs", autohelp=False, adminonly=True) @hook.command(autohelp=False, adminonly=True) -def clear(inp, input=None): - ".clear -- Clears the bots log(s)." - time.sleep(5) +def clearlogs(inp, input=None): + ".clearlogs -- Clears the bots log(s)." subprocess.call("./cloudbot clear", shell=True) @hook.command(adminonly=True) def join(inp, input=None, notice=None): - ".join -- Joins ." + ".join -- joins ." notice("Attempting to join " + inp + "...") - input.conn.send("JOIN " + inp) + conn.cmd("JOIN", [inp]) @hook.command(adminonly=True) -def cycle(inp, input=None, db=None, notice=None): - ".cycle -- Cycles ." +def cycle(inp, conn=None, notice=None): + ".cycle -- cycles ." notice("Attempting to cycle " + inp + "...") - input.conn.send("PART " + inp) - input.conn.send("JOIN " + inp) + conn.cmd("PART", [inp]) + conn.cmd("JOIN", [inp]) @hook.command(adminonly=True) -def part(inp, input=None, notice=None): - ".part -- Parts from ." +def part(inp, conn=None, notice=None): + ".part -- parts ." notice("Attempting to part from " + inp + "...") - input.conn.send("PART " + inp) + conn.cmd("PART", [inp]) @hook.command(adminonly=True) @@ -85,14 +81,14 @@ def nick(inp, input=None, notice=None, set_nick=None): @hook.command(adminonly=True) -def raw(inp, input=None, notice=None): +def raw(inp, conn=None, notice=None): ".raw -- Sends a RAW IRC command." notice("Raw command sent.") - input.conn.send(inp) + conn.send(inp) @hook.command(adminonly=True) -def kick(inp, input=None, notice=None): +def kick(inp, chan=None, notice=None): ".kick [channel] [reason] -- kicks a user." split = inp.split(" ") if split[0][0] == "#": From f025df92b62326c3107d340f373825f1ac674024 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Fri, 23 Mar 2012 18:14:58 +1300 Subject: [PATCH 111/205] PEP-8 + ping.py changes --- plugins/ping.py | 6 +++--- plugins/urlparse.py | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/ping.py b/plugins/ping.py index e2f6fe2..c9424da 100755 --- a/plugins/ping.py +++ b/plugins/ping.py @@ -3,7 +3,7 @@ from util import hook import subprocess import re -PING_REGEX = "rtt min/avg/max/mdev = (\d+.\d+)/(\d+.\d+)/(\d+.\d+)/(\d+.\d+)" +ping_regex = re.compile(r"(\d+.\d+)/(\d+.\d+)/(\d+.\d+)/(\d+.\d+)") @hook.command @@ -27,9 +27,9 @@ def ping(inp, reply=None): reply("Attempting to ping %s %s times..." % (host, count)) pingcmd = subprocess.check_output(["ping", "-c", count, host]) - if 'request timed out' in pingcmd or 'unknown host' in pingcmd: + if "request timed out" in pingcmd or "unknown host" in pingcmd: return "error: could not ping host" else: - m = re.search(PING_REGEX, pingcmd) + m = re.search(ping_regex, pingcmd) return "min: %sms, max: %sms, average: %sms, range: %sms, count: %s" \ % (m.group(1), m.group(3), m.group(2), m.group(4), count) diff --git a/plugins/urlparse.py b/plugins/urlparse.py index 088bc85..d8a9b62 100755 --- a/plugins/urlparse.py +++ b/plugins/urlparse.py @@ -1,7 +1,8 @@ from util import hook, http, urlnorm import re -titler = re.compile(r'(?si)(.+?)'); +titler = re.compile(r'(?si)(.+?)') + def parse(url): """ an improved version of our parsing code - now regex powered """ @@ -20,17 +21,17 @@ def parse(url): title = match.group(1) except: return "Could not parse URL! Are you sure its valid?" - + title = http.unescape(title) - + # if the url has been redirected, show us if real_url == url: return title else: return u"%s [%s]" % (title, real_url) + @hook.command def title(inp): ".title -- gets the title of a web page" return parse(inp) - From 51a31caf99557857e8bf062a10f5b90626d248cb Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 23 Mar 2012 19:36:24 -0700 Subject: [PATCH 112/205] Update plugins/urlparse.py --- plugins/urlparse.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/urlparse.py b/plugins/urlparse.py index d8a9b62..58fb8e2 100755 --- a/plugins/urlparse.py +++ b/plugins/urlparse.py @@ -4,8 +4,7 @@ import re titler = re.compile(r'(?si)(.+?)') -def parse(url): - """ an improved version of our parsing code - now regex powered """ +def gettitle(url): url = urlnorm.normalize(url.encode('utf-8')) url = url.decode('utf-8') # add http if its missing @@ -34,4 +33,4 @@ def parse(url): @hook.command def title(inp): ".title -- gets the title of a web page" - return parse(inp) + return gettitle(inp) From f5d09dc35e1348a2aa48b49da8d0d8a3b69d599c Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 23 Mar 2012 20:13:50 -0700 Subject: [PATCH 113/205] remove derpy config settings --- core/config.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/core/config.py b/core/config.py index 0401d3a..d8b5986 100755 --- a/core/config.py +++ b/core/config.py @@ -46,10 +46,6 @@ if not os.path.exists('config'): "factoids": { "prefix": false - }, - "urlparse": - { - "enabled": false } }, "censored_strings": From cb33198bfb52a32f33b2d27fbc3b001cada47cc4 Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 23 Mar 2012 20:34:33 -0700 Subject: [PATCH 114/205] fix help messages --- plugins/mute.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/mute.py b/plugins/mute.py index d59ded5..be378c9 100755 --- a/plugins/mute.py +++ b/plugins/mute.py @@ -40,11 +40,11 @@ def mutesieve(bot, input, func, type, args): @hook.command(autohelp=False) def listmuted(inp, bot=None): - ".listmuted -- Lists muted users/channels." + ".listmuted -- Lists muted channels/users." if muted: - return "Muted users/channels are: " + ", ".join(muted) + return "Muted channels/users are: " + ", ".join(muted) else: - return "No users are currently muted." + return "No channels/users are currently muted." @hook.command(adminonly=True) From ac9e567eaf69df7d8d8734537c832f6891da3c0c Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 23 Mar 2012 20:42:08 -0700 Subject: [PATCH 115/205] renamed mute.py to ignore.py --- plugins/ignore.py | 73 +++++++++++++++++++++++++++++++++++++++++++++++ plugins/mute.py | 73 ----------------------------------------------- 2 files changed, 73 insertions(+), 73 deletions(-) create mode 100755 plugins/ignore.py delete mode 100755 plugins/mute.py diff --git a/plugins/ignore.py b/plugins/ignore.py new file mode 100755 index 0000000..fbeeba7 --- /dev/null +++ b/plugins/ignore.py @@ -0,0 +1,73 @@ +from util import hook + +ignorelist = [] + + +def ignore_target(target): + """ ignores someone """ + target = target.lower() + ignorelist.append(target) + + +def unignore_target(target): + """ unignores someone """ + target = target.lower() + ignorelist.remove(target) + + +def is_ignored(target): + """ checks of someone is ignored """ + target = target.lower() + if target in ignorelist: + return True + else: + return False + + +@hook.sieve +def ignoresieve(bot, input, func, type, args): + """ blocks input from ignored channels/users """ + # don't block input to event hooks + if type == "event": + return input + if is_ignored(input.chan) or is_ignored(input.nick): + if input.command == "PRIVMSG" and input.lastparam[1:] == "unignore": + return input + else: + return None + return input + + +@hook.command(autohelp=False) +def ignored(inp, bot=None): + ".ignored -- Lists ignored channels/users." + if ignorelist: + return "Ignored channels/users are: " + ", ".join(ignorelist) + else: + return "No channels/users are currently ignored." + + +@hook.command(adminonly=True) +def ignore(inp, input=None, notice=None): + ".ignore -- Makes the bot ignore ." + target = inp + + if is_ignored(target): + notice("%s is already ignored." % target) + else: + ignore_target(target) + notice("%s has been ignored." % target) + + +@hook.command(adminonly=True) +def unignore(inp, input=None, notice=None): + ".unignore -- Makes the bot listen to ." + target = inp + + if is_ignored(target): + unignore_target(target) + notice("%s has been unignored." % target) + return + else: + notice("%s is not ignored." % target) + return diff --git a/plugins/mute.py b/plugins/mute.py deleted file mode 100755 index be378c9..0000000 --- a/plugins/mute.py +++ /dev/null @@ -1,73 +0,0 @@ -from util import hook - -muted = [] - - -def mute_target(target): - """ mutes someone """ - target = target.lower() - muted.append(target) - - -def unmute_target(target): - """ unmutes someone """ - target = target.lower() - muted.remove(target) - - -def is_muted(target): - """ checks of someone is muted """ - target = target.lower() - if target in muted: - return True - else: - return False - - -@hook.sieve -def mutesieve(bot, input, func, type, args): - """ blocks input from muted channels/users """ - # don't block input to event hooks - if type == "event": - return input - if is_muted(input.chan) or is_muted(input.nick): - if input.command == "PRIVMSG" and input.lastparam[1:] == "unmute": - return input - else: - return None - return input - - -@hook.command(autohelp=False) -def listmuted(inp, bot=None): - ".listmuted -- Lists muted channels/users." - if muted: - return "Muted channels/users are: " + ", ".join(muted) - else: - return "No channels/users are currently muted." - - -@hook.command(adminonly=True) -def mute(inp, input=None, db=None): - ".mute -- Makes the bot ignore ." - target = inp - - if is_muted(target): - input.notice("%s is already muted." % target) - else: - mute_target(target) - input.notice("%s has been muted." % target) - - -@hook.command(adminonly=True) -def unmute(inp, input=None, db=None): - ".unmute -- Makes the bot listen to ." - target = inp - - if is_muted(target): - unmute_target(target) - input.notice("%s has been unmuted." % target) - return - else: - input.notice("%s is not muted." % target) - return From 25fd9358f21c76fb86d681a7a284746050952d80 Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 23 Mar 2012 21:17:26 -0700 Subject: [PATCH 116/205] Update core/config.py --- core/config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/config.py b/core/config.py index d8b5986..3354404 100755 --- a/core/config.py +++ b/core/config.py @@ -38,8 +38,8 @@ if not os.path.exists('config'): "bitly_api": "INSERT API KEY FROM bitly.com HERE", "wolframalpha": "INSERT API KEY FROM wolframalpha.com HERE", "lastfm": "INSERT API KEY FROM lastfm HERE", - "mc_user": "INSERT MINECRAFT USERNAME HERE", - "mc_pass": "INSERT MINECRAFT PASSWORD HERE" + "mc_user": "INSERT minecraft USERNAME HERE", + "mc_pass": "INSERT minecraft PASSWORD HERE" }, "plugins": { @@ -53,7 +53,7 @@ if not os.path.exists('config'): "mypass", "mysecret" ], - "admins": ["myname"] + "admins": ["myname@myhost"] }''') + '\n') print "Config generated!" print "Please edit the config now!" From 9ce44024c2fcda74dbea3985979fd723996a9551 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sat, 24 Mar 2012 19:15:11 -0700 Subject: [PATCH 117/205] fixes --- plugins/admin.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index 4b65124..38487e1 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -49,15 +49,15 @@ def clearlogs(inp, input=None): @hook.command(adminonly=True) -def join(inp, input=None, notice=None): - ".join -- joins ." +def join(inp, conn=None, notice=None): + ".join -- Joins ." notice("Attempting to join " + inp + "...") conn.cmd("JOIN", [inp]) @hook.command(adminonly=True) def cycle(inp, conn=None, notice=None): - ".cycle -- cycles ." + ".cycle -- Cycles ." notice("Attempting to cycle " + inp + "...") conn.cmd("PART", [inp]) conn.cmd("JOIN", [inp]) @@ -65,7 +65,7 @@ def cycle(inp, conn=None, notice=None): @hook.command(adminonly=True) def part(inp, conn=None, notice=None): - ".part -- parts ." + ".part -- Parts from ." notice("Attempting to part from " + inp + "...") conn.cmd("PART", [inp]) @@ -88,8 +88,10 @@ def raw(inp, conn=None, notice=None): @hook.command(adminonly=True) -def kick(inp, chan=None, notice=None): - ".kick [channel] [reason] -- kicks a user." +def kick(inp, input=None, chan=None, conn=None, notice=None): + ".kick [channel] [reason] -- Makes the bot kick in [channel] "\ + "If [channel] is blank the bot will kick the in "\ + "the channel the command was used in." split = inp.split(" ") if split[0][0] == "#": chan = split[0] @@ -113,11 +115,11 @@ def kick(inp, chan=None, notice=None): out = out + " :" + reason notice("Attempting to kick %s from %s..." % (user, chan)) - input.conn.send(out) + conn.send(out) @hook.command(adminonly=True) -def say(inp, input=None, notice=None): +def say(inp, conn=None, notice=None): ".say [channel] -- Makes the bot say in [channel]. "\ "If [channel] is blank the bot will say the in "\ "the channel the command was used in." @@ -134,12 +136,12 @@ def say(inp, input=None, notice=None): message = message + x + " " message = message[:-1] out = "PRIVMSG %s :%s" % (input.chan, message) - input.conn.send(out) + conn.send(out) @hook.command("me", adminonly=True) @hook.command(adminonly=True) -def act(inp, input=None, notice=None): +def act(inp, conn=None, notice=None): ".act [channel] -- Makes the bot act out in [channel] "\ "If [channel] is blank the bot will act the in "\ "the channel the command was used in." @@ -156,7 +158,7 @@ def act(inp, input=None, notice=None): message = message + x + " " message = message[:-1] out = "PRIVMSG %s :\x01ACTION %s\x01" % (input.chan, message) - input.conn.send(out) + conn.send(out) @hook.command(adminonly=True) From f26e2cd094751e00b3b5994cd5637c3246213588 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Mon, 26 Mar 2012 11:25:57 +1300 Subject: [PATCH 118/205] You can now admin users by nick --- plugins/sieve.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/plugins/sieve.py b/plugins/sieve.py index 46e54b7..64411ee 100755 --- a/plugins/sieve.py +++ b/plugins/sieve.py @@ -36,11 +36,7 @@ def sieve_suite(bot, input, func, kind, args): if args.get('adminonly', False): admins = bot.config.get('admins', []) - # admins = ["u3601@irccloud.com", "brjannc@smurfed.org"] - - mask = input.user + "@" + input.host - - if mask not in admins: + if input.mask not in admins and input.nick not in admins: return None return input From bd7ffe11ed79b24fdab46145923a0de3604aaf9f Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 26 Mar 2012 17:17:19 +1300 Subject: [PATCH 119/205] Refactoring + Windows fixes --- plugins/data/fortunes.txt | 51 +++++++++++++++++++++++++++++++++ plugins/fortune.py | 60 ++++++--------------------------------- plugins/mcitems.py | 4 +-- 3 files changed, 61 insertions(+), 54 deletions(-) create mode 100755 plugins/data/fortunes.txt diff --git a/plugins/data/fortunes.txt b/plugins/data/fortunes.txt new file mode 100755 index 0000000..1c01b36 --- /dev/null +++ b/plugins/data/fortunes.txt @@ -0,0 +1,51 @@ +"Help! I'm stuck in the fortune cookie factory! +He who laughs at himself never runs out of things to laugh at. +The world is your oyster. +Today will be a good day. +Life's short, party naked. +Haters gonna hate. +You are amazing and let no one tell you otherwise. +A starship ride has been promised to you by the galactic wizard. +That wasn’t chicken. +Don’t fry bacon in the nude. +Take calculated risks. That is quite different from being rash. +DO THE IMPOSSIBLE, SEE THE INVISIBLE. +You cannot plough a field by turning it over in your mind. Unless you have telekinesis. +No one can make you feel inferior without your consent. +Never lose the ability to find beauty in ordinary things. +Ignore previous fortune. +Smile more. +You are the dancing queen. +YOU'RE THE BEST AROUND, NOTHIN'S GONNA EVER KEEP YA DOWN. +The cake is a lie. +Never take life seriously. Nobody gets out alive anyway. +Friendship is like peeing on yourself: everyone can see it, but only you get the warm feeling that it brings. +Never go to a doctor whose office plants have died. +Always remember you're unique, just like everyone else. +What if everything is an illusion and nothing exists? In that case, I definitely overpaid for my carpet. +Even if you are on the right track, you will get run over if you just sit there. +Think like a man of action, and act like a man of thought. +When in doubt, lubricate. +It is time for you to live up to your family name and face FULL LIFE CONSEQUENCES. +It's a good day to do what has to be done. +Move near the countryside and you will be friends of John Freeman. +If you can't beat 'em, mock 'em. +Use gun. And if that don't work, use more gun. +LOOK OUT BEHIND YOU +This message will self destruct in 10 seconds. +You'll never know what you can do until you try. +You are talented in many ways +Be both a speaker of words and a doer of deeds. +A visit to a strange place will bring you renewed perspective. +A passionate new romance will appear in your life when you least expect it. +If you care enough for a result, you will most certainly attain it. +To be loved, be loveable. +Step away from the power position for one day. +If you want to get a sure crop with a big yield, sow wild oats. +It doesn't take guts to quit. +You can expect a change for the better in job or status in the future. +As the wallet grows, so do the needs. +You have a reputation for being straightforward and honest. +Learn a new language and get a new soul. +A tall dark stranger will soon enter our life. +Keep staring. I'll do a trick. diff --git a/plugins/fortune.py b/plugins/fortune.py index 7f1f4b4..e556406 100755 --- a/plugins/fortune.py +++ b/plugins/fortune.py @@ -2,64 +2,20 @@ from util import hook import re import random -fortunes = ["Help! I'm stuck in the fortune cookie factory!", - "He who laughs at himself never runs out of things to laugh at.", - "The world is your oyster.", - "Today will be a good day.", - "Life's short, party naked.", - "Haters gonna hate.", - "You are amazing and let no one tell you otherwise.", - "A starship ride has been promised to you by the galactic wizard.", - "That wasn’t chicken.", - "Don’t fry bacon in the nude.", - "Take calculated risks. That is quite different from being rash.", - "DO THE IMPOSSIBLE, SEE THE INVISIBLE.", - "You cannot plough a field by turning it over in your mind. Unless you have telekinesis.", - "No one can make you feel inferior without your consent.", - "Never lose the ability to find beauty in ordinary things.", - "Ignore previous fortune.", - "Smile more.", - "You are the dancing queen.", - "YOU'RE THE BEST AROUND, NOTHIN'S GONNA EVER KEEP YA DOWN.", - "The cake is a lie.", - "Never take life seriously. Nobody gets out alive anyway.", - "Friendship is like peeing on yourself: everyone can see it, but only you get the warm feeling that it brings.", - "Never go to a doctor whose office plants have died.", - "Always remember you're unique, just like everyone else.", - "What if everything is an illusion and nothing exists? In that case, I definitely overpaid for my carpet.", - "Even if you are on the right track, you will get run over if you just sit there.", - "Think like a man of action, and act like a man of thought.", - "When in doubt, lubricate.", - "It is time for you to live up to your family name and face FULL LIFE CONSEQUENCES.", - "It's a good day to do what has to be done.", - "Move near the countryside and you will be friends of John Freeman.", - "If you can't beat 'em, mock 'em.", - "Use gun. And if that don't work, use more gun.", - "LOOK OUT BEHIND YOU", - "This message will self destruct in 10 seconds.", - "You'll never know what you can do until you try.", - "You are talented in many ways", - "Be both a speaker of words and a doer of deeds.", - "A visit to a strange place will bring you renewed perspective.", - "A passionate new romance will appear in your life when you least expect it.", - "If you care enough for a result, you will most certainly attain it.", - "To be loved, be loveable.", - "Step away from the power position for one day.", - "If you want to get a sure crop with a big yield, sow wild oats.", - "It doesn't take guts to quit.", - "You can expect a change for the better in job or status in the future.", - "As the wallet grows, so do the needs.", - "You have a reputation for being straightforward and honest.", - "Learn a new language and get a new soul.", - "A tall dark stranger will soon enter our life.", - "Keep staring. I'll do a trick."] +fortunes = [] + +with open("plugins/data/fortunes.txt") as f: + for line in f.readlines(): + if line.startswith("//"): + continue + fortunes.append(line) @hook.command(autohelp=False) def fortune(inp, nick=None, say=None, input=None): ".fortune -- Fortune cookies on demand." msg = "(" + nick + ") " + random.choice(fortunes) - if re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()) and inp != "": + if inp: msg = "(@" + inp + ") " + random.choice(fortunes) say(msg) diff --git a/plugins/mcitems.py b/plugins/mcitems.py index b97ce30..bcfb378 100644 --- a/plugins/mcitems.py +++ b/plugins/mcitems.py @@ -23,7 +23,7 @@ class Recipe(object): return self.line -with open("./plugins/data/recipes.txt") as f: +with open("plugins/data/recipes.txt") as f: for line in f.readlines(): if line.startswith("//"): continue @@ -38,7 +38,7 @@ with open("./plugins/data/recipes.txt") as f: ids = [] -with open("./plugins/data/itemids.txt") as f: +with open("plugins/data/itemids.txt") as f: for line in f.readlines(): if line.startswith("//"): continue From b725d49c33b81043ff0d509ba2df1f710fa35df7 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 26 Mar 2012 17:28:22 +1300 Subject: [PATCH 120/205] started switching violence.py to text files --- plugins/data/slap_items.txt | 19 ++++++++++++++++ plugins/data/slaps.txt | 12 ++++++++++ plugins/sieve.py | 1 + plugins/violence.py | 44 +++++++++++-------------------------- 4 files changed, 45 insertions(+), 31 deletions(-) create mode 100755 plugins/data/slap_items.txt create mode 100755 plugins/data/slaps.txt diff --git a/plugins/data/slap_items.txt b/plugins/data/slap_items.txt new file mode 100755 index 0000000..2f53980 --- /dev/null +++ b/plugins/data/slap_items.txt @@ -0,0 +1,19 @@ +cast iron skillet +large trout +baseball bat +wooden cane +CRT monitor +diamond sword +physics textbook +television +mau5head +five ton truck +roll of duct tape +book +cobblestone block +lava bucket +rubber chicken +gold block +fire extinguisher +heavy rock +chunk of dirt diff --git a/plugins/data/slaps.txt b/plugins/data/slaps.txt new file mode 100755 index 0000000..ae23e7b --- /dev/null +++ b/plugins/data/slaps.txt @@ -0,0 +1,12 @@ +slaps with a . +slaps around a bit with a . +throws a at . +chucks a few s at . +grabs a and throws it in 's face. +launches a in 's general direction. +sits on 's face, while slamming a into their crotch. +holds down and repeatedly whacks them with a . +prods with a flaming . +picks up a , and whacks with it. +ties to a chair and throws a at them. +hits on the head with a . diff --git a/plugins/sieve.py b/plugins/sieve.py index 64411ee..05bf678 100755 --- a/plugins/sieve.py +++ b/plugins/sieve.py @@ -36,6 +36,7 @@ def sieve_suite(bot, input, func, kind, args): if args.get('adminonly', False): admins = bot.config.get('admins', []) + if input.mask not in admins and input.nick not in admins: return None diff --git a/plugins/violence.py b/plugins/violence.py index 286ca1c..613ee4f 100644 --- a/plugins/violence.py +++ b/plugins/violence.py @@ -3,38 +3,20 @@ import re import random -slaps = ["slaps with a .", - "slaps around a bit with a .", - "throws a at .", - "chucks a few s at .", - "grabs a and throws it in 's face.", - "launches a in 's general direction.", - "sits on 's face, while slamming a into their crotch.", - "holds down and repeatedly whacks them with a .", - "prods with a flaming .", - "picks up a , and whacks with it.", - "ties to a chair and throws a at them.", - "hits on the head with a ."] +slaps = [] +slap_items = [] -items = ["cast iron skillet", - "large trout", - "baseball bat", - "wooden cane", - "CRT monitor", - "diamond sword", - "physics textbook", - "television", - "mau5head", - "five ton truck", - "roll of duct tape", - "book", - "cobblestone block", - "lava bucket", - "rubber chicken", - "gold block", - "fire extinguisher", - "heavy rock", - "chunk of dirt"] +with open("plugins/data/slaps.txt") as f: + for line in f.readlines(): + if line.startswith("//"): + continue + slaps.append(line) + +with open("plugins/data/slap_items.txt") as f: + for line in f.readlines(): + if line.startswith("//"): + continue + items.append(line) larts = ["swaps 's shampoo with glue.", "installs Windows on 's computer.", From 18b90a2b2ac9898244797e12acf578d353632c86 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 26 Mar 2012 17:34:08 +1300 Subject: [PATCH 121/205] Still buggy, will fix soon (need to go out) --- plugins/violence.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/violence.py b/plugins/violence.py index 613ee4f..015491b 100644 --- a/plugins/violence.py +++ b/plugins/violence.py @@ -2,6 +2,7 @@ from util import hook import re import random +nick_re = re.compile(r"^[A-Za-z0-9_|.-\]\[]*$") slaps = [] slap_items = [] @@ -16,7 +17,7 @@ with open("plugins/data/slap_items.txt") as f: for line in f.readlines(): if line.startswith("//"): continue - items.append(line) + slap_items.append(line) larts = ["swaps 's shampoo with glue.", "installs Windows on 's computer.", @@ -163,7 +164,7 @@ def slap(inp, me=None, nick=None, input=None, notice=None): ".slap -- Makes the bot slap ." inp = inp.strip() - if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): + if not re.match(nick_re, inp.lower()): notice("Invalid username!") return @@ -171,7 +172,7 @@ def slap(inp, me=None, nick=None, input=None, notice=None): target = re.sub ('', nick, random.choice(slaps)) else: target = re.sub ('', inp, random.choice(slaps)) - msg = re.sub ('', random.choice(items), target) + msg = re.sub ('', random.choice(slap_items), target) me(msg) @@ -181,7 +182,7 @@ def lart(inp, me=None, nick=None, input=None, notice=None): ".lart -- Makes the bot LART ." inp = inp.strip() - if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): + if not re.match(nick_re, inp.lower()): notice("Invalid username!") return @@ -199,7 +200,7 @@ def kill(inp, me=None, nick=None, input=None, notice=None): ".kill -- Makes the bot kill ." inp = inp.strip() - if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): + if not re.match(nick_re, inp.lower()): notice("Invalid username!") return From 69775a0cc7dc0477451256e8be5628afb5d32c22 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 26 Mar 2012 18:11:22 +1300 Subject: [PATCH 122/205] More refactoring --- plugins/data/slaps.txt | 2 +- plugins/violence.py | 80 +++++++++++++++++++++++------------------- 2 files changed, 45 insertions(+), 37 deletions(-) diff --git a/plugins/data/slaps.txt b/plugins/data/slaps.txt index ae23e7b..d8ee0b2 100755 --- a/plugins/data/slaps.txt +++ b/plugins/data/slaps.txt @@ -7,6 +7,6 @@ launches a in 's general direction. sits on 's face, while slamming a into their crotch. holds down and repeatedly whacks them with a . prods with a flaming . -picks up a , and whacks with it. +picks up a and whacks with it. ties to a chair and throws a at them. hits on the head with a . diff --git a/plugins/violence.py b/plugins/violence.py index 015491b..1ea9a2e 100644 --- a/plugins/violence.py +++ b/plugins/violence.py @@ -11,13 +11,13 @@ with open("plugins/data/slaps.txt") as f: for line in f.readlines(): if line.startswith("//"): continue - slaps.append(line) + slaps.append(line.strip()) with open("plugins/data/slap_items.txt") as f: for line in f.readlines(): if line.startswith("//"): continue - slap_items.append(line) + slap_items.append(line.strip()) larts = ["swaps 's shampoo with glue.", "installs Windows on 's computer.", @@ -160,55 +160,63 @@ body = ['head', @hook.command -def slap(inp, me=None, nick=None, input=None, notice=None): +def slap(inp, me=None, nick=None, conn=None, notice=None): ".slap -- Makes the bot slap ." - inp = inp.strip() - - if not re.match(nick_re, inp.lower()): + target = inp.lower() + + if not re.match(nick_re, target): notice("Invalid username!") return - if inp == input.conn.nick.lower() or inp == "itself": - target = re.sub ('', nick, random.choice(slaps)) - else: - target = re.sub ('', inp, random.choice(slaps)) - msg = re.sub ('', random.choice(slap_items), target) - me(msg) - - - -@hook.command -def lart(inp, me=None, nick=None, input=None, notice=None): - ".lart -- Makes the bot LART ." - inp = inp.strip() - - if not re.match(nick_re, inp.lower()): - notice("Invalid username!") - return - - if inp == input.conn.nick.lower() or inp == "itself": + # if the user is trying to make the bot slap itself, slap them + if target == conn.nick.lower() or target == "itself": target = nick else: target = inp - msg = re.sub ('', target, random.choice(larts)) - me(msg) - + + out = random.choice(slaps) + out = out.replace('', target) + out = out.replace('', random.choice(slap_items)) + + # act out the message + me(out) @hook.command -def kill(inp, me=None, nick=None, input=None, notice=None): +def lart(inp, me=None, nick=None, conn=None, notice=None): + ".lart -- LARTs ." + target = inp.lower() + + if not re.match(nick_re, target): + notice("Invalid username!") + return + + if target == conn.nick.lower() or target == "itself": + target = nick + else: + target = inp + + out = random.choice(larts) + out = out.replace('', target) + out = out.replace('', random.choice(slap_items)) + me(out) + + +@hook.command +def kill(inp, me=None, nick=None, conn=None, notice=None): ".kill -- Makes the bot kill ." - inp = inp.strip() + target = inp.lower() - if not re.match(nick_re, inp.lower()): + if not re.match(nick_re, target): notice("Invalid username!") return - if inp == input.conn.nick.lower() or inp == "itself": + if target == conn.nick.lower() or target == "itself": target = nick else: target = inp - msg = random.choice(kills) - msg = re.sub ('', target, msg) - msg = re.sub ('', random.choice(body), msg) - me(msg) + + out = random.choice(kills) + out = out.replace('', target) + out = out.replace('', random.choice(body)) + me(out) From 297806308c9033d02415e2d1aa1a6ca29d0d278e Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 26 Mar 2012 18:32:20 +1300 Subject: [PATCH 123/205] Finished refactor of violence --- plugins/data/kill_bodyparts.txt | 5 + plugins/data/kills.txt | 23 +++++ plugins/data/larts.txt | 106 +++++++++++++++++++++ plugins/violence.py | 159 +++++--------------------------- 4 files changed, 155 insertions(+), 138 deletions(-) create mode 100755 plugins/data/kill_bodyparts.txt create mode 100755 plugins/data/kills.txt create mode 100755 plugins/data/larts.txt diff --git a/plugins/data/kill_bodyparts.txt b/plugins/data/kill_bodyparts.txt new file mode 100755 index 0000000..35dcc8d --- /dev/null +++ b/plugins/data/kill_bodyparts.txt @@ -0,0 +1,5 @@ +head +arms +leg +arm +"special parts" diff --git a/plugins/data/kills.txt b/plugins/data/kills.txt new file mode 100755 index 0000000..6ff53d1 --- /dev/null +++ b/plugins/data/kills.txt @@ -0,0 +1,23 @@ +rips off 's and leaves them to die. +grabs 's head and rips it clean off their body. +grabs a machine gun and riddles 's body with bullets. +sends The Terminator on a mission to retrieve 's . +gags and ties then throws them off a bridge. +crushes with a huge spiked boulder. +glares at until they die of boredom. +stuffs a few TNT blocks under 's bed and sets them off. +shivs in the . +rams a rocket launcher up 's ass and lets off a few rounds. +crushes 's skull in with a spiked mace. +unleashes the armies of Isengard on . +packs into a SVN repo. +slices 's off with a Katana. +throws to Cthulu! +feeds to an owlbear. +turns into a snail and salts them. +snacks on 's . +puts into a sack, throws the sack in the river, and hurls the river into space. +goes bowling with 's head. +uses 's as a back-scratcher. +sends to /dev/null! +feeds coke and mentos till they pop! diff --git a/plugins/data/larts.txt b/plugins/data/larts.txt new file mode 100755 index 0000000..bf2f0f1 --- /dev/null +++ b/plugins/data/larts.txt @@ -0,0 +1,106 @@ +swaps 's shampoo with glue. +installs Windows on 's computer. +forces to use perl for 3 weeks. +registers 's name with 50 known spammers. +resizes 's console to 40x24. +takes 's drink. +dispenses 's email address to a few hundred 'bulk mailing services'. +pokes in the eye. +beats senseless with a 50lb Linux manual. +cats /dev/random into 's ear. +signs up for AOL. +downvotes on Reddit. +enrolls in Visual Basic 101. +sporks . +drops a truckload of support tickets on . +judo chops . +sets 's resolution to 800x600. +formats 's harddrive to fat12. +rm -rf's . +stabs . +makes learn C++. +steals 's mojo. +strangles with a doohicky mouse cord. +whacks with the cluebat. +sells on EBay. +drops creepers on 's house. +throws all of 's diamond gear into lava. +uses as a biological warfare study. +uses the 'Customer Appreciation Bat' on . +puts in the Total Perspective Vortex. +casts into the fires of Mt. Doom. +gives a melvin. +turns over to the Fun Police. +turns over to Agent Smith to be 'bugged'. +takes away 's internet connection. +pushes past the Shoe Event Horizon. +counts '1, 2, 5... er... 3!' and hurls the Holy Handgrenade Of Antioch at . +puts in a nest of camel spiders. +makes read slashdot at -1. +puts 'alias vim=emacs' in 's /etc/profile. +uninstalls every web browser from 's system. +locks in the Chateau d'If. +signs up for getting hit on the head lessons. +makes try to set up a Lexmark printer. +fills 's eyedrop bottle with lime juice. +casts into the fires of Mt. Doom. +gives a Flying Dutchman. +rips off 's arm, and uses it to beat them to death. +pierces 's nose with a rusty paper hole puncher. +pokes with a rusty nail. +puts sugar between 's bedsheets. +pours sand into 's breakfast. +mixes epoxy into 's toothpaste. +puts Icy-Hot in 's lube container. +straps to a chair, and plays a endless low bitrate MP3 loop of \"the world's most annoying sound\" from \"Dumb and Dumber\". +tells Dr. Dre that was talking smack. +forces to use a Commodore 64 for all their word processing. +smacks in the face with a burlap sack full of broken glass. +puts in a room with several heavily armed manic depressives. +makes watch reruns of \"Blue's Clues\". +puts lye in 's coffee. +introduces to the clue-by-four. +tattoos the Windows symbol on 's ass. +lets Borg have his way with . +signs up for line dancing classes at the local senior center. +wakes out of a sound sleep with some brand new nipple piercings. +gives a 2 gauge Prince Albert. +forces to eat all their veggies. +covers 's toilet paper with lemon-pepper. +fills 's ketchup bottle with Dave's Insanity sauce. +forces to stare at an incredibly frustrating and seemingly never-ending IRC political debate. +knocks two of 's teeth out with a 2x4. +removes Debian from 's system. +switches over to CentOS. +uses 's iPod for skeet shooting practice. +gives 's phone number to Borg. +posts 's IP, username(s), and password(s) on 4chan. +forces to use words like 'irregardless' and 'administrate' (thereby sounding like a real dumbass). +tickles until they wet their pants and pass out. +replaces 's KY with elmer's clear wood glue. +replaces 's TUMS with alka-seltzer tablets. +squeezes habanero pepper juice into 's tub of vaseline. +forces to learn the Win32 API. +gives an atomic wedgie. +ties to a chair and forces them to listen to 'N Sync at full blast. +forces to use notepad for text editing. +frowns at really, really hard. +jabs a hot lighter into 's eye sockets. +forces to browse the web with IE6. +takes out at the knees with a broken pool cue. +forces to listen to emo music. +lets a few creepers into 's house. +signs up for the Iowa State Ferret Legging Championship. +attempts to hotswap 's RAM. +dragon punches . +puts railroad spikes into 's side. +replaces 's Astroglide with JB Weld. +replaces 's stress pills with rat poison pellets. +replaces 's crotch itch cream with Nair. +does the Australian Death Grip on . +dances upon the grave of 's ancestors. +farts in 's general direction. +flogs with stinging nettle. +intoduces to the Knights who say Ni. +assigns all of the permissions tickets on the BeastNode support system to . +hands a poison ivy joint. diff --git a/plugins/violence.py b/plugins/violence.py index 1ea9a2e..603f7c5 100644 --- a/plugins/violence.py +++ b/plugins/violence.py @@ -4,9 +4,19 @@ import random nick_re = re.compile(r"^[A-Za-z0-9_|.-\]\[]*$") +# define lists for messages +larts = [] +kills = [] +kill_bodyparts = [] slaps = [] slap_items = [] +with open("plugins/data/larts.txt") as f: + for line in f.readlines(): + if line.startswith("//"): + continue + larts.append(line.strip()) + with open("plugins/data/slaps.txt") as f: for line in f.readlines(): if line.startswith("//"): @@ -19,144 +29,17 @@ with open("plugins/data/slap_items.txt") as f: continue slap_items.append(line.strip()) -larts = ["swaps 's shampoo with glue.", - "installs Windows on 's computer.", - "forces to use perl for 3 weeks.", - "registers 's name with 50 known spammers.", - "resizes 's console to 40x24.", - "takes 's drink.", - "dispenses 's email address to a few hundred 'bulk mailing services'.", - "pokes in the eye.", - "beats senseless with a 50lb Linux manual.", - "cats /dev/random into 's ear.", - "signs up for AOL.", - "downvotes on Reddit.", - "enrolls in Visual Basic 101.", - "sporks .", - "drops a truckload of support tickets on .", - "judo chops .", - "sets 's resolution to 800x600.", - "formats 's harddrive to fat12.", - "rm -rf's .", - "stabs .", - "makes learn C++.", - "steals 's mojo.", - "strangles with a doohicky mouse cord.", - "whacks with the cluebat.", - "sells on EBay.", - "drops creepers on 's house.", - "throws all of 's diamond gear into lava.", - "uses as a biological warfare study.", - "uses the 'Customer Appreciation Bat' on .", - "puts in the Total Perspective Vortex.", - "casts into the fires of Mt. Doom.", - "gives a melvin.", - "turns over to the Fun Police.", - "turns over to Agent Smith to be 'bugged'.", - "takes away 's internet connection.", - "pushes past the Shoe Event Horizon.", - "counts '1, 2, 5... er... 3!' and hurls the Holy Handgrenade Of Antioch at .", - "puts in a nest of camel spiders.", - "makes read slashdot at -1.", - "puts 'alias vim=emacs' in 's /etc/profile.", - "uninstalls every web browser from 's system.", - "locks in the Chateau d'If.", - "signs up for getting hit on the head lessons.", - "makes try to set up a Lexmark printer.", - "fills 's eyedrop bottle with lime juice.", - "casts into the fires of Mt. Doom.", - "gives a Flying Dutchman.", - "rips off 's arm, and uses it to beat them to death.", - "pierces 's nose with a rusty paper hole puncher.", - "pokes with a rusty nail.", - "puts sugar between 's bedsheets.", - "pours sand into 's breakfast.", - "mixes epoxy into 's toothpaste.", - "puts Icy-Hot in 's lube container.", - "straps to a chair, and plays a endless low bitrate MP3 loop of \"the world's most annoying sound\" from \"Dumb and Dumber\".", - "tells Dr. Dre that was talking smack.", - "forces to use a Commodore 64 for all their word processing.", - "smacks in the face with a burlap sack full of broken glass.", - "puts in a room with several heavily armed manic depressives.", - "makes watch reruns of \"Blue's Clues\".", - "puts lye in 's coffee.", - "introduces to the clue-by-four.", - "tattoos the Windows symbol on 's ass.", - "lets Borg have his way with .", - "signs up for line dancing classes at the local senior center.", - "wakes out of a sound sleep with some brand new nipple piercings.", - "gives a 2 gauge Prince Albert.", - "forces to eat all their veggies.", - "covers 's toilet paper with lemon-pepper.", - "fills 's ketchup bottle with Dave's Insanity sauce.", - "forces to stare at an incredibly frustrating and seemingly never-ending IRC political debate.", - "knocks two of 's teeth out with a 2x4.", - "removes Debian from 's system.", - "switches over to CentOS.", - "uses 's iPod for skeet shooting practice.", - "gives 's phone number to Borg.", - "posts 's IP, username(s), and password(s) on 4chan.", - "forces to use words like 'irregardless' and 'administrate' (thereby sounding like a real dumbass).", - "tickles until they wet their pants and pass out.", - "replaces 's KY with elmer's clear wood glue.", - "replaces 's TUMS with alka-seltzer tablets.", - "squeezes habanero pepper juice into 's tub of vaseline.", - "forces to learn the Win32 API.", - "gives an atomic wedgie.", - "ties to a chair and forces them to listen to 'N Sync at full blast.", - "forces to use notepad for text editing.", - "frowns at really, really hard.", - "jabs a hot lighter into 's eye sockets.", - "forces to browse the web with IE6.", - "takes out at the knees with a broken pool cue.", - "forces to listen to emo music.", - "lets a few creepers into 's house.", - "signs up for the Iowa State Ferret Legging Championship.", - "attempts to hotswap 's RAM.", - "dragon punches .", - "puts railroad spikes into 's side.", - "replaces 's Astroglide with JB Weld.", - "replaces 's stress pills with rat poison pellets.", - "replaces 's crotch itch cream with Nair.", - "does the Australian Death Grip on .", - "dances upon the grave of 's ancestors.", - "farts in 's general direction.", - "flogs with stinging nettle.", - "intoduces to the Knights who say Ni.", - "assigns all of the permissions tickets on the BeastNode support system to .", - "hands a poison ivy joint."] +with open("plugins/data/kills.txt") as f: + for line in f.readlines(): + if line.startswith("//"): + continue + kills.append(line.strip()) - -kills = ["rips off 's and leaves them to die.", - "grabs 's head and rips it clean off their body.", - "grabs a machine gun and riddles 's body with bullets.", - "sends The Terminator on a mission to retrieve 's .", - "gags and ties then throws them off a bridge.", - "crushes with a huge spiked boulder.", - "glares at until they die of boredom.", - "stuffs a few TNT blocks under 's bed and sets them off.", - "shivs in the .", - "rams a rocket launcher up 's ass and lets off a few rounds.", - "crushes 's skull in with a spiked mace.", - "unleashes the armies of Isengard on .", - "packs into a SVN repo.", - "slices 's off with a Katana.", - "throws to Cthulu!", - "feeds to an owlbear.", - "turns into a snail and salts them.", - "snacks on 's .", - "puts into a sack, throws the sack in the river, and hurls the river into space.", - "goes bowling with 's head.", - "uses 's as a back-scratcher.", - "sends to /dev/null!", - "feeds coke and mentos till they pop!"] - - -body = ['head', - 'arms', - 'leg', - 'arm', - '"special parts"'] +with open("plugins/data/kill_bodyparts.txt") as f: + for line in f.readlines(): + if line.startswith("//"): + continue + kill_bodyparts.append(line.strip()) @hook.command @@ -218,5 +101,5 @@ def kill(inp, me=None, nick=None, conn=None, notice=None): out = random.choice(kills) out = out.replace('', target) - out = out.replace('', random.choice(body)) + out = out.replace('', random.choice(kill_bodyparts)) me(out) From 3acd6536a6387c081842739a385689b0deefe32c Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 26 Mar 2012 18:33:11 +1300 Subject: [PATCH 124/205] Quick fix in fortune.py --- plugins/fortune.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/fortune.py b/plugins/fortune.py index e556406..ed0f487 100755 --- a/plugins/fortune.py +++ b/plugins/fortune.py @@ -8,7 +8,7 @@ with open("plugins/data/fortunes.txt") as f: for line in f.readlines(): if line.startswith("//"): continue - fortunes.append(line) + fortunes.append(line.strip()) @hook.command(autohelp=False) def fortune(inp, nick=None, say=None, input=None): From cb9129aebc26a4efeb19be4a11677597bc1e927f Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 26 Mar 2012 18:36:40 +1300 Subject: [PATCH 125/205] PEP-8 --- plugins/fortune.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/fortune.py b/plugins/fortune.py index ed0f487..81136f4 100755 --- a/plugins/fortune.py +++ b/plugins/fortune.py @@ -10,6 +10,7 @@ with open("plugins/data/fortunes.txt") as f: continue fortunes.append(line.strip()) + @hook.command(autohelp=False) def fortune(inp, nick=None, say=None, input=None): ".fortune -- Fortune cookies on demand." From 9d0e704eae83db8df9b6ed2ebed4ded6a5bf52e4 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 26 Mar 2012 21:59:02 +1300 Subject: [PATCH 126/205] Random tweaks --- plugins/data/kills.txt | 9 ++++----- plugins/data/larts.txt | 1 - plugins/fortune.py | 11 +++-------- plugins/time.py | 13 +++++-------- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/plugins/data/kills.txt b/plugins/data/kills.txt index 6ff53d1..c644ea4 100755 --- a/plugins/data/kills.txt +++ b/plugins/data/kills.txt @@ -10,14 +10,13 @@ shivs in the . rams a rocket launcher up 's ass and lets off a few rounds. crushes 's skull in with a spiked mace. unleashes the armies of Isengard on . -packs into a SVN repo. slices 's off with a Katana. -throws to Cthulu! -feeds to an owlbear. +throws to Cthulu and watches them get ripped to shreads. +feeds to an owlbear, who proceeds to maul them. turns into a snail and salts them. snacks on 's . puts into a sack, throws the sack in the river, and hurls the river into space. -goes bowling with 's head. +goes bowling with 's disembodied head. uses 's as a back-scratcher. sends to /dev/null! -feeds coke and mentos till they pop! +feeds coke and mentos till they violently explode. diff --git a/plugins/data/larts.txt b/plugins/data/larts.txt index bf2f0f1..b4a831c 100755 --- a/plugins/data/larts.txt +++ b/plugins/data/larts.txt @@ -102,5 +102,4 @@ dances upon the grave of 's ancestors. farts in 's general direction. flogs with stinging nettle. intoduces to the Knights who say Ni. -assigns all of the permissions tickets on the BeastNode support system to . hands a poison ivy joint. diff --git a/plugins/fortune.py b/plugins/fortune.py index 81136f4..c31a17d 100755 --- a/plugins/fortune.py +++ b/plugins/fortune.py @@ -11,12 +11,7 @@ with open("plugins/data/fortunes.txt") as f: fortunes.append(line.strip()) -@hook.command(autohelp=False) -def fortune(inp, nick=None, say=None, input=None): +@hook.command +def fortune(inp): ".fortune -- Fortune cookies on demand." - - msg = "(" + nick + ") " + random.choice(fortunes) - if inp: - msg = "(@" + inp + ") " + random.choice(fortunes) - - say(msg) + return random.choice(fortunes) diff --git a/plugins/time.py b/plugins/time.py index 4c6c5ea..1bb9f1f 100755 --- a/plugins/time.py +++ b/plugins/time.py @@ -9,6 +9,8 @@ import locale import datetime from BeautifulSoup import BeautifulSoup +tags_re = re.compile(r'<[^<]*?>') + TimeZones = {'KST': 9, 'CADT': 10.5, 'EETDST': 3, 'MESZ': 2, 'WADT': 9, 'EET': 2, 'MST': -7, 'WAST': 8, 'IST': 5.5, 'B': 2, 'MSK': 3, 'X': -11, 'MSD': 4, 'CETDST': 2, 'AST': -4, @@ -224,21 +226,16 @@ def get_time(tz): @hook.command("time") -def timecommand(inp, say=None): +def time_command(inp): ".time -- Gets the time in " - tags_re = re.compile(r'<[^<]*?>') - - page = http.get('http://www.google.com/search', q="time in " + inp) - - soup = BeautifulSoup(page) - + request = http.get('http://www.google.com/search', q="time in " + inp) + soup = BeautifulSoup(request) response = soup.find('td', {'style': 'font-size:medium'}) if response: output = response.renderContents() output = tags_re.sub('\x02', output.strip()) - return output else: try: From 921c16cf7c9e72529bbc371fc1dbb4fbcc4234ed Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 26 Mar 2012 23:18:19 +1300 Subject: [PATCH 127/205] fixes --- plugins/admin.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index 38487e1..324be46 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -88,7 +88,7 @@ def raw(inp, conn=None, notice=None): @hook.command(adminonly=True) -def kick(inp, input=None, chan=None, conn=None, notice=None): +def kick(inp, chan=None, conn=None, notice=None): ".kick [channel] [reason] -- Makes the bot kick in [channel] "\ "If [channel] is blank the bot will kick the in "\ "the channel the command was used in." @@ -104,9 +104,8 @@ def kick(inp, input=None, chan=None, conn=None, notice=None): reason = reason[:-1] out = out + " :" + reason else: - chan = input.chan user = split[0] - out = "KICK %s %s" % (input.chan, split[0]) + out = "KICK %s %s" % (chan, split[0]) if len(split) > 1: reason = "" for x in split[1:]: @@ -119,7 +118,7 @@ def kick(inp, input=None, chan=None, conn=None, notice=None): @hook.command(adminonly=True) -def say(inp, conn=None, notice=None): +def say(inp, conn=None, chan=None, notice=None): ".say [channel] -- Makes the bot say in [channel]. "\ "If [channel] is blank the bot will say the in "\ "the channel the command was used in." @@ -135,13 +134,13 @@ def say(inp, conn=None, notice=None): for x in split[0:]: message = message + x + " " message = message[:-1] - out = "PRIVMSG %s :%s" % (input.chan, message) + out = "PRIVMSG %s :%s" % (chan, message) conn.send(out) @hook.command("me", adminonly=True) @hook.command(adminonly=True) -def act(inp, conn=None, notice=None): +def act(inp, conn=None, chan=None, notice=None): ".act [channel] -- Makes the bot act out in [channel] "\ "If [channel] is blank the bot will act the in "\ "the channel the command was used in." @@ -162,7 +161,7 @@ def act(inp, conn=None, notice=None): @hook.command(adminonly=True) -def topic(inp, input=None, notice=None): +def topic(inp, conn=None, chan=None, notice=None): ".topic [channel] -- Change the topic of a channel." split = inp.split(" ") if split[0][0] == "#": From 8d6a2d71d419607e4ec13fb20b38a261f775fe6c Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 28 Mar 2012 08:47:46 +1300 Subject: [PATCH 128/205] Rewrote fmylife with a cache for instant fmls --- plugins/fmylife.py | 55 ++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/plugins/fmylife.py b/plugins/fmylife.py index d0986b3..fbe5e3c 100755 --- a/plugins/fmylife.py +++ b/plugins/fmylife.py @@ -1,41 +1,38 @@ # Plugin by Lukeroge # -import re - -from util import hook, http, misc -from urllib2 import HTTPError +from util import hook, http from urlparse import urljoin from BeautifulSoup import BeautifulSoup +from collections import defaultdict base_url = 'http://www.fmylife.com/' -@hook.command(autohelp=False) -def fml(inp): - ".fml [id] -- Gets a random quote from fmyfife.com. Optionally gets [id]." +fml_cache = defaultdict() - inp = inp.replace("#", "") - - if inp: - if not inp.isdigit(): - return "Invalid ID!" - try: - page = http.get(urljoin(base_url, inp)) - except (HTTPError, IOError): - return "Could not fetch #%s. FML" % inp - else: - try: - page = http.get(urljoin(base_url, 'random')) - except (HTTPError, IOError): - return "I tried to use .fml, but it was broken. FML" +def refresh_cache(): + """ gets a page of random fmls and puts them into a dictionary """ + page = http.get(urljoin(base_url, 'random')) soup = BeautifulSoup(page) - soup.find('div', id='submit').extract() - post = soup.body.find('div', 'post') - try: - id = int(post.find('a', 'fmllink')['href'].split('/')[-1]) - except TypeError: - return "Could not fetch #%s. FML" % inp - body = misc.strip_html(' '.join(link.renderContents() for link in post('a', 'fmllink'))) - return '(#%d) %s' % (id, body) + for e in soup.findAll('div', {'class': 'post article'}): + id = int(e['id']) + text = e.find('p', text=True) + fml_cache[id] = text + +# do an initial refresh of the cache +refresh_cache() + + +@hook.command(autohelp=False) +def fml(inp, reply=None): + ".fml -- Gets a random quote from fmyfife.com." + + # grab the last item in the fml cache and remove it + id, text = fml_cache.popitem() + # reply with the fml we grabbed + reply('(#%d) %s' % (id, text)) + # refresh fml cache if its getting empty + if len(fml_cache) < 3: + refresh_cache() From d65f1557405c26c0d8fcb25e1c29eb80b962e10c Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 28 Mar 2012 09:18:25 +1300 Subject: [PATCH 129/205] Workaround for stupid bug --- plugins/fmylife.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/fmylife.py b/plugins/fmylife.py index fbe5e3c..68d1d89 100755 --- a/plugins/fmylife.py +++ b/plugins/fmylife.py @@ -18,7 +18,7 @@ def refresh_cache(): for e in soup.findAll('div', {'class': 'post article'}): id = int(e['id']) - text = e.find('p', text=True) + text = ''.join(e.find('p').findAll(text=True)) fml_cache[id] = text # do an initial refresh of the cache From c64c2cbcd09b5ad8eaeb7c53be1ec9ef51acddf4 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Wed, 28 Mar 2012 10:21:07 +1300 Subject: [PATCH 130/205] Added part() --- core/irc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/irc.py b/core/irc.py index ff9a45f..50ff379 100755 --- a/core/irc.py +++ b/core/irc.py @@ -184,6 +184,9 @@ class IRC(object): def join(self, channel): self.cmd("JOIN", [channel]) + + def part(self, channel): + self.cmd("PART", [channel]) def msg(self, target, text): self.cmd("PRIVMSG", [target, text]) From 9c59fa538a0a281f63fc6b094f75722506995515 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Wed, 28 Mar 2012 10:23:53 +1300 Subject: [PATCH 131/205] Removed some code --- core/main.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/core/main.py b/core/main.py index 93f53c4..df47cd4 100755 --- a/core/main.py +++ b/core/main.py @@ -25,9 +25,6 @@ class Input(dict): else: conn.msg(chan, '(' + nick + ') ' + msg) - def set_nick(nick): - conn.set_nick(nick) - def me(msg): conn.msg(chan, "\x01%s %s\x01" % ("ACTION", msg)) @@ -38,7 +35,7 @@ class Input(dict): params=params, nick=nick, user=user, host=host, mask=mask, paraml=paraml, msg=msg, server=conn.server, chan=chan, notice=notice, say=say, reply=reply, pm=pm, bot=bot, - me=me, set_nick=set_nick, lastparam=paraml[-1]) + me=me, lastparam=paraml[-1]) # make dict keys accessible as attributes def __getattr__(self, key): From 70b75398610dbd1dfb5427dada9ecc0865e71d9f Mon Sep 17 00:00:00 2001 From: lukeroge Date: Wed, 28 Mar 2012 10:27:18 +1300 Subject: [PATCH 132/205] Update plugins/admin.py --- plugins/admin.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index 324be46..9791b0d 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -51,33 +51,33 @@ def clearlogs(inp, input=None): @hook.command(adminonly=True) def join(inp, conn=None, notice=None): ".join -- Joins ." - notice("Attempting to join " + inp + "...") - conn.cmd("JOIN", [inp]) + notice("Attempting to join %s..." % inp) + conn.join(inp) @hook.command(adminonly=True) def cycle(inp, conn=None, notice=None): ".cycle -- Cycles ." - notice("Attempting to cycle " + inp + "...") - conn.cmd("PART", [inp]) - conn.cmd("JOIN", [inp]) + notice("Attempting to cycle %s..." % inp) + conn.part(inp) + conn.join(inp) @hook.command(adminonly=True) def part(inp, conn=None, notice=None): - ".part -- Parts from ." - notice("Attempting to part from " + inp + "...") - conn.cmd("PART", [inp]) + ".part -- Leaves ." + notice("Attempting to part from %s..." % inp) + conn.part(inp) @hook.command(adminonly=True) -def nick(inp, input=None, notice=None, set_nick=None): +def nick(inp, input=None, notice=None, conn=None): ".nick -- Changes the bots nickname to ." if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): notice("Invalid username!") return - notice("Attempting to change nick to " + inp + ".") - set_nick(inp) + notice("Attempting to change nick to \"%s\"..." % inp) + conn.set_nick(inp) @hook.command(adminonly=True) From 59aa505fcb4b9ed50e809fe67876353807dfef8f Mon Sep 17 00:00:00 2001 From: lukeroge Date: Wed, 28 Mar 2012 10:44:07 +1300 Subject: [PATCH 133/205] Changed some code around --- plugins/admin.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index 9791b0d..c148455 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -28,24 +28,23 @@ def stop(inp, nick=None, conn=None): else: conn.cmd("QUIT", ["Killed by %s." % nick]) time.sleep(5) - subprocess.call("./cloudbot stop", shell=True) + subprocess.call(["./cloudbot", "stop"]) -@hook.command("reboot", autohelp=False, adminonly=True) @hook.command(autohelp=False, adminonly=True) -def restart(inp, input=None): +def restart(inp, nick=None, conn=None): ".restart [reason] -- Restarts the bot with [reason] as its quit message." if inp: - input.conn.send("QUIT :Restarted by " + input.nick + " (" + inp + ")") + conn.cmd("QUIT", ["Restarted by %s (%s)" % (nick, inp)]) else: - input.conn.send("QUIT :Restarted by " + input.nick + " (no reason)") + conn.cmd("QUIT", ["Restarted by %s." % nick]) time.sleep(5) - os.execl("./cloudbot", "restart") + subprocess.call(["./cloudbot", "restart"]) @hook.command(autohelp=False, adminonly=True) def clearlogs(inp, input=None): ".clearlogs -- Clears the bots log(s)." - subprocess.call("./cloudbot clear", shell=True) + subprocess.call(["./cloudbot", "clear"]) @hook.command(adminonly=True) From 6c31f313fda0f86486fd841cffbb49e64ce061c0 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Wed, 28 Mar 2012 11:04:06 +1300 Subject: [PATCH 134/205] Standardised function name --- plugins/urlparse.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/urlparse.py b/plugins/urlparse.py index 58fb8e2..e2ea215 100755 --- a/plugins/urlparse.py +++ b/plugins/urlparse.py @@ -4,7 +4,7 @@ import re titler = re.compile(r'(?si)(.+?)') -def gettitle(url): +def get_title(url): url = urlnorm.normalize(url.encode('utf-8')) url = url.decode('utf-8') # add http if its missing @@ -33,4 +33,4 @@ def gettitle(url): @hook.command def title(inp): ".title -- gets the title of a web page" - return gettitle(inp) + return get_title(inp) From b35868c0f1484f695e9fd35e5afa52c86665dafd Mon Sep 17 00:00:00 2001 From: lukeroge Date: Wed, 28 Mar 2012 11:24:20 +1300 Subject: [PATCH 135/205] Modernized some code. --- plugins/urlparse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/urlparse.py b/plugins/urlparse.py index e2ea215..b4f47d5 100755 --- a/plugins/urlparse.py +++ b/plugins/urlparse.py @@ -8,7 +8,7 @@ def get_title(url): url = urlnorm.normalize(url.encode('utf-8')) url = url.decode('utf-8') # add http if its missing - if url[:7] != "http://" and url[:8] != "https://": + if not url.startswith("http"): url = "http://" + url try: # get the title From 2f492a4659b53118588a1984f6311edf72d9f154 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Wed, 28 Mar 2012 12:22:43 +1300 Subject: [PATCH 136/205] added .system to get info on the host system --- plugins/misc.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/misc.py b/plugins/misc.py index de62cb8..7691582 100755 --- a/plugins/misc.py +++ b/plugins/misc.py @@ -1,6 +1,7 @@ import re import socket import subprocess +import platform import time from util import hook, http @@ -60,3 +61,12 @@ def onjoin(paraml, conn=None, bot=None): while True: time.sleep(delay) conn.cmd('PING', [conn.nick]) + +# system info command +@hook.command(autohelp=False) +def system(inp): + ".system -- retrieves information about the host system" + python_version = platform.python_version() + os = platform.platform(aliased=True) + cpu = platform.machine() + return "Platform: %s, Python Version: %s, CPU: %s" % (os, python_version, cpu) From ebdf34256e7249f19284e74b7ed3b780511900b2 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Thu, 29 Mar 2012 10:48:59 +1300 Subject: [PATCH 137/205] Bug fixes --- plugins/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/admin.py b/plugins/admin.py index c148455..6251510 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -38,7 +38,7 @@ def restart(inp, nick=None, conn=None): else: conn.cmd("QUIT", ["Restarted by %s." % nick]) time.sleep(5) - subprocess.call(["./cloudbot", "restart"]) + os.execl("./cloudbot", "restart") @hook.command(autohelp=False, adminonly=True) From 66c43af84e74f9b9f39d9d7bc892f7004e9f37a7 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Thu, 29 Mar 2012 11:07:41 +1300 Subject: [PATCH 138/205] Switched to a faster method of printing the channel list (hah, I bet this will confuse python beginners) --- plugins/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/admin.py b/plugins/admin.py index 6251510..2b88d12 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -17,7 +17,7 @@ def admins(inp, bot=None): @hook.command(autohelp=False) def channels(inp, conn=None): ".channels -- Lists the channels that the bot is in." - return "I am in these channels: " + ", ".join(conn.channels) + return "I am in these channels: %s" % ", ".join(conn.channels) @hook.command(autohelp=False, adminonly=True) From 90aa412a00950334be156497dceb6ee516e53156 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Thu, 29 Mar 2012 11:11:48 +1300 Subject: [PATCH 139/205] Moar optimisation --- plugins/ignore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ignore.py b/plugins/ignore.py index fbeeba7..a12142a 100755 --- a/plugins/ignore.py +++ b/plugins/ignore.py @@ -42,7 +42,7 @@ def ignoresieve(bot, input, func, type, args): def ignored(inp, bot=None): ".ignored -- Lists ignored channels/users." if ignorelist: - return "Ignored channels/users are: " + ", ".join(ignorelist) + return "Ignored channels/users are: %s" % ", ".join(ignorelist) else: return "No channels/users are currently ignored." From 36d7d0a1cc80a309f30fb81122cdfabde71a84b4 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Thu, 29 Mar 2012 11:19:54 +1300 Subject: [PATCH 140/205] Changed code around a bit --- plugins/factoids.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/factoids.py b/plugins/factoids.py index 106aa14..51388f9 100755 --- a/plugins/factoids.py +++ b/plugins/factoids.py @@ -111,11 +111,9 @@ def forget(inp, db=None, input=None, notice=None): @hook.regex(r'^\? ?(.+)') def factoid(inp, say=None, db=None, bot=None): "? -- Shows what data is associated with ." - try: - prefix_on = bot.config["plugins"]["factoids"]["prefix"] - except KeyError: - prefix_on = False - + + prefix_on = bot.config["plugins"]["factoids"].get("prefix", False) + db_init(db) data = get_memory(db, inp.group(1).strip()) From 67d0eb1b2f186c03debda9e7d9f0d36a024217b0 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Thu, 29 Mar 2012 11:23:20 +1300 Subject: [PATCH 141/205] Update plugins/sieve.py --- plugins/sieve.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plugins/sieve.py b/plugins/sieve.py index 05bf678..500d0bf 100755 --- a/plugins/sieve.py +++ b/plugins/sieve.py @@ -6,17 +6,13 @@ from util import hook @hook.sieve def sieve_suite(bot, input, func, kind, args): if input.command == 'PRIVMSG' and \ - input.nick.lower()[-3:] == 'bot' and args.get('ignorebots', True): + input.nick.endswith('bot') and args.get('ignorebots', True): return None if kind == "command": if input.trigger in bot.config.get('disabled_commands', []): return None - ignored = bot.config.get('ignored', []) - if input.host in ignored or input.nick in ignored: - return None - fn = re.match(r'^plugins.(.+).py$', func._filename) disabled = bot.config.get('disabled_plugins', []) if fn and fn.group(1).lower() in disabled: @@ -36,8 +32,7 @@ def sieve_suite(bot, input, func, kind, args): if args.get('adminonly', False): admins = bot.config.get('admins', []) - if input.mask not in admins and input.nick not in admins: return None - return input + return input \ No newline at end of file From 7b21ffe06586bf1cc2469ff9f1646aaffd1d9acf Mon Sep 17 00:00:00 2001 From: lukeroge Date: Thu, 29 Mar 2012 20:53:57 +1300 Subject: [PATCH 142/205] Fixed up some really screwy encoding --- plugins/mem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mem.py b/plugins/mem.py index c480291..844238f 100755 --- a/plugins/mem.py +++ b/plugins/mem.py @@ -13,7 +13,7 @@ def mem(inp): line_pairs = re.findall(r"^(\w+):\s*(.*)\s*$", status_file, re.M) status = dict(line_pairs) keys = 'VmSize VmLib VmData VmExe VmRSS VmStk'.split() - return ', '.join(key + ':' + status[key] for key in keys) + return '\x02, '.join(key + ':\x02' + status[key] for key in keys) elif os.name == 'nt': cmd = "tasklist /FI \"PID eq %s\" /FO CSV /NH" % os.getpid() @@ -23,6 +23,6 @@ def mem(inp): for amount in re.findall(r'([,0-9]+) K', out): total += int(amount.replace(',', '')) - return 'memory usage: %d kB' % total + return 'Memory usage: \x02%d kB\x02' % total return mem.__doc__ From 17a4d8262cb23ca30ed1a376ea05dd4e5245f926 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Thu, 29 Mar 2012 21:12:41 +1300 Subject: [PATCH 143/205] Added Windows catch --- plugins/ping.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/ping.py b/plugins/ping.py index c9424da..9710fd7 100755 --- a/plugins/ping.py +++ b/plugins/ping.py @@ -2,6 +2,7 @@ from util import hook import subprocess import re +import os ping_regex = re.compile(r"(\d+.\d+)/(\d+.\d+)/(\d+.\d+)/(\d+.\d+)") @@ -9,10 +10,14 @@ ping_regex = re.compile(r"(\d+.\d+)/(\d+.\d+)/(\d+.\d+)/(\d+.\d+)") @hook.command def ping(inp, reply=None): ".ping [count] -- Pings [count] times." + + if os.name == "nt": + return "Sorry, this command is not supported on Windows systems." args = inp.split(' ') host = args[0] + # check for a seccond argument and set the ping count if len(args) > 1: count = int(args[1]) if count > 20: From 88ea538773cb2fa5dad3f89e7e5fcaedb17fd3ca Mon Sep 17 00:00:00 2001 From: lukeroge Date: Thu, 29 Mar 2012 21:21:43 +1300 Subject: [PATCH 144/205] Lolspelling --- plugins/password.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/password.py b/plugins/password.py index c550ab6..f1fcb08 100755 --- a/plugins/password.py +++ b/plugins/password.py @@ -53,6 +53,6 @@ def gen_password(types): @hook.command def password(inp, notice=None): - ".password [types] -- Generates a password of (default 10). [types] can include 'alpha', 'no caps', 'numeric', 'symbols' or any combination of the types, eg. 'numbers symbols'" + ".password [types] -- Generates a password of (default 10). [types] can include 'alpha', 'no caps', 'numeric', 'symbols' or any combination of the types, eg. 'numbers symbols'" password = gen_password(inp) notice(password) From 7b1cc2ff0e4cbfeb1ad8cb29dffc937d74266250 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Fri, 30 Mar 2012 12:58:47 +1300 Subject: [PATCH 145/205] Added code to unescape HTML entities --- plugins/fmylife.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/fmylife.py b/plugins/fmylife.py index 68d1d89..27ca639 100755 --- a/plugins/fmylife.py +++ b/plugins/fmylife.py @@ -19,6 +19,7 @@ def refresh_cache(): for e in soup.findAll('div', {'class': 'post article'}): id = int(e['id']) text = ''.join(e.find('p').findAll(text=True)) + text = http.unescape(text) fml_cache[id] = text # do an initial refresh of the cache From d717292c135c9919ea4abf0b6ee227a5a293e93a Mon Sep 17 00:00:00 2001 From: neersighted Date: Thu, 29 Mar 2012 17:08:59 -0700 Subject: [PATCH 146/205] fix help message --- plugins/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/misc.py b/plugins/misc.py index 7691582..3953288 100755 --- a/plugins/misc.py +++ b/plugins/misc.py @@ -65,7 +65,7 @@ def onjoin(paraml, conn=None, bot=None): # system info command @hook.command(autohelp=False) def system(inp): - ".system -- retrieves information about the host system" + ".system -- Retrieves information about the host system." python_version = platform.python_version() os = platform.platform(aliased=True) cpu = platform.machine() From 9398190a5d04027efff0955b3d28e69dd22c3cfb Mon Sep 17 00:00:00 2001 From: neersighted Date: Thu, 29 Mar 2012 17:16:31 -0700 Subject: [PATCH 147/205] merge mem/sys --- plugins/data/itemids.txt | 0 plugins/data/recipes.txt | 0 plugins/mcitems.py | 0 plugins/misc.py | 9 --------- plugins/{mem.py => system.py} | 10 +++++++++- plugins/violence.py | 0 6 files changed, 9 insertions(+), 10 deletions(-) mode change 100644 => 100755 plugins/data/itemids.txt mode change 100644 => 100755 plugins/data/recipes.txt mode change 100644 => 100755 plugins/mcitems.py rename plugins/{mem.py => system.py} (71%) mode change 100644 => 100755 plugins/violence.py diff --git a/plugins/data/itemids.txt b/plugins/data/itemids.txt old mode 100644 new mode 100755 diff --git a/plugins/data/recipes.txt b/plugins/data/recipes.txt old mode 100644 new mode 100755 diff --git a/plugins/mcitems.py b/plugins/mcitems.py old mode 100644 new mode 100755 diff --git a/plugins/misc.py b/plugins/misc.py index 3953288..1a25988 100755 --- a/plugins/misc.py +++ b/plugins/misc.py @@ -61,12 +61,3 @@ def onjoin(paraml, conn=None, bot=None): while True: time.sleep(delay) conn.cmd('PING', [conn.nick]) - -# system info command -@hook.command(autohelp=False) -def system(inp): - ".system -- Retrieves information about the host system." - python_version = platform.python_version() - os = platform.platform(aliased=True) - cpu = platform.machine() - return "Platform: %s, Python Version: %s, CPU: %s" % (os, python_version, cpu) diff --git a/plugins/mem.py b/plugins/system.py similarity index 71% rename from plugins/mem.py rename to plugins/system.py index 844238f..f8bb9ee 100755 --- a/plugins/mem.py +++ b/plugins/system.py @@ -1,6 +1,6 @@ import os import re - +import platform from util import hook @@ -26,3 +26,11 @@ def mem(inp): return 'Memory usage: \x02%d kB\x02' % total return mem.__doc__ + +@hook.command(autohelp=False) +def sys(inp): + ".sys -- Retrieves information about the host system." + python_version = platform.python_version() + os = platform.platform(aliased=True) + cpu = platform.machine() + return "Platform: %s, Python Version: %s, CPU: %s" % (os, python_version, cpu) diff --git a/plugins/violence.py b/plugins/violence.py old mode 100644 new mode 100755 From 0849e3f09b803d63fc112865c014e1a0648c6475 Mon Sep 17 00:00:00 2001 From: neersighted Date: Thu, 29 Mar 2012 18:22:22 -0700 Subject: [PATCH 148/205] tweaks to .sys --- plugins/system.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/system.py b/plugins/system.py index f8bb9ee..d83abf5 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -4,6 +4,7 @@ import platform from util import hook +@hook.command("memory", autohelp=False) @hook.command(autohelp=False) def mem(inp): ".mem -- Display the bot's current memory usage." @@ -12,8 +13,8 @@ def mem(inp): status_file = open("/proc/%d/status" % os.getpid()).read() line_pairs = re.findall(r"^(\w+):\s*(.*)\s*$", status_file, re.M) status = dict(line_pairs) - keys = 'VmSize VmLib VmData VmExe VmRSS VmStk'.split() - return '\x02, '.join(key + ':\x02' + status[key] for key in keys) + keys = 'VmSize VmRSS VmStk'.split() + return '\x02, '.join(key + ': \x02' + status[key] for key in keys) elif os.name == 'nt': cmd = "tasklist /FI \"PID eq %s\" /FO CSV /NH" % os.getpid() @@ -23,10 +24,11 @@ def mem(inp): for amount in re.findall(r'([,0-9]+) K', out): total += int(amount.replace(',', '')) - return 'Memory usage: \x02%d kB\x02' % total + return '\x02Memory Usage: %s kB\x02' % total return mem.__doc__ +@hook.command("system", autohelp=False) @hook.command(autohelp=False) def sys(inp): ".sys -- Retrieves information about the host system." From a81ece7c0debdcea680a8ffc134234585c789b53 Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 30 Mar 2012 07:51:59 -0700 Subject: [PATCH 149/205] tweaks to system.py --- plugins/system.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/system.py b/plugins/system.py index d83abf5..5535850 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -4,18 +4,26 @@ import platform from util import hook +def replace(text, wordDic): + rc = re.compile('|'.join(map(re.escape, wordDic))) + + def translate(match): + return wordDic[match.group(0)] + return rc.sub(translate, text) + @hook.command("memory", autohelp=False) @hook.command(autohelp=False) def mem(inp): ".mem -- Display the bot's current memory usage." - if os.name == 'posix': status_file = open("/proc/%d/status" % os.getpid()).read() line_pairs = re.findall(r"^(\w+):\s*(.*)\s*$", status_file, re.M) status = dict(line_pairs) - keys = 'VmSize VmRSS VmStk'.split() - return '\x02, '.join(key + ': \x02' + status[key] for key in keys) - + checked_stats = 'VmRSS VmSize VmPeak VmStk'.split() + stats = '\x02, '.join(key + ': \x02' + status[key] for key in checked_stats) + pretty_names = {'VmRSS': 'Real Memory', 'VmSize': 'Allocated Memory', 'VmPeak': 'Peak Allocated Memory', 'VmStk': 'Stack Size'} + stats = replace(stats, pretty_names) + return stats elif os.name == 'nt': cmd = "tasklist /FI \"PID eq %s\" /FO CSV /NH" % os.getpid() out = os.popen(cmd).read() From 1a436f87bf8cceb8d4089e9504fa2b0ec81d2d06 Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 30 Mar 2012 07:58:39 -0700 Subject: [PATCH 150/205] Functionized the proc reader, added more cool stuff --- plugins/system.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/plugins/system.py b/plugins/system.py index 5535850..0c1ca7e 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -11,30 +11,34 @@ def replace(text, wordDic): return wordDic[match.group(0)] return rc.sub(translate, text) -@hook.command("memory", autohelp=False) -@hook.command(autohelp=False) -def mem(inp): - ".mem -- Display the bot's current memory usage." - if os.name == 'posix': +def checkProc(checked_stats): status_file = open("/proc/%d/status" % os.getpid()).read() line_pairs = re.findall(r"^(\w+):\s*(.*)\s*$", status_file, re.M) status = dict(line_pairs) - checked_stats = 'VmRSS VmSize VmPeak VmStk'.split() + checked_stats = checked_stats.split() stats = '\x02, '.join(key + ': \x02' + status[key] for key in checked_stats) - pretty_names = {'VmRSS': 'Real Memory', 'VmSize': 'Allocated Memory', 'VmPeak': 'Peak Allocated Memory', 'VmStk': 'Stack Size'} + return stats + +@hook.command("memory", autohelp=False) +@hook.command(autohelp=False) +def mem(inp): + ".mem -- Displays the bot's current memory usage." + if os.name == 'posix': + checked_stats = 'Threads VmRSS VmSize VmPeak VmStk' + stats = checkProc(checked_stats) + pretty_names = {'Threads': 'Active Threads', 'VmRSS': 'Real Memory', 'VmSize': 'Allocated Memory', 'VmPeak': 'Peak Allocated Memory', 'VmStk': 'Stack Size'} stats = replace(stats, pretty_names) return stats + elif os.name == 'nt': cmd = "tasklist /FI \"PID eq %s\" /FO CSV /NH" % os.getpid() out = os.popen(cmd).read() - total = 0 for amount in re.findall(r'([,0-9]+) K', out): total += int(amount.replace(',', '')) + return 'Memory Usage: \x02%s kB\x02' % total + return 'error: operating system not currently supported' - return '\x02Memory Usage: %s kB\x02' % total - - return mem.__doc__ @hook.command("system", autohelp=False) @hook.command(autohelp=False) From a49009c53cc728081d12505681427a8c6d0270e0 Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 30 Mar 2012 09:03:34 -0700 Subject: [PATCH 151/205] added uptime, but id does not work with hours. will fix later --- README.md | 6 +++--- plugins/admin.py | 2 +- plugins/system.py | 19 ++++++++++++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0fd541e..14d316d 100755 --- a/README.md +++ b/README.md @@ -25,13 +25,13 @@ Unzip the resulting file, and continue to read this document. ## Install -Before you can run the bot, you need to install a few Python modules. These are `lXML`, `BeautifulSoup`, `MyGengo`, and `HTTPlib2`. These can be installed with PIP (The Python package manager): +Before you can run the bot, you need to install a few Python modules. These are `lXML`, `BeautifulSoup`, `psutil`, and `HTTPlib2`. These can be installed with PIP (The Python package manager): `sudo pip install lxml` `sudo pip install beautifulsoup` -`sudo pip install mygengo` +`sudo pip install psutil` `sudo pip install httplib2` @@ -93,7 +93,7 @@ They can both be found in [#CloudBot](irc://irc.esper.net/cloudbot "Connect via CloudBot runs on **Python** *2.7.x*. It is developed on **Debian** *Wheezy/Testing* and **Ubuntu** *11.10* with **Python** *2.7.2*. -It **requires Python modules** `lXML`, `BeautifulSoup`, `Enchant`, `MyGengo`, and `HTTPlib2`. +It **requires Python modules** `lXML`, `BeautifulSoup`, `Enchant`, `psutil`, and `HTTPlib2`. The programs `screen` or `daemon` are recomended for the wrapper to run optimaly. diff --git a/plugins/admin.py b/plugins/admin.py index 2b88d12..8b120df 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -28,7 +28,7 @@ def stop(inp, nick=None, conn=None): else: conn.cmd("QUIT", ["Killed by %s." % nick]) time.sleep(5) - subprocess.call(["./cloudbot", "stop"]) + os.execl(["./cloudbot", "stop"]) @hook.command(autohelp=False, adminonly=True) def restart(inp, nick=None, conn=None): diff --git a/plugins/system.py b/plugins/system.py index 0c1ca7e..c45932d 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -1,9 +1,10 @@ import os import re +import time +import psutil import platform from util import hook - def replace(text, wordDic): rc = re.compile('|'.join(map(re.escape, wordDic))) @@ -24,9 +25,9 @@ def checkProc(checked_stats): def mem(inp): ".mem -- Displays the bot's current memory usage." if os.name == 'posix': - checked_stats = 'Threads VmRSS VmSize VmPeak VmStk' + checked_stats = 'Threads VmRSS VmSize VmPeak VmStk VmData' stats = checkProc(checked_stats) - pretty_names = {'Threads': 'Active Threads', 'VmRSS': 'Real Memory', 'VmSize': 'Allocated Memory', 'VmPeak': 'Peak Allocated Memory', 'VmStk': 'Stack Size'} + pretty_names = {'Threads': 'Active Threads', 'VmRSS': 'Real Memory', 'VmSize': 'Allocated Memory', 'VmPeak': 'Peak Allocated Memory', 'VmStk': 'Stack Size', 'VmData': 'Heap Size'} stats = replace(stats, pretty_names) return stats @@ -40,6 +41,18 @@ def mem(inp): return 'error: operating system not currently supported' +@hook.command("up", autohelp=False) +@hook.command(autohelp=False) +def uptime(inp): + proc = psutil.Process(os.getpid()) + up_time = proc.create_time + up_time = time.time() - up_time + up_time = time.localtime(up_time) + up_time = time.strftime("Uptime: %M:%S", up_time) + return up_time + + + @hook.command("system", autohelp=False) @hook.command(autohelp=False) def sys(inp): From 392b4b96c40fc35c97a634a95fcc38098c9eb414 Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 30 Mar 2012 09:10:48 -0700 Subject: [PATCH 152/205] moar bolding --- plugins/system.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/system.py b/plugins/system.py index c45932d..2c58f0f 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -48,7 +48,7 @@ def uptime(inp): up_time = proc.create_time up_time = time.time() - up_time up_time = time.localtime(up_time) - up_time = time.strftime("Uptime: %M:%S", up_time) + up_time = time.strftime("Uptime: \x02%M:%S\x02", up_time) return up_time @@ -60,4 +60,4 @@ def sys(inp): python_version = platform.python_version() os = platform.platform(aliased=True) cpu = platform.machine() - return "Platform: %s, Python Version: %s, CPU: %s" % (os, python_version, cpu) + return "Platform: \x02%s\x02, Python Version: \x02%s\x02, CPU: \x02%s\x02" % (os, python_version, cpu) From 84e18617d885a6a72dbd9e727161190d5abed9bb Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 30 Mar 2012 09:17:31 -0700 Subject: [PATCH 153/205] reprdered code, added .pid --- plugins/system.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/plugins/system.py b/plugins/system.py index 2c58f0f..128c0f6 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -20,6 +20,17 @@ def checkProc(checked_stats): stats = '\x02, '.join(key + ': \x02' + status[key] for key in checked_stats) return stats + +@hook.command("system", autohelp=False) +@hook.command(autohelp=False) +def sys(inp): + ".sys -- Retrieves information about the host system." + python_version = platform.python_version() + os = platform.platform(aliased=True) + cpu = platform.machine() + return "Platform: \x02%s\x02, Python Version: \x02%s\x02, CPU: \x02%s\x02" % (os, python_version, cpu) + + @hook.command("memory", autohelp=False) @hook.command(autohelp=False) def mem(inp): @@ -51,13 +62,6 @@ def uptime(inp): up_time = time.strftime("Uptime: \x02%M:%S\x02", up_time) return up_time - - -@hook.command("system", autohelp=False) @hook.command(autohelp=False) -def sys(inp): - ".sys -- Retrieves information about the host system." - python_version = platform.python_version() - os = platform.platform(aliased=True) - cpu = platform.machine() - return "Platform: \x02%s\x02, Python Version: \x02%s\x02, CPU: \x02%s\x02" % (os, python_version, cpu) +def pid(inp): + return 'PID: \x02%s\x02' % os.getpid() From a14b1f1fb62039467eabd1c14aa80d25fac978da Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 30 Mar 2012 09:31:36 -0700 Subject: [PATCH 154/205] tweaks, added help stings --- plugins/system.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/system.py b/plugins/system.py index 128c0f6..6d8c5b8 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -52,9 +52,10 @@ def mem(inp): return 'error: operating system not currently supported' -@hook.command("up", autohelp=False) +@hook.command("uptime", autohelp=False) @hook.command(autohelp=False) -def uptime(inp): +def up(inp): + ".up -- Shows the bot's uptime." proc = psutil.Process(os.getpid()) up_time = proc.create_time up_time = time.time() - up_time @@ -62,6 +63,8 @@ def uptime(inp): up_time = time.strftime("Uptime: \x02%M:%S\x02", up_time) return up_time +@hook.command("proc", autohelp=False) @hook.command(autohelp=False) def pid(inp): + ".pid -- Prints the bot's PID." return 'PID: \x02%s\x02' % os.getpid() From 12556902161c56ca80bbd88eb2fb017ae568562a Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 30 Mar 2012 11:48:24 -0700 Subject: [PATCH 155/205] added conversion of kb to mb --- plugins/system.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/plugins/system.py b/plugins/system.py index 6d8c5b8..b08ce84 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -1,6 +1,7 @@ import os import re import time +import string import psutil import platform from util import hook @@ -36,11 +37,22 @@ def sys(inp): def mem(inp): ".mem -- Displays the bot's current memory usage." if os.name == 'posix': - checked_stats = 'Threads VmRSS VmSize VmPeak VmStk VmData' - stats = checkProc(checked_stats) - pretty_names = {'Threads': 'Active Threads', 'VmRSS': 'Real Memory', 'VmSize': 'Allocated Memory', 'VmPeak': 'Peak Allocated Memory', 'VmStk': 'Stack Size', 'VmData': 'Heap Size'} - stats = replace(stats, pretty_names) - return stats + checked_stats = 'VmRSS VmSize VmPeak VmStk VmData' + memory = checkProc(checked_stats) + pretty_names = {'VmRSS': 'Real Memory', 'VmSize': 'Allocated Memory', 'VmPeak': 'Peak Allocated Memory', 'VmStk': 'Stack Size', 'VmData': 'Heap Size'} + memory = replace(memory, pretty_names) + memory = string.replace(memory, ' kB', '') + memory = memory.split('\x02') + numbers = [memory[i] for i in range(len(memory)) if i % 2 == 1] + memory = [i for i in memory if i not in numbers] + numbers = [float(x) for x in numbers] + numbers = [x / 1024 for x in numbers] + numbers = [str(x) for x in numbers] + numbers = [x + ' MB' for x in numbers] + memory = [list(l) for l in zip(memory, numbers)] + memory = sum(memory, []) + memory = '\x02'.join(memory) + return memory elif os.name == 'nt': cmd = "tasklist /FI \"PID eq %s\" /FO CSV /NH" % os.getpid() From ac9dfc99dfd93e9c616d9bf7a6fcb1531a5f28b4 Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 30 Mar 2012 12:06:36 -0700 Subject: [PATCH 156/205] added rounding,nadded conversion yo windows version --- plugins/system.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/plugins/system.py b/plugins/system.py index b08ce84..3bda3d8 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -45,23 +45,28 @@ def mem(inp): memory = memory.split('\x02') numbers = [memory[i] for i in range(len(memory)) if i % 2 == 1] memory = [i for i in memory if i not in numbers] - numbers = [float(x) for x in numbers] - numbers = [x / 1024 for x in numbers] - numbers = [str(x) for x in numbers] - numbers = [x + ' MB' for x in numbers] - memory = [list(l) for l in zip(memory, numbers)] + numbers = [float(i) for i in numbers] + numbers = [i / 1024 for i in numbers] + numbers = [round(i, 2) for i in numbers] + numbers = [str(i) for i in numbers] + numbers = [i + ' MB' for i in numbers] + memory = [list(i) for i in zip(memory, numbers)] memory = sum(memory, []) memory = '\x02'.join(memory) - return memory elif os.name == 'nt': cmd = "tasklist /FI \"PID eq %s\" /FO CSV /NH" % os.getpid() out = os.popen(cmd).read() - total = 0 + memory = 0 for amount in re.findall(r'([,0-9]+) K', out): - total += int(amount.replace(',', '')) - return 'Memory Usage: \x02%s kB\x02' % total - return 'error: operating system not currently supported' + memory += int(amount.replace(',', '')) + memory = float(memory) + memory = memory / 1024 + memory = round(memory, 2) + memory = 'Memory Usage: \x02%s MB\x02' % memory + else: + memory = 'error: operating system not currently supported' + return memory @hook.command("uptime", autohelp=False) From c0cb9671a1bde8d34157e53880be572d05f864fd Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 30 Mar 2012 14:52:00 -0700 Subject: [PATCH 157/205] cleaning up messy code --- plugins/system.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/plugins/system.py b/plugins/system.py index 3bda3d8..05ec335 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -45,11 +45,7 @@ def mem(inp): memory = memory.split('\x02') numbers = [memory[i] for i in range(len(memory)) if i % 2 == 1] memory = [i for i in memory if i not in numbers] - numbers = [float(i) for i in numbers] - numbers = [i / 1024 for i in numbers] - numbers = [round(i, 2) for i in numbers] - numbers = [str(i) for i in numbers] - numbers = [i + ' MB' for i in numbers] + numbers = [str(round(float(i) / 1024, 2)) + ' MB' for i in numbers] memory = [list(i) for i in zip(memory, numbers)] memory = sum(memory, []) memory = '\x02'.join(memory) From 17ab4e436d70371b5565c745784eb0e32264b975 Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 30 Mar 2012 15:04:11 -0700 Subject: [PATCH 158/205] optimized uptime code, fixed bug in ping.py --- plugins/ping.py | 4 ++-- plugins/system.py | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/plugins/ping.py b/plugins/ping.py index 9710fd7..67f76dd 100755 --- a/plugins/ping.py +++ b/plugins/ping.py @@ -10,9 +10,9 @@ ping_regex = re.compile(r"(\d+.\d+)/(\d+.\d+)/(\d+.\d+)/(\d+.\d+)") @hook.command def ping(inp, reply=None): ".ping [count] -- Pings [count] times." - + if os.name == "nt": - return "Sorry, this command is not supported on Windows systems." + return "Sorry, this command is not supported on Windows systems." args = inp.split(' ') host = args[0] diff --git a/plugins/system.py b/plugins/system.py index 05ec335..ce216b6 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -2,8 +2,8 @@ import os import re import time import string -import psutil import platform +import subprocess from util import hook def replace(text, wordDic): @@ -69,11 +69,8 @@ def mem(inp): @hook.command(autohelp=False) def up(inp): ".up -- Shows the bot's uptime." - proc = psutil.Process(os.getpid()) - up_time = proc.create_time - up_time = time.time() - up_time - up_time = time.localtime(up_time) - up_time = time.strftime("Uptime: \x02%M:%S\x02", up_time) + up_time = subprocess.check_output("ps -eo pid,etime | grep %s | awk '{print $2}'" % os.getpid(), shell=True) + up_time = "Uptime: " + up_time return up_time @hook.command("proc", autohelp=False) From 3c67274d5da818b8e5b69aef2d59382aea0a6301 Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 30 Mar 2012 16:38:31 -0700 Subject: [PATCH 159/205] cleaned code, added more detail into .sys --- plugins/system.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/system.py b/plugins/system.py index ce216b6..43cba6b 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -14,8 +14,8 @@ def replace(text, wordDic): return rc.sub(translate, text) def checkProc(checked_stats): - status_file = open("/proc/%d/status" % os.getpid()).read() - line_pairs = re.findall(r"^(\w+):\s*(.*)\s*$", status_file, re.M) + status_file = open('/proc/self/status').read() + line_pairs = re.findall(r'^(\w+):\s*(.*)\s*$', status_file, re.M) status = dict(line_pairs) checked_stats = checked_stats.split() stats = '\x02, '.join(key + ': \x02' + status[key] for key in checked_stats) @@ -26,10 +26,12 @@ def checkProc(checked_stats): @hook.command(autohelp=False) def sys(inp): ".sys -- Retrieves information about the host system." - python_version = platform.python_version() - os = platform.platform(aliased=True) + name = platform.node() + os = platform.platform() + python_version = platform.python_implementation() + ' ' + platform.python_version() + arch = '-'.join(platform.architecture()) cpu = platform.machine() - return "Platform: \x02%s\x02, Python Version: \x02%s\x02, CPU: \x02%s\x02" % (os, python_version, cpu) + return 'Name: \x02%s\x02, Operating System: \x02%s\x02, Python Version: \x02%s\x02, Architecture: \x02%s\x02, CPU: \x02%s\x02' % (name, os, python_version, arch, cpu) @hook.command("memory", autohelp=False) @@ -51,14 +53,12 @@ def mem(inp): memory = '\x02'.join(memory) elif os.name == 'nt': - cmd = "tasklist /FI \"PID eq %s\" /FO CSV /NH" % os.getpid() + cmd = 'tasklist /FI \"PID eq %s\" /FO CSV /NH' % os.getpid() out = os.popen(cmd).read() memory = 0 for amount in re.findall(r'([,0-9]+) K', out): memory += int(amount.replace(',', '')) - memory = float(memory) - memory = memory / 1024 - memory = round(memory, 2) + memory = str(round(float(memory) / 1024, 2)) memory = 'Memory Usage: \x02%s MB\x02' % memory else: memory = 'error: operating system not currently supported' @@ -69,8 +69,8 @@ def mem(inp): @hook.command(autohelp=False) def up(inp): ".up -- Shows the bot's uptime." - up_time = subprocess.check_output("ps -eo pid,etime | grep %s | awk '{print $2}'" % os.getpid(), shell=True) - up_time = "Uptime: " + up_time + up_time = subprocess.check_output('ps -eo pid,etime | grep %s | awk \'{print $2}\'' % os.getpid(), shell=True) + up_time = 'Uptime: \x02' + up_time + '\x02' return up_time @hook.command("proc", autohelp=False) From a69e7fa510bfa3eba78c2f0339c75e510441688a Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Sat, 31 Mar 2012 12:46:10 +1300 Subject: [PATCH 160/205] We don't need multiple hooks, this thing has autosuggest/complete --- plugins/system.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/plugins/system.py b/plugins/system.py index 43cba6b..1389903 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -22,10 +22,9 @@ def checkProc(checked_stats): return stats -@hook.command("system", autohelp=False) @hook.command(autohelp=False) -def sys(inp): - ".sys -- Retrieves information about the host system." +def system(inp): + ".system -- Retrieves information about the host system." name = platform.node() os = platform.platform() python_version = platform.python_implementation() + ' ' + platform.python_version() @@ -34,10 +33,9 @@ def sys(inp): return 'Name: \x02%s\x02, Operating System: \x02%s\x02, Python Version: \x02%s\x02, Architecture: \x02%s\x02, CPU: \x02%s\x02' % (name, os, python_version, arch, cpu) -@hook.command("memory", autohelp=False) @hook.command(autohelp=False) -def mem(inp): - ".mem -- Displays the bot's current memory usage." +def memory(inp): + ".memory -- Displays the bot's current memory usage." if os.name == 'posix': checked_stats = 'VmRSS VmSize VmPeak VmStk VmData' memory = checkProc(checked_stats) @@ -65,15 +63,13 @@ def mem(inp): return memory -@hook.command("uptime", autohelp=False) @hook.command(autohelp=False) -def up(inp): - ".up -- Shows the bot's uptime." +def uptime(inp): + ".uptime -- Shows the bot's uptime." up_time = subprocess.check_output('ps -eo pid,etime | grep %s | awk \'{print $2}\'' % os.getpid(), shell=True) up_time = 'Uptime: \x02' + up_time + '\x02' return up_time -@hook.command("proc", autohelp=False) @hook.command(autohelp=False) def pid(inp): ".pid -- Prints the bot's PID." From 22ba86ec5ae5a4fc05fd0a296dba46e0bfaa69f3 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Sat, 31 Mar 2012 12:52:51 +1300 Subject: [PATCH 161/205] You can now ignore by host --- plugins/ignore.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/ignore.py b/plugins/ignore.py index a12142a..9d3ab6a 100755 --- a/plugins/ignore.py +++ b/plugins/ignore.py @@ -30,7 +30,7 @@ def ignoresieve(bot, input, func, type, args): # don't block input to event hooks if type == "event": return input - if is_ignored(input.chan) or is_ignored(input.nick): + if is_ignored(input.chan) or is_ignored(input.nick) or is_ignored(input.host): if input.command == "PRIVMSG" and input.lastparam[1:] == "unignore": return input else: @@ -40,16 +40,16 @@ def ignoresieve(bot, input, func, type, args): @hook.command(autohelp=False) def ignored(inp, bot=None): - ".ignored -- Lists ignored channels/users." + ".ignored -- Lists ignored channels/users/hosts." if ignorelist: - return "Ignored channels/users are: %s" % ", ".join(ignorelist) + return "Ignored channels/users/hosts are: %s" % ", ".join(ignorelist) else: - return "No channels/users are currently ignored." + return "No channels/users/hosts are currently ignored." @hook.command(adminonly=True) def ignore(inp, input=None, notice=None): - ".ignore -- Makes the bot ignore ." + ".ignore -- Makes the bot ignore someone." target = inp if is_ignored(target): @@ -61,7 +61,7 @@ def ignore(inp, input=None, notice=None): @hook.command(adminonly=True) def unignore(inp, input=None, notice=None): - ".unignore -- Makes the bot listen to ." + ".unignore channels/users/hosts -- Makes the bot listen to someone." target = inp if is_ignored(target): From e90d72e6e055e8efa04863b070168c359beb5498 Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 30 Mar 2012 16:58:12 -0700 Subject: [PATCH 162/205] docstring tweaks --- plugins/ignore.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/ignore.py b/plugins/ignore.py index 9d3ab6a..48475df 100755 --- a/plugins/ignore.py +++ b/plugins/ignore.py @@ -49,7 +49,7 @@ def ignored(inp, bot=None): @hook.command(adminonly=True) def ignore(inp, input=None, notice=None): - ".ignore -- Makes the bot ignore someone." + ".ignore -- Makes the bot ignore ." target = inp if is_ignored(target): @@ -61,7 +61,7 @@ def ignore(inp, input=None, notice=None): @hook.command(adminonly=True) def unignore(inp, input=None, notice=None): - ".unignore channels/users/hosts -- Makes the bot listen to someone." + ".unignore -- Makes the bot listen to ." target = inp if is_ignored(target): @@ -71,3 +71,4 @@ def unignore(inp, input=None, notice=None): else: notice("%s is not ignored." % target) return + From 10e975ed69dbfd4e80e26d52be0108565dac434c Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 30 Mar 2012 17:07:29 -0700 Subject: [PATCH 163/205] rename .act to .me --- plugins/admin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index 8b120df..05052cf 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -137,10 +137,10 @@ def say(inp, conn=None, chan=None, notice=None): conn.send(out) -@hook.command("me", adminonly=True) +@hook.command("act", adminonly=True) @hook.command(adminonly=True) -def act(inp, conn=None, chan=None, notice=None): - ".act [channel] -- Makes the bot act out in [channel] "\ +def me(inp, conn=None, chan=None, notice=None): + ".me [channel] -- Makes the bot act out in [channel] "\ "If [channel] is blank the bot will act the in "\ "the channel the command was used in." split = inp.split(" ") From 0e6840b0a8a52e185618daa4f2cf1619c928076a Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 30 Mar 2012 17:19:47 -0700 Subject: [PATCH 164/205] .me bugfix --- plugins/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/admin.py b/plugins/admin.py index 05052cf..dcd6c4e 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -155,7 +155,7 @@ def me(inp, conn=None, chan=None, notice=None): for x in split[0:]: message = message + x + " " message = message[:-1] - out = "PRIVMSG %s :\x01ACTION %s\x01" % (input.chan, message) + out = "PRIVMSG %s :\x01ACTION %s\x01" % (chan, message) conn.send(out) From e93d4ed231e231e5982c4fa7f4e0f4ced0d483da Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 30 Mar 2012 17:26:38 -0700 Subject: [PATCH 165/205] removed mtg.py --- plugins/ignore.py | 4 +- plugins/mtg.py | 183 ---------------------------------------------- 2 files changed, 2 insertions(+), 185 deletions(-) delete mode 100755 plugins/mtg.py diff --git a/plugins/ignore.py b/plugins/ignore.py index 48475df..795d515 100755 --- a/plugins/ignore.py +++ b/plugins/ignore.py @@ -49,7 +49,7 @@ def ignored(inp, bot=None): @hook.command(adminonly=True) def ignore(inp, input=None, notice=None): - ".ignore -- Makes the bot ignore ." + ".ignore -- Makes the bot ignore ." target = inp if is_ignored(target): @@ -61,7 +61,7 @@ def ignore(inp, input=None, notice=None): @hook.command(adminonly=True) def unignore(inp, input=None, notice=None): - ".unignore -- Makes the bot listen to ." + ".unignore -- Makes the bot listen to ." target = inp if is_ignored(target): diff --git a/plugins/mtg.py b/plugins/mtg.py deleted file mode 100755 index 3db8306..0000000 --- a/plugins/mtg.py +++ /dev/null @@ -1,183 +0,0 @@ -import re - -from util import hook, http - - -@hook.command -def mtg(inp): - ".mtg -- Gets information about Magic the Gathering card ." - - url = 'http://magiccards.info/query?v=card&s=cname' - h = http.get_html(url, q=inp) - - name = h.find('body/table/tr/td/span/a') - if name is None: - return "No cards found :(" - card = name.getparent().getparent().getparent() - - type = card.find('td/p').text.replace('\n', '') - - # this is ugly - text = http.html.tostring(card.xpath("//p[@class='ctext']/b")[0]) - text = text.replace('
', '$') - text = http.html.fromstring(text).text_content() - text = re.sub(r'(\w+\s*)\$+(\s*\w+)', r'\1. \2', text) - text = text.replace('$', ' ') - text = re.sub(r'\(.*?\)', '', text) # strip parenthetical explanations - text = re.sub(r'\.(\S)', r'. \1', text) # fix spacing - - printings = card.find('td/small').text_content() - printings = re.search(r'Editions:(.*)Languages:', printings).group(1) - printings = re.findall(r'\s*(.+?(?: \([^)]+\))*) \((.*?)\)', - ' '.join(printings.split())) - - printing_out = ', '.join('%s (%s)' % (set_abbrevs.get(x[0], x[0]), - rarity_abbrevs.get(x[1], x[1])) - for x in printings) - - name.make_links_absolute(base_url=url) - link = name.attrib['href'] - name = name.text_content().strip() - type = type.strip() - text = ' '.join(text.split()) - - return ' | '.join((name, type, text, printing_out, link)) - - -set_abbrevs = { - '15th Anniversary': '15ANN', - 'APAC Junior Series': 'AJS', - 'Alara Reborn': 'ARB', - 'Alliances': 'AI', - 'Anthologies': 'AT', - 'Antiquities': 'AQ', - 'Apocalypse': 'AP', - 'Arabian Nights': 'AN', - 'Arena League': 'ARENA', - 'Asia Pacific Land Program': 'APAC', - 'Battle Royale': 'BR', - 'Battle Royale Box Set': 'BRB', - 'Beatdown': 'BTD', - 'Beatdown Box Set': 'BTD', - 'Betrayers of Kamigawa': 'BOK', - 'Celebration Cards': 'UQC', - 'Champions of Kamigawa': 'CHK', - 'Champs': 'CP', - 'Chronicles': 'CH', - 'Classic Sixth Edition': '6E', - 'Coldsnap': 'CS', - 'Coldsnap Theme Decks': 'CSTD', - 'Conflux': 'CFX', - 'Core Set - Eighth Edition': '8E', - 'Core Set - Ninth Edition': '9E', - 'Darksteel': 'DS', - 'Deckmasters': 'DM', - 'Dissension': 'DI', - 'Dragon Con': 'DRC', - 'Duel Decks: Divine vs. Demonic': 'DVD', - 'Duel Decks: Elves vs. Goblins': 'EVG', - 'Duel Decks: Garruk vs. Liliana': 'GVL', - 'Duel Decks: Jace vs. Chandra': 'JVC', - 'Eighth Edition': '8ED', - 'Eighth Edition Box Set': '8EB', - 'European Land Program': 'EURO', - 'Eventide': 'EVE', - 'Exodus': 'EX', - 'Fallen Empires': 'FE', - 'Fifth Dawn': '5DN', - 'Fifth Edition': '5E', - 'Fourth Edition': '4E', - 'Friday Night Magic': 'FNMP', - 'From the Vault: Dragons': 'FVD', - 'From the Vault: Exiled': 'FVE', - 'Future Sight': 'FUT', - 'Gateway': 'GRC', - 'Grand Prix': 'GPX', - 'Guildpact': 'GP', - 'Guru': 'GURU', - 'Happy Holidays': 'HHO', - 'Homelands': 'HL', - 'Ice Age': 'IA', - 'Introductory Two-Player Set': 'ITP', - 'Invasion': 'IN', - 'Judge Gift Program': 'JR', - 'Judgment': 'JU', - 'Junior Series': 'JSR', - 'Legend Membership': 'DCILM', - 'Legends': 'LG', - 'Legions': 'LE', - 'Limited Edition (Alpha)': 'LEA', - 'Limited Edition (Beta)': 'LEB', - 'Limited Edition Alpha': 'LEA', - 'Limited Edition Beta': 'LEB', - 'Lorwyn': 'LW', - 'MTGO Masters Edition': 'MED', - 'MTGO Masters Edition II': 'ME2', - 'MTGO Masters Edition III': 'ME3', - 'Magic 2010': 'M10', - 'Magic Game Day Cards': 'MGDC', - 'Magic Player Rewards': 'MPRP', - 'Magic Scholarship Series': 'MSS', - 'Magic: The Gathering Launch Parties': 'MLP', - 'Media Inserts': 'MBP', - 'Mercadian Masques': 'MM', - 'Mirage': 'MR', - 'Mirrodin': 'MI', - 'Morningtide': 'MT', - 'Multiverse Gift Box Cards': 'MGBC', - 'Nemesis': 'NE', - 'Ninth Edition Box Set': '9EB', - 'Odyssey': 'OD', - 'Onslaught': 'ON', - 'Planar Chaos': 'PC', - 'Planechase': 'PCH', - 'Planeshift': 'PS', - 'Portal': 'PO', - 'Portal Demogame': 'POT', - 'Portal Second Age': 'PO2', - 'Portal Three Kingdoms': 'P3K', - 'Premium Deck Series: Slivers': 'PDS', - 'Prerelease Events': 'PTC', - 'Pro Tour': 'PRO', - 'Prophecy': 'PR', - 'Ravnica: City of Guilds': 'RAV', - 'Release Events': 'REP', - 'Revised Edition': 'RV', - 'Saviors of Kamigawa': 'SOK', - 'Scourge': 'SC', - 'Seventh Edition': '7E', - 'Shadowmoor': 'SHM', - 'Shards of Alara': 'ALA', - 'Starter': 'ST', - 'Starter 1999': 'S99', - 'Starter 2000 Box Set': 'ST2K', - 'Stronghold': 'SH', - 'Summer of Magic': 'SOM', - 'Super Series': 'SUS', - 'Tempest': 'TP', - 'Tenth Edition': '10E', - 'The Dark': 'DK', - 'Time Spiral': 'TS', - 'Time Spiral Timeshifted': 'TSTS', - 'Torment': 'TR', - 'Two-Headed Giant Tournament': 'THGT', - 'Unglued': 'UG', - 'Unhinged': 'UH', - 'Unhinged Alternate Foils': 'UHAA', - 'Unlimited Edition': 'UN', - "Urza's Destiny": 'UD', - "Urza's Legacy": 'UL', - "Urza's Saga": 'US', - 'Visions': 'VI', - 'Weatherlight': 'WL', - 'Worlds': 'WRL', - 'WotC Online Store': 'WOTC', - 'Zendikar': 'ZEN'} - -rarity_abbrevs = { - 'Land': 'L', - 'Common': 'C', - 'Uncommon': 'UC', - 'Rare': 'R', - 'Special': 'S', - 'Mythic Rare': 'MR'} From bdb08fc23f7067b8a63785757f718b21e0c7411a Mon Sep 17 00:00:00 2001 From: neersighted Date: Fri, 30 Mar 2012 18:12:43 -0700 Subject: [PATCH 166/205] tweaked error message, added mtg.py to disabled_plugins --- disabled_plugins/mtg.py | 183 ++++++++++++++++++++++++++++++++++++++++ plugins/stock.py | 2 +- 2 files changed, 184 insertions(+), 1 deletion(-) create mode 100755 disabled_plugins/mtg.py diff --git a/disabled_plugins/mtg.py b/disabled_plugins/mtg.py new file mode 100755 index 0000000..3db8306 --- /dev/null +++ b/disabled_plugins/mtg.py @@ -0,0 +1,183 @@ +import re + +from util import hook, http + + +@hook.command +def mtg(inp): + ".mtg -- Gets information about Magic the Gathering card ." + + url = 'http://magiccards.info/query?v=card&s=cname' + h = http.get_html(url, q=inp) + + name = h.find('body/table/tr/td/span/a') + if name is None: + return "No cards found :(" + card = name.getparent().getparent().getparent() + + type = card.find('td/p').text.replace('\n', '') + + # this is ugly + text = http.html.tostring(card.xpath("//p[@class='ctext']/b")[0]) + text = text.replace('
', '$') + text = http.html.fromstring(text).text_content() + text = re.sub(r'(\w+\s*)\$+(\s*\w+)', r'\1. \2', text) + text = text.replace('$', ' ') + text = re.sub(r'\(.*?\)', '', text) # strip parenthetical explanations + text = re.sub(r'\.(\S)', r'. \1', text) # fix spacing + + printings = card.find('td/small').text_content() + printings = re.search(r'Editions:(.*)Languages:', printings).group(1) + printings = re.findall(r'\s*(.+?(?: \([^)]+\))*) \((.*?)\)', + ' '.join(printings.split())) + + printing_out = ', '.join('%s (%s)' % (set_abbrevs.get(x[0], x[0]), + rarity_abbrevs.get(x[1], x[1])) + for x in printings) + + name.make_links_absolute(base_url=url) + link = name.attrib['href'] + name = name.text_content().strip() + type = type.strip() + text = ' '.join(text.split()) + + return ' | '.join((name, type, text, printing_out, link)) + + +set_abbrevs = { + '15th Anniversary': '15ANN', + 'APAC Junior Series': 'AJS', + 'Alara Reborn': 'ARB', + 'Alliances': 'AI', + 'Anthologies': 'AT', + 'Antiquities': 'AQ', + 'Apocalypse': 'AP', + 'Arabian Nights': 'AN', + 'Arena League': 'ARENA', + 'Asia Pacific Land Program': 'APAC', + 'Battle Royale': 'BR', + 'Battle Royale Box Set': 'BRB', + 'Beatdown': 'BTD', + 'Beatdown Box Set': 'BTD', + 'Betrayers of Kamigawa': 'BOK', + 'Celebration Cards': 'UQC', + 'Champions of Kamigawa': 'CHK', + 'Champs': 'CP', + 'Chronicles': 'CH', + 'Classic Sixth Edition': '6E', + 'Coldsnap': 'CS', + 'Coldsnap Theme Decks': 'CSTD', + 'Conflux': 'CFX', + 'Core Set - Eighth Edition': '8E', + 'Core Set - Ninth Edition': '9E', + 'Darksteel': 'DS', + 'Deckmasters': 'DM', + 'Dissension': 'DI', + 'Dragon Con': 'DRC', + 'Duel Decks: Divine vs. Demonic': 'DVD', + 'Duel Decks: Elves vs. Goblins': 'EVG', + 'Duel Decks: Garruk vs. Liliana': 'GVL', + 'Duel Decks: Jace vs. Chandra': 'JVC', + 'Eighth Edition': '8ED', + 'Eighth Edition Box Set': '8EB', + 'European Land Program': 'EURO', + 'Eventide': 'EVE', + 'Exodus': 'EX', + 'Fallen Empires': 'FE', + 'Fifth Dawn': '5DN', + 'Fifth Edition': '5E', + 'Fourth Edition': '4E', + 'Friday Night Magic': 'FNMP', + 'From the Vault: Dragons': 'FVD', + 'From the Vault: Exiled': 'FVE', + 'Future Sight': 'FUT', + 'Gateway': 'GRC', + 'Grand Prix': 'GPX', + 'Guildpact': 'GP', + 'Guru': 'GURU', + 'Happy Holidays': 'HHO', + 'Homelands': 'HL', + 'Ice Age': 'IA', + 'Introductory Two-Player Set': 'ITP', + 'Invasion': 'IN', + 'Judge Gift Program': 'JR', + 'Judgment': 'JU', + 'Junior Series': 'JSR', + 'Legend Membership': 'DCILM', + 'Legends': 'LG', + 'Legions': 'LE', + 'Limited Edition (Alpha)': 'LEA', + 'Limited Edition (Beta)': 'LEB', + 'Limited Edition Alpha': 'LEA', + 'Limited Edition Beta': 'LEB', + 'Lorwyn': 'LW', + 'MTGO Masters Edition': 'MED', + 'MTGO Masters Edition II': 'ME2', + 'MTGO Masters Edition III': 'ME3', + 'Magic 2010': 'M10', + 'Magic Game Day Cards': 'MGDC', + 'Magic Player Rewards': 'MPRP', + 'Magic Scholarship Series': 'MSS', + 'Magic: The Gathering Launch Parties': 'MLP', + 'Media Inserts': 'MBP', + 'Mercadian Masques': 'MM', + 'Mirage': 'MR', + 'Mirrodin': 'MI', + 'Morningtide': 'MT', + 'Multiverse Gift Box Cards': 'MGBC', + 'Nemesis': 'NE', + 'Ninth Edition Box Set': '9EB', + 'Odyssey': 'OD', + 'Onslaught': 'ON', + 'Planar Chaos': 'PC', + 'Planechase': 'PCH', + 'Planeshift': 'PS', + 'Portal': 'PO', + 'Portal Demogame': 'POT', + 'Portal Second Age': 'PO2', + 'Portal Three Kingdoms': 'P3K', + 'Premium Deck Series: Slivers': 'PDS', + 'Prerelease Events': 'PTC', + 'Pro Tour': 'PRO', + 'Prophecy': 'PR', + 'Ravnica: City of Guilds': 'RAV', + 'Release Events': 'REP', + 'Revised Edition': 'RV', + 'Saviors of Kamigawa': 'SOK', + 'Scourge': 'SC', + 'Seventh Edition': '7E', + 'Shadowmoor': 'SHM', + 'Shards of Alara': 'ALA', + 'Starter': 'ST', + 'Starter 1999': 'S99', + 'Starter 2000 Box Set': 'ST2K', + 'Stronghold': 'SH', + 'Summer of Magic': 'SOM', + 'Super Series': 'SUS', + 'Tempest': 'TP', + 'Tenth Edition': '10E', + 'The Dark': 'DK', + 'Time Spiral': 'TS', + 'Time Spiral Timeshifted': 'TSTS', + 'Torment': 'TR', + 'Two-Headed Giant Tournament': 'THGT', + 'Unglued': 'UG', + 'Unhinged': 'UH', + 'Unhinged Alternate Foils': 'UHAA', + 'Unlimited Edition': 'UN', + "Urza's Destiny": 'UD', + "Urza's Legacy": 'UL', + "Urza's Saga": 'US', + 'Visions': 'VI', + 'Weatherlight': 'WL', + 'Worlds': 'WRL', + 'WotC Online Store': 'WOTC', + 'Zendikar': 'ZEN'} + +rarity_abbrevs = { + 'Land': 'L', + 'Common': 'C', + 'Uncommon': 'UC', + 'Rare': 'R', + 'Special': 'S', + 'Mythic Rare': 'MR'} diff --git a/plugins/stock.py b/plugins/stock.py index 0afdc13..c598d9e 100755 --- a/plugins/stock.py +++ b/plugins/stock.py @@ -20,7 +20,7 @@ def stock(inp): # if we dont get a company name back, the symbol doesn't match a company if results['company'] == '': - return "unknown ticker symbol %s" % inp + return "error: unknown ticker symbol (%s)" % inp if results['change'][0] == '-': results['color'] = "5" From 0a0e10d363574dcf469cffc033436552f22f9582 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sat, 31 Mar 2012 08:19:17 -0700 Subject: [PATCH 167/205] credit --- plugins/system.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/system.py b/plugins/system.py index 1389903..f67b16d 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -1,3 +1,4 @@ +# Plugin by Lukeroge, and neersighted import os import re import time From 79edc5e8bc0ad6c9d504b54c3ee40f71fcbde67c Mon Sep 17 00:00:00 2001 From: neersighted Date: Sat, 31 Mar 2012 08:20:51 -0700 Subject: [PATCH 168/205] bugfix --- plugins/admin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index dcd6c4e..732a62a 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -166,5 +166,5 @@ def topic(inp, conn=None, chan=None, notice=None): if split[0][0] == "#": out = "PRIVMSG %s :%s" % (split[0], message) else: - out = "TOPIC %s :%s" % (input.chan, message) - input.conn.send(out) + out = "TOPIC %s :%s" % (chan, message) + conn.send(out) From 62b3e84ca051f1d67509d649215da6a039f821c8 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sat, 31 Mar 2012 08:57:51 -0700 Subject: [PATCH 169/205] message tweaks --- plugins/tell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/tell.py b/plugins/tell.py index 9c903ad..10ed0eb 100755 --- a/plugins/tell.py +++ b/plugins/tell.py @@ -87,7 +87,7 @@ def tell(inp, nick='', chan='', db=None, input=None, notice=None): chan = 'a pm' if user_to == user_from.lower(): - notice("Nope.") + notice("Have you looked in a mirror lately?") return if user_to.lower() == input.conn.nick.lower(): From 1e13e8e2639e54dc45067163425930bf6745253d Mon Sep 17 00:00:00 2001 From: neersighted Date: Sat, 31 Mar 2012 09:22:06 -0700 Subject: [PATCH 170/205] Updated code --- plugins/tell.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/tell.py b/plugins/tell.py index 10ed0eb..2d7fffd 100755 --- a/plugins/tell.py +++ b/plugins/tell.py @@ -25,7 +25,7 @@ def get_tells(db, user_to): @hook.singlethread @hook.event('PRIVMSG') -def tellinput(paraml, input=None, db=None, bot=None): +def tellinput(paraml, input=None, notice=None, db=None, bot=None): if 'showtells' in input.msg.lower(): return @@ -45,7 +45,7 @@ def tellinput(paraml, input=None, db=None, bot=None): db.execute("delete from tell where user_to=lower(?) and message=?", (input.nick, message)) db.commit() - input.notice(reply) + notice(reply) @hook.command(autohelp=False) From 07620186775f647fc1847777de6bf9218dab42d9 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sat, 31 Mar 2012 09:24:05 -0700 Subject: [PATCH 171/205] wrapper fixes --- cloudbot | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cloudbot b/cloudbot index b422659..2b2a605 100755 --- a/cloudbot +++ b/cloudbot @@ -111,8 +111,7 @@ processargs() { status ;; *) - echo "Please enter a command:" - usage="./cloudbot {start|stop|restart|clear|status}" + usage="usage: ./cloudbot {start|stop|restart|clear|status}" echo $usage ;; esac From 1c374114ecdcb9e245298dceac4feeec3c54af37 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sat, 31 Mar 2012 16:01:23 -0700 Subject: [PATCH 172/205] Made feelings.py use the data/ dir, updated other plugins to not use input.* --- plugins/data/flirts.txt | 40 +++++++++++++ plugins/data/insults.txt | 32 ++++++++++ plugins/feelings.py | 125 +++++++++++---------------------------- plugins/repaste.py | 10 ++-- plugins/tell.py | 6 +- 5 files changed, 113 insertions(+), 100 deletions(-) create mode 100755 plugins/data/flirts.txt create mode 100755 plugins/data/insults.txt diff --git a/plugins/data/flirts.txt b/plugins/data/flirts.txt new file mode 100755 index 0000000..13e6710 --- /dev/null +++ b/plugins/data/flirts.txt @@ -0,0 +1,40 @@ +I bet your name's Mickey, 'cause you're so fine. +Hey, pretty mama. You smell kinda pretty, wanna smell me? +I better get out my library card, 'cause I'm checkin' you out. +If you were a booger, I'd pick you. +If I could rearrange the alphabet, I would put U and I together. +I've been bad, take me to your room. +I think Heaven's missing an angel. +That shirt looks good on you, it'd look better on my bedroom floor. +I cant help to notice but you look a lot like my next girlfriend. +Aren't your feet tired? Because you've been running through my mind all day. +I must be asleep, 'cause you are a dream come true. Also, I'm slightly damp. +I like large posteriors and I cannot prevaricate. +How you doin'? +If I said you had a good body, would you hold it against me? +Hey, baby cakes. +Nice butt. +I love you like a fat kid loves cake. +Do you believe in love at first sight? Or should I walk by again...? +Want to see my good side? Hahaha, that was a trick question, all I have are good sides. +You look like a woman who appreciates the finer things in life. Come over here and feel my velour bedspread. +Now you're officially my woman. Kudos! I can't say I don't envy you. +I find that the most erotic part of a woman is the boobies. +If you want to climb aboard the Love Train, you've got to stand on the Love Tracks. But you might just get smushed by a very sensual cow-catcher. +Lets say you and I knock some very /sensual/ boots. +I lost my phone number, can I have yours? +Does this rag smell like chloroform to you? +I'm here, where are your other two wishes? +Apart from being sexy, what do you do for a living? +Hi, I'm Mr. Right. Someone said you were looking for me. +You got something on your chest: My eyes. +Are you from Tennessee? Cause you're the only TEN I see. +Are you an alien? Because you just abducted my heart. +Excuse me, but I think you dropped something!!! MY JAW!!! +If I followed you home, would you keep me? +Where have you been all my life? +I'm just a love machine, and I don't work for nobody but you. +Do you live on a chicken farm? Because you sure know how to raise cocks. +Are you wearing space pants? Because your ass is out of this world. +Nice legs. What time do they open? +Your daddy must have been a baker, because you've got a nice set of buns. diff --git a/plugins/data/insults.txt b/plugins/data/insults.txt new file mode 100755 index 0000000..0eb5d09 --- /dev/null +++ b/plugins/data/insults.txt @@ -0,0 +1,32 @@ +You are the son of a motherless ogre. +Your mother was a hamster and your father smelled of elderberries. +I once owned a dog that was smarter than you. +Go climb a wall of dicks. +You fight like a dairy farmer. +I've spoken to apes more polite than you. +Go and boil your bottom! Son of a silly person! +I fart in your general direction. +Go away or I shall taunt you a second time. +Shouldn't you have a license for being that ugly? +Calling you an idiot would be an insult to all the stupid people. +Why don't you slip into something more comfortable...like a coma. +Well, they do say opposites attract...so I sincerely hope you meet somebody who is attractive, honest, intelligent, and cultured... +Are you always this stupid or are you just making a special effort today? +Yo momma so fat when she sits around the house she sits AROUND the house. +Yo momma so ugly she made an onion cry. +Is your name Maple Syrup? It should be, you sap. +Bite my shiny metal ass! +Up yours, meatbag. +Jam a bastard in it you crap! +Don't piss me off today, I'm running out of places to hide the bodies +Why don't you go outside and play hide and go fuck yourself +I'll use small words you're sure to understand, you warthog-faced buffoon. +You are a sad, strange little man, and you have my pity. +Sit your five dollar ass down before I make change. +What you've just said is one of the most insanely idiotic things I've ever heard. Everyone in this room is now dumber for having listened to it. May God have mercy on your soul. +Look up Idiot in the dictionary. Know what you'll find? The definition of the word IDIOT, which you are. +You're dumber than a bag of hammers. +Why don't you go back to your home on Whore Island? +If I had a dick this is when I'd tell you to suck it. +Go play in traffic. +The village called, they want their idiot back. diff --git a/plugins/feelings.py b/plugins/feelings.py index 4437d61..d2cb2d7 100755 --- a/plugins/feelings.py +++ b/plugins/feelings.py @@ -2,112 +2,53 @@ from util import hook import re import random -insults = ["You are the son of a motherless ogre.", - "Your mother was a hamster and your father smelled of elderberries.", - "I once owned a dog that was smarter than you. ", - "Go climb a wall of dicks.", - "You fight like a dairy farmer.", - "I've spoken to apes more polite than you.", - "Go and boil your bottom! Son of a silly person! ", - "I fart in your general direction.", - "Go away or I shall taunt you a second time. ", - "Shouldn't you have a license for being that ugly?", - "Calling you an idiot would be an insult to all the stupid people.", - "Why don't you slip into something more comfortable...like a coma.", - "Well, they do say opposites attract...so I sincerely hope you meet somebody who is attractive, honest, intelligent, and cultured..", - "Are you always this stupid or are you just making a special effort today?", - "Yo momma so fat when she sits around the house she sits AROUND the house.", - "Yo momma so ugly she made an onion cry.", - "Is your name Maple Syrup? It should be, you sap.", - "Bite my shiny metal ass!", - "Up yours, meatbag.", - "Jam a bastard in it you crap!", - "Don't piss me off today, I'm running out of places to hide the bodies", - "Why don't you go outside and play hide and go fuck yourself", - "I'll use small words you're sure to understand, you warthog-faced buffoon.", - "You are a sad, strange little man, and you have my pity.", - "Sit your five dollar ass down before I make change.", - "What you've just said is one of the most insanely idiotic things I've ever heard. Everyone in this room is now dumber for having listened to it. May God have mercy on your soul.", - "Look up Idiot in the dictionary. Know what you'll find? The definition of the word IDIOT, which you are.", - "You're dumber than a bag of hammers.", - "Why don't you go back to your home on Whore Island?", - "If I had a dick this is when I'd tell you to suck it.", - "Go play in traffic.", - "The village called, they want their idiot back."] +nick_re = re.compile(r"^[A-Za-z0-9_|.-\]\[]*$") -flirts = ["I bet your name's Mickey, 'cause you're so fine.", - "Hey, pretty mama. You smell kinda pretty, wanna smell me?", - "I better get out my library card, 'cause I'm checkin' you out.", - "If you were a booger, I'd pick you.", - "If I could rearrange the alphabet, I would put U and I together.", - "I've been bad, take me to your room.", - "I think Heaven's missing an angel.", - "That shirt looks good on you, it'd look better on my bedroom floor.", - "I cant help to notice but you look a lot like my next girlfriend.", - "Aren't your feet tired? Because you've been running through my mind all day.", - "I must be asleep, 'cause you are a dream come true. Also, I'm slightly damp.", - "I like large posteriors and I cannot prevaricate.", - "How you doin'?", - "If I said you had a good body, would you hold it against me?", - "Hey, baby cakes.", - "Nice butt.", - "I love you like a fat kid loves cake.", - "Do you believe in love at first sight? Or should I walk by again...?", - "Want to see my good side? Hahaha, that was a trick question, all I have are good sides.", - "You look like a woman who appreciates the finer things in life. Come over here and feel my velour bedspread.", - "Now you're officially my woman. Kudos! I can't say I don't envy you.", - "I find that the most erotic part of a woman is the boobies.", - "If you want to climb aboard the Love Train, you've got to stand on the Love Tracks. But you might just get smushed by a very sensual cow-catcher.", - "Lets say you and I knock some very /sensual/ boots.", - "I lost my phone number, can I have yours?", - "Does this rag smell like chloroform to you? ", - "I'm here, where are your other two wishes?", - "Apart from being sexy, what do you do for a living?", - "Hi, I'm Mr. Right. Someone said you were looking for me.", - "You got something on your chest: My eyes.", - "Are you from Tennessee? Cause you're the only TEN I see.", - "Are you an alien? Because you just abducted my heart.", - "Excuse me, but I think you dropped something!!! MY JAW!!!", - "If I followed you home, would you keep me?", - "Where have you been all my life?", - "I'm just a love machine, and I don't work for nobody but you.", - "Do you live on a chicken farm? Because you sure know how to raise cocks.", - "Are you wearing space pants? Because your ass is out of this world.", - "Nice legs. What time do they open?", - "Your daddy must have been a baker, because you've got a nice set of buns."] +insults = [] +flirts = [] + +with open("plugins/data/insults.txt") as f: + for line in f.readlines(): + if line.startswith("//"): + continue + insults.append(line.strip()) + +with open("plugins/data/flirts.txt") as f: + for line in f.readlines(): + if line.startswith("//"): + continue + flirts.append(line.strip()) -@hook.command(autohelp=False) -def insult(inp, nick=None, me=None, input=None): +@hook.command +def insult(inp, nick=None, me=None, conn=None): ".insult -- Makes the bot insult ." - inp = inp.strip() + target = inp.strip() - if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): + if not re.match(nick_re, target): notice("Invalid username!") return - target = nick - if inp.lower() and inp != "": - target = inp - if inp == input.conn.nick.lower() or inp == "itself": + if target == conn.nick.lower() or target == "itself": target = nick - msg = "insults " + target + "... \"" + random.choice(insults) + "\"" - me(msg) + else: + target = inp + out = "insults " + target + "... \"" + random.choice(insults) + "\"" + me(out) -@hook.command(autohelp=False) -def flirt(inp, nick=None, me=None, input=None): +@hook.command +def flirt(inp, nick=None, me=None, conn=None): ".flirt -- Make the bot flirt with ." - inp = inp.strip() + target = inp.strip() - if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): + if not re.match(nick_re, target): notice("Invalid username!") return - target = nick - if inp.lower() and inp != "": + if target == conn.nick.lower() or target == "itself": + target = 'itself' + else: target = inp - if inp == input.conn.nick.lower() or inp == "itself": - target = "itself" - msg = "flirts with " + target + "... \"" + random.choice(flirts) + "\"" - me(msg) + out = "flirts with " + target + "... \"" + random.choice(flirts) + "\"" + me(out) diff --git a/plugins/repaste.py b/plugins/repaste.py index 97aea23..1443345 100755 --- a/plugins/repaste.py +++ b/plugins/repaste.py @@ -51,21 +51,21 @@ autorepastes = {} #@hook.regex('(pastebin\.com)(/[^ ]+)') @hook.regex('(mibpaste\.com)(/[^ ]+)') -def autorepaste(inp, input=None, db=None, chan=None): +def autorepaste(inp, input=None, notice=None, db=None, chan=None, nick=None): db_init(db) - manual = input.db.execute("select manual from repaste where chan=?", (chan, )).fetchone() + manual = db.execute("select manual from repaste where chan=?", (chan, )).fetchone() if manual and len(manual) and manual[0]: return url = inp.group(1) + inp.group(2) urllib.unquote(url) if url in autorepastes: out = autorepastes[url] - input.notice("In the future, please use a less awful pastebin (e.g. pastebin.com)") + notice("In the future, please use a less awful pastebin (e.g. pastebin.com)") else: out = repaste("http://" + url, input, db, False) autorepastes[url] = out - input.notice("In the future, please use a less awful pastebin (e.g. pastebin.com) instead of %s." % inp.group(1)) - input.say("%s (repasted for %s)" % (out, input.nick)) + notice("In the future, please use a less awful pastebin (e.g. pastebin.com) instead of %s." % inp.group(1)) + input.say("%s (repasted for %s)" % (out, nick)) scrapers = { diff --git a/plugins/tell.py b/plugins/tell.py index 2d7fffd..22e0599 100755 --- a/plugins/tell.py +++ b/plugins/tell.py @@ -25,13 +25,13 @@ def get_tells(db, user_to): @hook.singlethread @hook.event('PRIVMSG') -def tellinput(paraml, input=None, notice=None, db=None, bot=None): +def tellinput(paraml, input=None, notice=None, db=None, bot=None, nick=None): if 'showtells' in input.msg.lower(): return db_init(db) - tells = get_tells(db, input.nick) + tells = get_tells(db, nick) if tells: user_from, message, time, chan = tells[0] @@ -43,7 +43,7 @@ def tellinput(paraml, input=None, notice=None, db=None, bot=None): reply += " (+%d more, .showtells to view)" % (len(tells) - 1) db.execute("delete from tell where user_to=lower(?) and message=?", - (input.nick, message)) + (nick, message)) db.commit() notice(reply) From 55676d86d9b75bddd68d7e56d96b2d3acfb7386d Mon Sep 17 00:00:00 2001 From: lukeroge Date: Sun, 1 Apr 2012 15:39:34 +1200 Subject: [PATCH 173/205] Fixed bug --- plugins/factoids.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/factoids.py b/plugins/factoids.py index 51388f9..c52a736 100755 --- a/plugins/factoids.py +++ b/plugins/factoids.py @@ -111,8 +111,11 @@ def forget(inp, db=None, input=None, notice=None): @hook.regex(r'^\? ?(.+)') def factoid(inp, say=None, db=None, bot=None): "? -- Shows what data is associated with ." - - prefix_on = bot.config["plugins"]["factoids"].get("prefix", False) + try: + prefix_on = bot.config["plugins"]["factoids"].get("prefix", False) + except KeyError: + prefix_on = False + db_init(db) From d03f6b63c6f6f02700c12b8dd2ff9c72e1655def Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Sun, 1 Apr 2012 22:58:14 +1200 Subject: [PATCH 174/205] A few tweaks to system.py --- plugins/system.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/system.py b/plugins/system.py index f67b16d..e575acd 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -1,4 +1,5 @@ # Plugin by Lukeroge, and neersighted +# Yeah, the code in this sucks. Meh. import os import re import time @@ -26,12 +27,15 @@ def checkProc(checked_stats): @hook.command(autohelp=False) def system(inp): ".system -- Retrieves information about the host system." - name = platform.node() + hostname = platform.node() os = platform.platform() - python_version = platform.python_implementation() + ' ' + platform.python_version() - arch = '-'.join(platform.architecture()) + python_imp = platform.python_implementation() + python_ver = platform.python_version() + architecture = '-'.join(platform.architecture()) cpu = platform.machine() - return 'Name: \x02%s\x02, Operating System: \x02%s\x02, Python Version: \x02%s\x02, Architecture: \x02%s\x02, CPU: \x02%s\x02' % (name, os, python_version, arch, cpu) + return 'Hostname: \x02%s\x02, Operating System: \x02%s\x02, Python Version:' \ + ' \x02%s %s\x02, Architecture: \x02%s\x02, CPU: \x02%s\x02' % (hostname, + os, python_imp, python_ver, architecture, cpu) @hook.command(autohelp=False) From 81958d63b712c63d75149a5dae2478fd5c5fe27e Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Sun, 1 Apr 2012 23:45:45 +1200 Subject: [PATCH 175/205] Totally rewrote part of system.py --- plugins/system.py | 72 ++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 44 deletions(-) diff --git a/plugins/system.py b/plugins/system.py index e575acd..a4477f1 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -1,28 +1,9 @@ -# Plugin by Lukeroge, and neersighted -# Yeah, the code in this sucks. Meh. import os import re -import time -import string import platform import subprocess from util import hook -def replace(text, wordDic): - rc = re.compile('|'.join(map(re.escape, wordDic))) - - def translate(match): - return wordDic[match.group(0)] - return rc.sub(translate, text) - -def checkProc(checked_stats): - status_file = open('/proc/self/status').read() - line_pairs = re.findall(r'^(\w+):\s*(.*)\s*$', status_file, re.M) - status = dict(line_pairs) - checked_stats = checked_stats.split() - stats = '\x02, '.join(key + ': \x02' + status[key] for key in checked_stats) - return stats - @hook.command(autohelp=False) def system(inp): @@ -33,49 +14,52 @@ def system(inp): python_ver = platform.python_version() architecture = '-'.join(platform.architecture()) cpu = platform.machine() - return 'Hostname: \x02%s\x02, Operating System: \x02%s\x02, Python Version:' \ - ' \x02%s %s\x02, Architecture: \x02%s\x02, CPU: \x02%s\x02' % (hostname, - os, python_imp, python_ver, architecture, cpu) + return "Hostname: \x02%s\x02, Operating System: \x02%s\x02, Python " \ + "Version: \x02%s %s\x02, Architecture: \x02%s\x02, CPU: \x02%s" \ + "\x02" % (hostname, os, python_imp, python_ver, architecture, cpu) @hook.command(autohelp=False) def memory(inp): ".memory -- Displays the bot's current memory usage." - if os.name == 'posix': - checked_stats = 'VmRSS VmSize VmPeak VmStk VmData' - memory = checkProc(checked_stats) - pretty_names = {'VmRSS': 'Real Memory', 'VmSize': 'Allocated Memory', 'VmPeak': 'Peak Allocated Memory', 'VmStk': 'Stack Size', 'VmData': 'Heap Size'} - memory = replace(memory, pretty_names) - memory = string.replace(memory, ' kB', '') - memory = memory.split('\x02') - numbers = [memory[i] for i in range(len(memory)) if i % 2 == 1] - memory = [i for i in memory if i not in numbers] - numbers = [str(round(float(i) / 1024, 2)) + ' MB' for i in numbers] - memory = [list(i) for i in zip(memory, numbers)] - memory = sum(memory, []) - memory = '\x02'.join(memory) + if os.name == "posix": + # get process info + status_file = open('/proc/self/status').read() + s = dict(re.findall(r'^(\w+):\s*(.*)\s*$', status_file, re.M)) + # get the data we need and process it + data = s['VmRSS'], s['VmSize'], s['VmPeak'], s['VmStk'], s['VmData'] + data = [int(i.replace(' kB', '')) for i in data] + strings = [str(round(float(i) / 1024, 2)) + ' MB' for i in data] + # prepare the output + out = "Real Memory: \x02%s\x02, Allocated Memory: \x02%s\x02, Peak " \ + "Allocated Memory: \x02%s\x02, Stack Size: \x02%s\x02, Heap " \ + "Size: \x02%s\x02" % (strings[0], strings[1], strings[2], + strings[3], strings[4]) + # return output + return out - elif os.name == 'nt': - cmd = 'tasklist /FI \"PID eq %s\" /FO CSV /NH' % os.getpid() + elif os.name == "nt": + cmd = 'tasklist /FI "PID eq %s" /FO CSV /NH' % os.getpid() out = os.popen(cmd).read() memory = 0 for amount in re.findall(r'([,0-9]+) K', out): memory += int(amount.replace(',', '')) memory = str(round(float(memory) / 1024, 2)) - memory = 'Memory Usage: \x02%s MB\x02' % memory + return "Memory Usage: \x02%s MB\x02" % memory + else: - memory = 'error: operating system not currently supported' - return memory + return "Operating system not currently supported." @hook.command(autohelp=False) def uptime(inp): ".uptime -- Shows the bot's uptime." - up_time = subprocess.check_output('ps -eo pid,etime | grep %s | awk \'{print $2}\'' % os.getpid(), shell=True) - up_time = 'Uptime: \x02' + up_time + '\x02' - return up_time + up = subprocess.check_output("ps -eo pid,etime | grep %s | awk " \ + "'{print $2}'" % os.getpid(), shell=True) + return "Uptime: \x02%s\x02" % up + @hook.command(autohelp=False) def pid(inp): ".pid -- Prints the bot's PID." - return 'PID: \x02%s\x02' % os.getpid() + return "PID: \x02%s\x02" % os.getpid() From 9b2726e386bce3b5e021027e51cdd7aab437f584 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Sun, 1 Apr 2012 23:51:19 +1200 Subject: [PATCH 176/205] Disabled old unmaintained plugin --- {plugins => disabled_plugins}/repaste.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {plugins => disabled_plugins}/repaste.py (100%) diff --git a/plugins/repaste.py b/disabled_plugins/repaste.py similarity index 100% rename from plugins/repaste.py rename to disabled_plugins/repaste.py From 75694df0db71e0d886b0e44b6ab924376c255b11 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Sun, 1 Apr 2012 23:56:44 +1200 Subject: [PATCH 177/205] Updated feelings.py to match violence.py --- plugins/feelings.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/feelings.py b/plugins/feelings.py index d2cb2d7..184d8e1 100755 --- a/plugins/feelings.py +++ b/plugins/feelings.py @@ -33,7 +33,8 @@ def insult(inp, nick=None, me=None, conn=None): target = nick else: target = inp - out = "insults " + target + "... \"" + random.choice(insults) + "\"" + + out = 'insults %s... "%s"' % (target, random.choice(insults)) me(out) @@ -50,5 +51,6 @@ def flirt(inp, nick=None, me=None, conn=None): target = 'itself' else: target = inp - out = "flirts with " + target + "... \"" + random.choice(flirts) + "\"" + + out = 'insults %s... "%s"' % (target, random.choice(flirts)) me(out) From 6d81048d3fd531470569bb7635b16acfa58f4025 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 2 Apr 2012 01:01:01 +1200 Subject: [PATCH 178/205] Fix --- plugins/system.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/system.py b/plugins/system.py index a4477f1..ddbfc6e 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -48,12 +48,14 @@ def memory(inp): return "Memory Usage: \x02%s MB\x02" % memory else: - return "Operating system not currently supported." + return "Sorry, this command is not supported on your OS." @hook.command(autohelp=False) def uptime(inp): ".uptime -- Shows the bot's uptime." + if os.name not "posix": + return "Sorry, this command is not supported on your OS." up = subprocess.check_output("ps -eo pid,etime | grep %s | awk " \ "'{print $2}'" % os.getpid(), shell=True) return "Uptime: \x02%s\x02" % up From c4df4c5b2bab7bf897c2605955f7bd6eb881d619 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 2 Apr 2012 01:06:11 +1200 Subject: [PATCH 179/205] durr --- plugins/system.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/system.py b/plugins/system.py index ddbfc6e..da64d90 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -54,7 +54,7 @@ def memory(inp): @hook.command(autohelp=False) def uptime(inp): ".uptime -- Shows the bot's uptime." - if os.name not "posix": + if os.name != "posix": return "Sorry, this command is not supported on your OS." up = subprocess.check_output("ps -eo pid,etime | grep %s | awk " \ "'{print $2}'" % os.getpid(), shell=True) From 0894908ad54ef928487415a6f40bddb924e902ca Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 2 Apr 2012 07:05:27 +1200 Subject: [PATCH 180/205] Switched to cross-platform uptime code --- bot.py | 1 + plugins/system.py | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bot.py b/bot.py index 2a6fb10..387a78d 100755 --- a/bot.py +++ b/bot.py @@ -16,6 +16,7 @@ class Bot(object): print 'Welcome to Cloudbot - Version DEV - http://git.io/cloudbotirc' bot = Bot() +bot.start_time = time.time() print 'Loading plugins...' diff --git a/plugins/system.py b/plugins/system.py index da64d90..352caeb 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -1,5 +1,6 @@ import os import re +import time import platform import subprocess from util import hook @@ -52,13 +53,11 @@ def memory(inp): @hook.command(autohelp=False) -def uptime(inp): +def uptime(inp, bot=None): ".uptime -- Shows the bot's uptime." - if os.name != "posix": - return "Sorry, this command is not supported on your OS." - up = subprocess.check_output("ps -eo pid,etime | grep %s | awk " \ - "'{print $2}'" % os.getpid(), shell=True) - return "Uptime: \x02%s\x02" % up + uptime_raw = time.time() - bot.start_time + uptime = time.strftime('%H:%M:%S', time.gmtime(uptime_raw)) + return "Uptime: \x02%s\x02" % uptime @hook.command(autohelp=False) From a84bc36096bc1f27ea7d33dfc974cefc90f5b882 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 2 Apr 2012 07:21:47 +1200 Subject: [PATCH 181/205] Removed useless import --- plugins/system.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/system.py b/plugins/system.py index 352caeb..d07b48b 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -2,7 +2,6 @@ import os import re import time import platform -import subprocess from util import hook From 365c7801fe1dfd3d2f5439ba444b3e66b5824c70 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 2 Apr 2012 07:51:02 +1200 Subject: [PATCH 182/205] Changed method of getting uptime --- plugins/system.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/system.py b/plugins/system.py index d07b48b..57983b6 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -1,8 +1,10 @@ import os import re import time +import datetime import platform from util import hook +from datetime import timedelta @hook.command(autohelp=False) @@ -54,8 +56,8 @@ def memory(inp): @hook.command(autohelp=False) def uptime(inp, bot=None): ".uptime -- Shows the bot's uptime." - uptime_raw = time.time() - bot.start_time - uptime = time.strftime('%H:%M:%S', time.gmtime(uptime_raw)) + uptime_raw = round(time.time() - bot.start_time) + uptime = timedelta(seconds=uptime_raw) return "Uptime: \x02%s\x02" % uptime From 1bbf10efdf165b2362458acee49c777dd220ac32 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 2 Apr 2012 07:51:44 +1200 Subject: [PATCH 183/205] durp --- plugins/system.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/system.py b/plugins/system.py index 57983b6..a01acd6 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -1,7 +1,6 @@ import os import re import time -import datetime import platform from util import hook from datetime import timedelta From d24f001da610391a6a5e3501bbe1612137c63576 Mon Sep 17 00:00:00 2001 From: lukeroge Date: Mon, 2 Apr 2012 09:29:42 +1200 Subject: [PATCH 184/205] moved float() --- plugins/system.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/system.py b/plugins/system.py index a01acd6..00389a5 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -29,8 +29,8 @@ def memory(inp): s = dict(re.findall(r'^(\w+):\s*(.*)\s*$', status_file, re.M)) # get the data we need and process it data = s['VmRSS'], s['VmSize'], s['VmPeak'], s['VmStk'], s['VmData'] - data = [int(i.replace(' kB', '')) for i in data] - strings = [str(round(float(i) / 1024, 2)) + ' MB' for i in data] + data = [float(i.replace(' kB', '')) for i in data] + strings = [str(round(i / 1024, 2)) + ' MB' for i in data] # prepare the output out = "Real Memory: \x02%s\x02, Allocated Memory: \x02%s\x02, Peak " \ "Allocated Memory: \x02%s\x02, Stack Size: \x02%s\x02, Heap " \ From ba65a90f6f9605d14118a7718be3db4ec05863a3 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sun, 1 Apr 2012 18:45:37 -0700 Subject: [PATCH 185/205] Added threads to .mem --- plugins/system.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/system.py b/plugins/system.py index 00389a5..afd9233 100755 --- a/plugins/system.py +++ b/plugins/system.py @@ -32,9 +32,9 @@ def memory(inp): data = [float(i.replace(' kB', '')) for i in data] strings = [str(round(i / 1024, 2)) + ' MB' for i in data] # prepare the output - out = "Real Memory: \x02%s\x02, Allocated Memory: \x02%s\x02, Peak " \ + out = "Threads: \x02%s\x02, Real Memory: \x02%s\x02, Allocated Memory: \x02%s\x02, Peak " \ "Allocated Memory: \x02%s\x02, Stack Size: \x02%s\x02, Heap " \ - "Size: \x02%s\x02" % (strings[0], strings[1], strings[2], + "Size: \x02%s\x02" % (s['Threads'], strings[0], strings[1], strings[2], strings[3], strings[4]) # return output return out From 03daf6a0062c8d1759c4c9f56c06c6438783b499 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sun, 1 Apr 2012 19:01:20 -0700 Subject: [PATCH 186/205] Added message to adminonly commands --- plugins/sieve.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/sieve.py b/plugins/sieve.py index 500d0bf..cdbeb9c 100755 --- a/plugins/sieve.py +++ b/plugins/sieve.py @@ -33,6 +33,7 @@ def sieve_suite(bot, input, func, kind, args): admins = bot.config.get('admins', []) if input.mask not in admins and input.nick not in admins: + input.notice("Sorry, you are not allowed to use this command.") return None return input \ No newline at end of file From 126ef8d319ec8379904fc3ee6c64bff106688127 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sun, 1 Apr 2012 20:53:16 -0700 Subject: [PATCH 187/205] split admin/op commands --- plugins/admin.py | 41 ----------------------------------------- plugins/op.py | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 41 deletions(-) create mode 100644 plugins/op.py diff --git a/plugins/admin.py b/plugins/admin.py index 732a62a..4f0b3a9 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -86,36 +86,6 @@ def raw(inp, conn=None, notice=None): conn.send(inp) -@hook.command(adminonly=True) -def kick(inp, chan=None, conn=None, notice=None): - ".kick [channel] [reason] -- Makes the bot kick in [channel] "\ - "If [channel] is blank the bot will kick the in "\ - "the channel the command was used in." - split = inp.split(" ") - if split[0][0] == "#": - chan = split[0] - user = split[1] - out = "KICK %s %s" % (chan, user) - if len(split) > 2: - reason = "" - for x in split[2:]: - reason = reason + x + " " - reason = reason[:-1] - out = out + " :" + reason - else: - user = split[0] - out = "KICK %s %s" % (chan, split[0]) - if len(split) > 1: - reason = "" - for x in split[1:]: - reason = reason + x + " " - reason = reason[:-1] - out = out + " :" + reason - - notice("Attempting to kick %s from %s..." % (user, chan)) - conn.send(out) - - @hook.command(adminonly=True) def say(inp, conn=None, chan=None, notice=None): ".say [channel] -- Makes the bot say in [channel]. "\ @@ -157,14 +127,3 @@ def me(inp, conn=None, chan=None, notice=None): message = message[:-1] out = "PRIVMSG %s :\x01ACTION %s\x01" % (chan, message) conn.send(out) - - -@hook.command(adminonly=True) -def topic(inp, conn=None, chan=None, notice=None): - ".topic [channel] -- Change the topic of a channel." - split = inp.split(" ") - if split[0][0] == "#": - out = "PRIVMSG %s :%s" % (split[0], message) - else: - out = "TOPIC %s :%s" % (chan, message) - conn.send(out) diff --git a/plugins/op.py b/plugins/op.py new file mode 100644 index 0000000..e7a7e67 --- /dev/null +++ b/plugins/op.py @@ -0,0 +1,41 @@ +# Plugin made by iloveportalz0r, TheNoodle, Lukeroge and neersighted +from util import hook + +@hook.command(adminonly=True) +def kick(inp, chan=None, conn=None, notice=None): + ".kick [channel] [reason] -- Makes the bot kick in [channel] "\ + "If [channel] is blank the bot will kick the in "\ + "the channel the command was used in." + split = inp.split(" ") + if split[0][0] == "#": + chan = split[0] + user = split[1] + out = "KICK %s %s" % (chan, user) + if len(split) > 2: + reason = "" + for x in split[2:]: + reason = reason + x + " " + reason = reason[:-1] + out = out + " :" + reason + else: + user = split[0] + out = "KICK %s %s" % (chan, split[0]) + if len(split) > 1: + reason = "" + for x in split[1:]: + reason = reason + x + " " + reason = reason[:-1] + out = out + " :" + reason + + notice("Attempting to kick %s from %s..." % (user, chan)) + conn.send(out) + +@hook.command(adminonly=True) +def topic(inp, conn=None, chan=None, notice=None): + ".topic [channel] -- Change the topic of a channel." + split = inp.split(" ") + if split[0][0] == "#": + out = "PRIVMSG %s :%s" % (split[0], message) + else: + out = "TOPIC %s :%s" % (chan, message) + conn.send(out) From 70c41b3038f3aae97665d67ff6ccfa899428e363 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sun, 1 Apr 2012 20:54:49 -0700 Subject: [PATCH 188/205] Made .ignored use notice(), you can now ignore via hostmask (*!*@*) --- plugins/ignore.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/ignore.py b/plugins/ignore.py index 795d515..194fe0a 100755 --- a/plugins/ignore.py +++ b/plugins/ignore.py @@ -30,7 +30,7 @@ def ignoresieve(bot, input, func, type, args): # don't block input to event hooks if type == "event": return input - if is_ignored(input.chan) or is_ignored(input.nick) or is_ignored(input.host): + if is_ignored(input.chan) or is_ignored(input.nick) or is_ignored(input.host) or is_ignored(input.mask): if input.command == "PRIVMSG" and input.lastparam[1:] == "unignore": return input else: @@ -39,12 +39,13 @@ def ignoresieve(bot, input, func, type, args): @hook.command(autohelp=False) -def ignored(inp, bot=None): +def ignored(inp, notice=None, bot=None): ".ignored -- Lists ignored channels/users/hosts." if ignorelist: - return "Ignored channels/users/hosts are: %s" % ", ".join(ignorelist) + notice("Ignored channels/users/hosts are: %s" % ", ".join(ignorelist)) else: - return "No channels/users/hosts are currently ignored." + notice("No channels/users/hosts are currently ignored.") + return @hook.command(adminonly=True) From adc9a3c608ee742734086cf7251614e99441243d Mon Sep 17 00:00:00 2001 From: neersighted Date: Sun, 1 Apr 2012 20:57:00 -0700 Subject: [PATCH 189/205] Minor changes to return() layout --- plugins/ignore.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/ignore.py b/plugins/ignore.py index 194fe0a..c2476d7 100755 --- a/plugins/ignore.py +++ b/plugins/ignore.py @@ -58,7 +58,7 @@ def ignore(inp, input=None, notice=None): else: ignore_target(target) notice("%s has been ignored." % target) - + return @hook.command(adminonly=True) def unignore(inp, input=None, notice=None): @@ -68,8 +68,7 @@ def unignore(inp, input=None, notice=None): if is_ignored(target): unignore_target(target) notice("%s has been unignored." % target) - return else: notice("%s is not ignored." % target) - return + return From 5af42f128af1ab95f1bb15d6e88ccfcfa81602d2 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sun, 1 Apr 2012 21:30:04 -0700 Subject: [PATCH 190/205] added the main op commands --- plugins/admin.py | 20 +++++----- plugins/op.py | 95 +++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 91 insertions(+), 24 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index 4f0b3a9..0568abd 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -91,16 +91,16 @@ def say(inp, conn=None, chan=None, notice=None): ".say [channel] -- Makes the bot say in [channel]. "\ "If [channel] is blank the bot will say the in "\ "the channel the command was used in." - split = inp.split(" ") - if split[0][0] == "#": + inp = inp.split(" ") + if inp[0][0] == "#": message = "" - for x in split[1:]: + for x in inp[1:]: message = message + x + " " message = message[:-1] - out = "PRIVMSG %s :%s" % (split[0], message) + out = "PRIVMSG %s :%s" % (inp[0], message) else: message = "" - for x in split[0:]: + for x in inp[0:]: message = message + x + " " message = message[:-1] out = "PRIVMSG %s :%s" % (chan, message) @@ -113,16 +113,16 @@ def me(inp, conn=None, chan=None, notice=None): ".me [channel] -- Makes the bot act out in [channel] "\ "If [channel] is blank the bot will act the in "\ "the channel the command was used in." - split = inp.split(" ") - if split[0][0] == "#": + inp = inp.split(" ") + if inp[0][0] == "#": message = "" - for x in split[1:]: + for x in inp[1:]: message = message + x + " " message = message[:-1] - out = "PRIVMSG %s :\x01ACTION %s\x01" % (split[0], message) + out = "PRIVMSG %s :\x01ACTION %s\x01" % (inp[0], message) else: message = "" - for x in split[0:]: + for x in inp[0:]: message = message + x + " " message = message[:-1] out = "PRIVMSG %s :\x01ACTION %s\x01" % (chan, message) diff --git a/plugins/op.py b/plugins/op.py index e7a7e67..c11be31 100644 --- a/plugins/op.py +++ b/plugins/op.py @@ -1,28 +1,29 @@ -# Plugin made by iloveportalz0r, TheNoodle, Lukeroge and neersighted +# Plugin made by Lukeroge and neersighted from util import hook + @hook.command(adminonly=True) def kick(inp, chan=None, conn=None, notice=None): ".kick [channel] [reason] -- Makes the bot kick in [channel] "\ "If [channel] is blank the bot will kick the in "\ "the channel the command was used in." - split = inp.split(" ") - if split[0][0] == "#": - chan = split[0] - user = split[1] + inp = inp.split(" ") + if inp[0][0] == "#": + chan = inp[0] + user = inp[1] out = "KICK %s %s" % (chan, user) - if len(split) > 2: + if len(inp) > 2: reason = "" - for x in split[2:]: + for x in inp[2:]: reason = reason + x + " " reason = reason[:-1] out = out + " :" + reason else: - user = split[0] - out = "KICK %s %s" % (chan, split[0]) - if len(split) > 1: + user = inp[0] + out = "KICK %s %s" % (chan, user) + if len(inp) > 1: reason = "" - for x in split[1:]: + for x in inp[1:]: reason = reason + x + " " reason = reason[:-1] out = out + " :" + reason @@ -30,12 +31,78 @@ def kick(inp, chan=None, conn=None, notice=None): notice("Attempting to kick %s from %s..." % (user, chan)) conn.send(out) + +@hook.command(adminonly=True) +def ban(inp, conn=None, chan=None, notice=None): + ".ban [channel] -- Makes the bot ban in [channel]. "\ + "If [channel] is blank the bot will ban in "\ + "the channel the command was used in." + inp = inp.split(" ") + if inp[0][0] == "#": + chan = inp[0] + user = inp[1] + out = "MODE %s +b %s" % (chan, user) + else: + user = inp[0] + out = "MODE %s +b %s" % (chan, user) + notice("Attempting to ban %s from %s..." % (user, chan)) + conn.send(out) + + +@hook.command(adminonly=True) +def unban(inp, conn=None, chan=None, notice=None): + ".unban [channel] -- Makes the bot unban in [channel]. "\ + "If [channel] is blank the bot will unban in "\ + "the channel the command was used in." + inp = inp.split(" ") + if inp[0][0] == "#": + chan = inp[0] + user = inp[1] + out = "MODE %s -b %s" % (chan, user) + else: + user = inp[0] + out = "MODE %s -b %s" % (chan, user) + notice("Attempting to unban %s from %s..." % (user, chan)) + conn.send(out) + +@hook.command(adminonly=True) +def kickban(inp, chan=None, conn=None, notice=None): + ".kickban [channel] [reason] -- Makes the bot kickban in [channel] "\ + "If [channel] is blank the bot will kickban the in "\ + "the channel the command was used in." + inp = inp.split(" ") + if inp[0][0] == "#": + chan = inp[0] + user = inp[1] + out1 = "MODE %s +b %s" % (chan, user) + out2 = "KICK %s %s" % (chan, user) + if len(inp) > 2: + reason = "" + for x in inp[2:]: + reason = reason + x + " " + reason = reason[:-1] + out = out + " :" + reason + else: + user = inp[0] + out1 = "MODE %s +b %s" % (chan, user) + out2 = "KICK %s %s" % (chan, user) + if len(inp) > 1: + reason = "" + for x in inp[1:]: + reason = reason + x + " " + reason = reason[:-1] + out = out + " :" + reason + + notice("Attempting to kickban %s from %s..." % (user, chan)) + conn.send(out1) + conn.send(out2) + @hook.command(adminonly=True) def topic(inp, conn=None, chan=None, notice=None): ".topic [channel] -- Change the topic of a channel." - split = inp.split(" ") - if split[0][0] == "#": - out = "PRIVMSG %s :%s" % (split[0], message) + inp = inp.split(" ") + if inp[0][0] == "#": + out = "PRIVMSG %s :%s" % (inp[0], message) else: out = "TOPIC %s :%s" % (chan, message) conn.send(out) From 681745d35753c3129127a94edb1938a952170599 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sun, 1 Apr 2012 22:37:32 -0700 Subject: [PATCH 191/205] Added json/persist to ignore.py, added in-chat admin adding --- plugins/admin.py | 50 ++++++++++++++++++++++++++++++------ plugins/ignore.py | 65 +++++++++++++++++------------------------------ 2 files changed, 66 insertions(+), 49 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index 0568abd..2190101 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -1,25 +1,59 @@ # Plugin made by iloveportalz0r, TheNoodle, Lukeroge and neersighted from util import hook import os -import sys -import subprocess -import time import re +import sys +import json +import time +import subprocess @hook.command(autohelp=False) -def admins(inp, bot=None): - ".admins -- Lists the bot's admins." - admins = bot.config["admins"] - return ", ".join(admins) +def admins(inp, notice=None, bot=None): + ".admins -- Lists bot's admins." + adminlist = bot.config["admins"] + if adminlist: + notice("Admins are: %s." % ", ".join(adminlist)) + else: + notice("No users are admins!") + return +@hook.command(adminonly=True) +def admin(inp, notice=None, bot=None, config=None): + ".admin -- Make an admin." + target = inp.lower() + adminlist = bot.config["admins"] + if target in adminlist: + notice("%s is already an admin." % target) + else: + notice("%s is now an admin." % target) + adminlist.append(target) + adminlist.sort() + json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2) + return + +@hook.command(adminonly=True) +def unadmin(inp, notice=None, bot=None, config=None): + ".unadmin -- Make a non-admin." + target = inp.lower() + adminlist = bot.config["admins"] + if target in adminlist: + notice("%s is no longer an admin." % target) + adminlist.remove(target) + adminlist.sort() + json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2) + else: + notice("%s is not an admin." % target) + return + @hook.command(autohelp=False) def channels(inp, conn=None): ".channels -- Lists the channels that the bot is in." return "I am in these channels: %s" % ", ".join(conn.channels) +@hook.command("quit", autohelp=False, adminonly=True) @hook.command(autohelp=False, adminonly=True) def stop(inp, nick=None, conn=None): ".stop [reason] -- Kills the bot with [reason] as its quit message." @@ -28,7 +62,7 @@ def stop(inp, nick=None, conn=None): else: conn.cmd("QUIT", ["Killed by %s." % nick]) time.sleep(5) - os.execl(["./cloudbot", "stop"]) + os.execl("./cloudbot", "stop") @hook.command(autohelp=False, adminonly=True) def restart(inp, nick=None, conn=None): diff --git a/plugins/ignore.py b/plugins/ignore.py index c2476d7..b6b2110 100755 --- a/plugins/ignore.py +++ b/plugins/ignore.py @@ -1,36 +1,14 @@ +import json from util import hook -ignorelist = [] - - -def ignore_target(target): - """ ignores someone """ - target = target.lower() - ignorelist.append(target) - - -def unignore_target(target): - """ unignores someone """ - target = target.lower() - ignorelist.remove(target) - - -def is_ignored(target): - """ checks of someone is ignored """ - target = target.lower() - if target in ignorelist: - return True - else: - return False - - @hook.sieve def ignoresieve(bot, input, func, type, args): - """ blocks input from ignored channels/users """ + """ blocks input from ignored channels/nicks """ + ignorelist = bot.config["plugins"]["ignore"]["ignored"] # don't block input to event hooks if type == "event": return input - if is_ignored(input.chan) or is_ignored(input.nick) or is_ignored(input.host) or is_ignored(input.mask): + if input.chan in ignorelist or input.nick in ignorelist or input.host in ignorelist or input.mask in ignorelist: if input.command == "PRIVMSG" and input.lastparam[1:] == "unignore": return input else: @@ -40,34 +18,39 @@ def ignoresieve(bot, input, func, type, args): @hook.command(autohelp=False) def ignored(inp, notice=None, bot=None): - ".ignored -- Lists ignored channels/users/hosts." + ".ignored -- Lists ignored channels/nicks/hosts." + ignorelist = bot.config["plugins"]["ignore"]["ignored"] if ignorelist: - notice("Ignored channels/users/hosts are: %s" % ", ".join(ignorelist)) + notice("Ignored channels/nicks/hosts are: %s" % ", ".join(ignorelist)) else: - notice("No channels/users/hosts are currently ignored.") + notice("No channels/nicks/hosts are currently ignored.") return @hook.command(adminonly=True) -def ignore(inp, input=None, notice=None): - ".ignore -- Makes the bot ignore ." - target = inp - - if is_ignored(target): +def ignore(inp, notice=None, bot=None, config=None): + ".ignore -- Makes the bot ignore ." + target = inp.lower() + ignorelist = bot.config["plugins"]["ignore"]["ignored"] + if target in ignorelist: notice("%s is already ignored." % target) else: - ignore_target(target) notice("%s has been ignored." % target) + ignorelist.append(target) + ignorelist.sort() + json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2) return @hook.command(adminonly=True) -def unignore(inp, input=None, notice=None): - ".unignore -- Makes the bot listen to ." - target = inp - - if is_ignored(target): - unignore_target(target) +def unignore(inp, notice=None, bot=None, config=None): + ".unignore -- Makes the bot listen to ." + target = inp.lower() + ignorelist = bot.config["plugins"]["ignore"]["ignored"] + if target in ignorelist: notice("%s has been unignored." % target) + ignorelist.remove(target) + ignorelist.sort() + json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2) else: notice("%s is not ignored." % target) return From f77d8c18678ce741375a3befbacc07e22e42c5d1 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sun, 1 Apr 2012 22:43:43 -0700 Subject: [PATCH 192/205] --FEATURE FREEZE-- Python 3 conversion is now underway --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 14d316d..204bd8a 100755 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +# Pending, conversion to Python 3 # CloudBot/DEV ## About From f83f57be60abb2bbbb7874adab15e04ab6ec6453 Mon Sep 17 00:00:00 2001 From: neersighted Date: Sun, 1 Apr 2012 22:50:47 -0700 Subject: [PATCH 193/205] --EMERGENCY FREEZE BREAK-- Fixed critical bug --- core/config.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/config.py b/core/config.py index 3354404..8eea815 100755 --- a/core/config.py +++ b/core/config.py @@ -46,6 +46,10 @@ if not os.path.exists('config'): "factoids": { "prefix": false + }, + "ignore": + { + "ignored": [] } }, "censored_strings": From ba7304a071e66ae908d40ae7cc8fee9c7f078d78 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 2 Apr 2012 08:20:17 -0700 Subject: [PATCH 194/205] Added more triggers to .gis --- plugins/google.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/google.py b/plugins/google.py index c4593b2..bf2a81c 100755 --- a/plugins/google.py +++ b/plugins/google.py @@ -9,8 +9,10 @@ def api_get(kind, query): return http.get_json(url % kind, q=query) +@hook.command('image') +@hook.command('gis') @hook.command -def gis(inp): +def googleimage(inp): ".gis -- Returns first Google Image result (Safesearch off)." parsed = api_get('images', inp) From ff11ba760f22d5309fb2c4d7af71e4d6ce1ceac6 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 2 Apr 2012 08:22:13 -0700 Subject: [PATCH 195/205] Tweaked messages --- bot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index 387a78d..e754380 100755 --- a/bot.py +++ b/bot.py @@ -29,7 +29,7 @@ config() if not hasattr(bot, 'config'): exit() -print 'Connecting to IRC' +print 'Connecting to IRC...' bot.conns = {} @@ -50,7 +50,7 @@ bot.persist_dir = os.path.abspath('persist') if not os.path.exists(bot.persist_dir): os.mkdir(bot.persist_dir) -print 'Running main loop' +print 'Connection(s) made, bot online...' while True: reload() # these functions only do things From 641b770dc36cf677c5f95d7ae7e907cce10a3cc6 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 2 Apr 2012 08:22:38 -0700 Subject: [PATCH 196/205] Removed Py3 message, putting that one the backburner --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 204bd8a..14d316d 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -# Pending, conversion to Python 3 # CloudBot/DEV ## About From 508fec8ae81c1f8d9376b18ca0f3377177db55b8 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 2 Apr 2012 09:17:55 -0700 Subject: [PATCH 197/205] PEP8, lots of tweaks/fixes --- plugins/admin.py | 3 +++ plugins/dice.py | 9 +++---- plugins/dictionary.py | 13 ++++----- plugins/drama.py | 3 ++- plugins/fact.py | 8 ++++-- plugins/factoids.py | 3 +-- plugins/feelings.py | 4 +-- plugins/flip.py | 1 + plugins/fmylife.py | 3 +-- plugins/geoip.py | 8 +++--- plugins/gitio.py | 2 +- plugins/google.py | 10 ++++--- plugins/hash.py | 5 ++++ plugins/help.py | 14 +++++----- plugins/ignore.py | 11 +++++--- plugins/lastfm.py | 5 ++-- plugins/log.py | 17 ++++++++---- plugins/mctools.py | 33 +++++++++++++++-------- plugins/namegen.py | 6 ++--- plugins/op.py | 22 +++++++++------- plugins/potato.py | 1 + plugins/quote.py | 58 ++++++++++++++++++++++++----------------- plugins/shorten.py | 1 - plugins/sieve.py | 4 +-- plugins/time.py | 1 - plugins/translate.py | 2 +- plugins/twitter.py | 15 ++++++----- plugins/violence.py | 10 +++---- plugins/wordoftheday.py | 4 +-- 29 files changed, 165 insertions(+), 111 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index 2190101..65673e2 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -33,6 +33,7 @@ def admin(inp, notice=None, bot=None, config=None): json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2) return + @hook.command(adminonly=True) def unadmin(inp, notice=None, bot=None, config=None): ".unadmin -- Make a non-admin." @@ -47,6 +48,7 @@ def unadmin(inp, notice=None, bot=None, config=None): notice("%s is not an admin." % target) return + @hook.command(autohelp=False) def channels(inp, conn=None): ".channels -- Lists the channels that the bot is in." @@ -64,6 +66,7 @@ def stop(inp, nick=None, conn=None): time.sleep(5) os.execl("./cloudbot", "stop") + @hook.command(autohelp=False, adminonly=True) def restart(inp, nick=None, conn=None): ".restart [reason] -- Restarts the bot with [reason] as its quit message." diff --git a/plugins/dice.py b/plugins/dice.py index dd2ee2f..2e688bd 100755 --- a/plugins/dice.py +++ b/plugins/dice.py @@ -1,7 +1,5 @@ -""" -dice.py: written by Scaevolus 2008, updated 2009 -simulates dicerolls -""" +# Written by Scaevolus, updated by Lukeroge + import re import random @@ -30,7 +28,8 @@ def nrolls(count, n): return [random.randint(1, n) for x in xrange(count)] else: # fake it return [int(random.normalvariate(.5 * (1 + n) * count, - (((n+1)*(2*n+1)/6.-(.5*(1+n))**2)*count)**.5))] + (((n + 1) * (2 * n + 1) / 6. - + (.5 * (1 + n)) ** 2) * count) ** .5))] @hook.command('roll') diff --git a/plugins/dictionary.py b/plugins/dictionary.py index 5efbf9c..934a8b8 100755 --- a/plugins/dictionary.py +++ b/plugins/dictionary.py @@ -1,13 +1,14 @@ +# Plugin by GhettoWizard and Scaevolus import re - -from util import hook, http +from util import hook +from util import http @hook.command('u') @hook.command def urban(inp): ".urban [id] -- Looks up on urbandictionary.com." - + # set a default definition number id = 1 @@ -27,11 +28,12 @@ def urban(inp): if page['result_type'] == 'no_results': return 'Not found.' - + # try getting the requested definition try: out = "[%s/%s] %s: %s" % \ - (str(id), str(len(defs)), defs[id-1]['word'], defs[id-1]['definition']) + (str(id), str(len(defs)), defs[id - 1]['word'], + defs[id - 1]['definition']) except IndexError: return 'Not found.' @@ -41,7 +43,6 @@ def urban(inp): return out -# define plugin by GhettoWizard & Scaevolus @hook.command('dictionary') @hook.command def define(inp): diff --git a/plugins/drama.py b/plugins/drama.py index 67008bf..db586bc 100755 --- a/plugins/drama.py +++ b/plugins/drama.py @@ -7,7 +7,8 @@ ed_url = "http://encyclopediadramatica.ch/" @hook.command('ed') @hook.command def drama(inp): - ".drama -- Gets the first paragraph of Encyclopedia Dramatica article on ." + ".drama -- Gets the first paragraph of"\ + "the Encyclopedia Dramatica article on ." j = http.get_json(api_url, search=inp) if not j[1]: diff --git a/plugins/fact.py b/plugins/fact.py index 3a4ee55..82bec4e 100755 --- a/plugins/fact.py +++ b/plugins/fact.py @@ -1,7 +1,10 @@ import re -from util import hook, http, misc +from util import hook +from util import http +from util import misc from BeautifulSoup import BeautifulSoup + @hook.command(autohelp=False) def fact(inp, say=False, nick=False): ".fact -- Gets a random fact from OMGFACTS." @@ -15,10 +18,11 @@ def fact(inp, say=False, nick=False): return u"%s [ %s ]" % (fact, link) + def get_fact(): page = http.get('http://www.omg-facts.com/random') soup = BeautifulSoup(page) - container = soup.find('a', {'class' : 'surprise'}) + container = soup.find('a', {'class': 'surprise'}) link = container['href'] fact = misc.strip_html(container.renderContents()) diff --git a/plugins/factoids.py b/plugins/factoids.py index c52a736..706cc06 100755 --- a/plugins/factoids.py +++ b/plugins/factoids.py @@ -112,11 +112,10 @@ def forget(inp, db=None, input=None, notice=None): def factoid(inp, say=None, db=None, bot=None): "? -- Shows what data is associated with ." try: - prefix_on = bot.config["plugins"]["factoids"].get("prefix", False) + prefix_on = bot.config["plugins"]["factoids"].get("prefix", False) except KeyError: prefix_on = False - db_init(db) data = get_memory(db, inp.group(1).strip()) diff --git a/plugins/feelings.py b/plugins/feelings.py index 184d8e1..3141ceb 100755 --- a/plugins/feelings.py +++ b/plugins/feelings.py @@ -33,7 +33,7 @@ def insult(inp, nick=None, me=None, conn=None): target = nick else: target = inp - + out = 'insults %s... "%s"' % (target, random.choice(insults)) me(out) @@ -51,6 +51,6 @@ def flirt(inp, nick=None, me=None, conn=None): target = 'itself' else: target = inp - + out = 'insults %s... "%s"' % (target, random.choice(flirts)) me(out) diff --git a/plugins/flip.py b/plugins/flip.py index d613e48..14ad83e 100755 --- a/plugins/flip.py +++ b/plugins/flip.py @@ -1,6 +1,7 @@ from util import hook import random + @hook.command def flip(inp, flip_count=0, say=None): ".flip -- Flips over." diff --git a/plugins/fmylife.py b/plugins/fmylife.py index 27ca639..7c67b15 100755 --- a/plugins/fmylife.py +++ b/plugins/fmylife.py @@ -1,5 +1,4 @@ # Plugin by Lukeroge -# from util import hook, http from urlparse import urljoin @@ -12,7 +11,7 @@ fml_cache = defaultdict() def refresh_cache(): - """ gets a page of random fmls and puts them into a dictionary """ + """Gets a page of random FMLs and puts them into a dictionary""" page = http.get(urljoin(base_url, 'random')) soup = BeautifulSoup(page) diff --git a/plugins/geoip.py b/plugins/geoip.py index b8d540c..7912b1a 100755 --- a/plugins/geoip.py +++ b/plugins/geoip.py @@ -36,8 +36,10 @@ def geoip(inp, say=None, bot=None): localstring = give["city"] else: localstring = give["city"] + ", " + give["state"] - say("That IP comes from " + give["country"] + " (" + give["country_short"] + ")") - say("I think it's in " + localstring + " with a timezone of " + give["timezone"] + "GMT") + say("That IP comes from " + give["country"] + + " (" + give["country_short"] + ")") + say("I think it's in " + localstring + + " with a timezone of " + give["timezone"] + "GMT") else: - say("Either that wasn't an IP or I cannot locate it in my database. :(") + say("Either that wasn't an IP or I cannot locate it in my database.") return diff --git a/plugins/gitio.py b/plugins/gitio.py index 6c5c8fa..99d4e41 100755 --- a/plugins/gitio.py +++ b/plugins/gitio.py @@ -1,4 +1,4 @@ -# plugin created by neersighted and lukeroge +# Plugin by neersighted and Lukeroge from util import hook import urllib2 diff --git a/plugins/google.py b/plugins/google.py index bf2a81c..282649a 100755 --- a/plugins/google.py +++ b/plugins/google.py @@ -1,9 +1,10 @@ import random - -from util import hook, http +from util import hook +from util import http def api_get(kind, query): + """Use the RESTful Google Search API""" url = 'http://ajax.googleapis.com/ajax/services/search/%s?' \ 'v=1.0&safe=off' return http.get_json(url % kind, q=query) @@ -21,8 +22,9 @@ def googleimage(inp): parsed['responseStatus'], '')) if not parsed['responseData']['results']: return 'no images found' - return random.choice(parsed['responseData']['results'][:10]) \ - ['unescapedUrl'] # squares is dumb + return random.choice(parsed['responseData']['results'][:10])\ + + ['unescapedUrl'] + @hook.command('search') @hook.command('g') diff --git a/plugins/hash.py b/plugins/hash.py index 48d291f..d00731c 100755 --- a/plugins/hash.py +++ b/plugins/hash.py @@ -1,26 +1,31 @@ import hashlib from util import hook + @hook.command def md5(inp): ".hash -- Returns a md5 hash of ." return hashlib.md5(inp).hexdigest() + @hook.command def sha1(inp): ".hash -- Returns a sha1 hash of ." return hashlib.sha1(inp).hexdigest() + @hook.command def sha256(inp): ".hash -- Returns a sha256 hash of ." return hashlib.sha256(inp).hexdigest() + @hook.command def sha512(inp): ".hash -- Returns a sha512 hash of ." return hashlib.sha512(inp).hexdigest() + @hook.command def hash(inp): ".hash -- Returns hashes of ." diff --git a/plugins/help.py b/plugins/help.py index 70ac3be..ceb67c3 100755 --- a/plugins/help.py +++ b/plugins/help.py @@ -1,7 +1,7 @@ import re - from util import hook + @hook.command(autohelp=False) def help(inp, input=None, bot=None, say=None, notice=None): ".help -- Gives a list of commands/help for a command." @@ -12,7 +12,9 @@ def help(inp, input=None, bot=None, say=None, notice=None): for command, (func, args) in bot.commands.iteritems(): fn = re.match(r'^plugins.(.+).py$', func._filename) if fn.group(1).lower() not in disabled: - if not args.get('adminonly', False) or input.mask in input.bot.config["admins"]: + if not args.get('adminonly', False) or\ + input.nick in bot.config["admins"] or\ + input.mask in bot.config["admins"]: if command not in disabled_comm: if func.__doc__ is not None: if func in funcs: @@ -35,13 +37,13 @@ def help(inp, input=None, bot=None, say=None, notice=None): out[1] += " " + str(x) else: out[0] += " " + str(x) - + notice("Commands I recognise: " + out[0][1:]) if out[1]: notice(out[1][1:]) - notice("For detailed help, do '.help ' where is the " + - "name of the command you want help for.") - + notice("For detailed help, do '.help ' where "\ + "is the name of the command you want help for.") + else: if inp in commands: notice(commands[inp].__doc__) diff --git a/plugins/ignore.py b/plugins/ignore.py index b6b2110..662531f 100755 --- a/plugins/ignore.py +++ b/plugins/ignore.py @@ -1,6 +1,7 @@ import json from util import hook + @hook.sieve def ignoresieve(bot, input, func, type, args): """ blocks input from ignored channels/nicks """ @@ -8,7 +9,10 @@ def ignoresieve(bot, input, func, type, args): # don't block input to event hooks if type == "event": return input - if input.chan in ignorelist or input.nick in ignorelist or input.host in ignorelist or input.mask in ignorelist: + if input.chan in ignorelist or\ + input.nick in ignorelist or\ + input.host in ignorelist or\ + input.mask in ignorelist: if input.command == "PRIVMSG" and input.lastparam[1:] == "unignore": return input else: @@ -41,9 +45,11 @@ def ignore(inp, notice=None, bot=None, config=None): json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2) return + @hook.command(adminonly=True) def unignore(inp, notice=None, bot=None, config=None): - ".unignore -- Makes the bot listen to ." + ".unignore -- Makes the bot listen to"\ + " ." target = inp.lower() ignorelist = bot.config["plugins"]["ignore"]["ignored"] if target in ignorelist: @@ -54,4 +60,3 @@ def unignore(inp, notice=None, bot=None, config=None): else: notice("%s is not ignored." % target) return - diff --git a/plugins/lastfm.py b/plugins/lastfm.py index a1616aa..d910ea7 100755 --- a/plugins/lastfm.py +++ b/plugins/lastfm.py @@ -1,11 +1,12 @@ # Upgraded with tables/caching by ChauffeR of #freebnc on irc.esper.net from util import hook, http + @hook.command('l', autohelp=False) -@hook.command('lfm', autohelp=False) @hook.command(autohelp=False) def lastfm(inp, nick='', say=None, db=None, bot=None): - ".lastfm [user] -- Displays the now playing (or last played) track of LastFM user [user]." + ".lastfm [user] -- Displays the now playing (or last played) "\ + "track of LastFM user [user]." if inp: user = inp else: diff --git a/plugins/log.py b/plugins/log.py index f05129e..4b761a9 100755 --- a/plugins/log.py +++ b/plugins/log.py @@ -10,11 +10,12 @@ import re from util import hook -log_fds = {} # '%(net)s %(chan)s' : (filename, fd) +log_fds = {} # '%(net)s %(chan)s': (filename, fd) timestamp_format = '%H:%M:%S' -formats = {'PRIVMSG': '<%(nick)s> %(msg)s', +formats = { + 'PRIVMSG': '<%(nick)s> %(msg)s', 'PART': '-!- %(nick)s [%(user)s@%(host)s] has left %(chan)s', 'JOIN': '-!- %(nick)s [%(user)s@%(host)s] has joined %(param0)s', 'MODE': '-!- mode/%(chan)s [%(param_tail)s] by %(nick)s', @@ -22,16 +23,22 @@ formats = {'PRIVMSG': '<%(nick)s> %(msg)s', 'TOPIC': '-!- %(nick)s changed the topic of %(chan)s to: %(msg)s', 'QUIT': '-!- %(nick)s has quit [%(msg)s]', 'PING': '', - 'NOTICE': '' + 'NOTICE': '-%(nick)s- %(msg)s' } -ctcp_formats = {'ACTION': '* %(nick)s %(ctcpmsg)s'} +ctcp_formats = { +'ACTION': '* %(nick)s %(ctcpmsg)s' +'VERSION': '%(nick)s has requested CTCP %(ctcpcmd)s from %(chan)s: %(ctcpmsg)s' +'PING': '%(nick)s has requested CTCP %(ctcpcmd)s from %(chan)s: %(ctcpmsg)s' +'TIME': '%(nick)s has requested CTCP %(ctcpcmd)s from %(chan)s: %(ctcpmsg)s' +'FINGER': '%(nick)s has requested CTCP %(ctcpcmd)s from %(chan)s: %(ctcpmsg)s' +} irc_color_re = re.compile(r'(\x03(\d+,\d+|\d)|[\x0f\x02\x16\x1f])') def get_log_filename(dir, server, chan): - return os.path.join(dir, 'log', gmtime('%Y'), server, chan, + return os.path.join(dir, 'log', gmtime('%Y'), server, chan, (gmtime('%%s.%m-%d.log') % chan).lower()) diff --git a/plugins/mctools.py b/plugins/mctools.py index 399c4fd..19f1e95 100755 --- a/plugins/mctools.py +++ b/plugins/mctools.py @@ -12,13 +12,15 @@ def mcping_connect(host, port): sock.send('\xfe') response = sock.recv(1) if response != '\xff': - return "Server gave invalid response: "+repr(response) + return "Server gave invalid response: " + repr(response) length = struct.unpack('!h', sock.recv(2))[0] - values = sock.recv(length*2).decode('utf-16be').split(u'\xa7') + values = sock.recv(length * 2).decode('utf-16be').split(u'\xa7') sock.close() - return "%s - %d/%d players" % (values[0], int(values[1]), int(values[2])) + return "%s - %d/%d players"\ + % (values[0], int(values[1]), int(values[2])) except: - return "Error pinging "+host+":"+str(port)+", is it up? Double-check your address!" + return "Error pinging " + host + ":" + str(port) +\ + ", is it up? Double-check your address!" @hook.command(autohelp=False) @@ -29,33 +31,42 @@ def mcstatus(inp, bot=None): if password is None: return "error: no login set" - login = http.get("https://login.minecraft.net/?user="+username+"&password="+password+"&version=13") + login = http.get("https://login.minecraft.net/?user="\ + + username + "&password=" + password + "&version=13") if username.lower() in login.lower(): return "Minecraft login servers appear to be online!" else: return "Minecraft login servers appear to be offline!" + @hook.command def mclogin(inp, say=None): - ".mclogin -- Attempts to log in to Minecrat with and (This is NOT logged)." + ".mclogin -- Attempts to log in to Minecraft with "\ + " and (This is NOT logged)." inp = inp.split(" ") username = inp[0] password = inp[1] say("Attempting to log in using " + username) - login = http.get("https://login.minecraft.net/?user=" + username + "&password=" + password + "&version=13") + login = http.get("https://login.minecraft.net/?user="\ + + username + "&password=" + password + "&version=13") if username.lower() in login.lower(): return "I logged in with " + username else: - return "I couldn't log in using " + username + ", either the password is wrong or minecraft login servers are down!" + return "I couldn't log in using " + username + ", either"\ + " the password is wrong or Minecraft login servers are down!" + @hook.command def mcpaid(inp): - ".mcpaid -- Checks if has a premium Minecraft account." + ".mcpaid -- Checks if has a "\ + "premium Minecraft account." login = http.get("http://www.minecraft.net/haspaid.jsp?user=" + inp) if "true" in login: - return "The account \'" + inp + "\' is a premium Minecraft account!" + return "The account \'" + inp + "\' is a "\ + "premium Minecraft account!" else: - return "The account \'" + inp + "\' is not a premium Minecraft account!" + return "The account \'" + inp + "\' is not a "\ + "premium Minecraft account!" from util import hook diff --git a/plugins/namegen.py b/plugins/namegen.py index e3d5683..ba82033 100755 --- a/plugins/namegen.py +++ b/plugins/namegen.py @@ -1,9 +1,9 @@ # Plugin by Lukeroge -# - -from util import hook, molecular +from util import hook +from util import molecular import unicodedata + @hook.command() def namegen(inp, say=None, nick=None, input=None, notice=None): ".namegen [modules] -- Generates some names using the chosen modules. '.namegen list' will display a list of all modules." diff --git a/plugins/op.py b/plugins/op.py index c11be31..28e96ad 100644 --- a/plugins/op.py +++ b/plugins/op.py @@ -2,6 +2,17 @@ from util import hook +@hook.command(adminonly=True) +def topic(inp, conn=None, chan=None, notice=None): + ".topic [channel] -- Change the topic of a channel." + inp = inp.split(" ") + if inp[0][0] == "#": + out = "PRIVMSG %s :%s" % (inp[0], message) + else: + out = "TOPIC %s :%s" % (chan, message) + conn.send(out) + + @hook.command(adminonly=True) def kick(inp, chan=None, conn=None, notice=None): ".kick [channel] [reason] -- Makes the bot kick in [channel] "\ @@ -65,6 +76,7 @@ def unban(inp, conn=None, chan=None, notice=None): notice("Attempting to unban %s from %s..." % (user, chan)) conn.send(out) + @hook.command(adminonly=True) def kickban(inp, chan=None, conn=None, notice=None): ".kickban [channel] [reason] -- Makes the bot kickban in [channel] "\ @@ -96,13 +108,3 @@ def kickban(inp, chan=None, conn=None, notice=None): notice("Attempting to kickban %s from %s..." % (user, chan)) conn.send(out1) conn.send(out2) - -@hook.command(adminonly=True) -def topic(inp, conn=None, chan=None, notice=None): - ".topic [channel] -- Change the topic of a channel." - inp = inp.split(" ") - if inp[0][0] == "#": - out = "PRIVMSG %s :%s" % (inp[0], message) - else: - out = "TOPIC %s :%s" % (chan, message) - conn.send(out) diff --git a/plugins/potato.py b/plugins/potato.py index cf34686..5712a35 100755 --- a/plugins/potato.py +++ b/plugins/potato.py @@ -4,6 +4,7 @@ import random potatoes = ['AC Belmont', 'AC Blue Pride', 'AC Brador', 'AC Chaleur', 'AC Domino', 'AC Dubuc', 'AC Glacier Chip', 'AC Maple Gold', 'AC Novachip', 'AC Peregrine Red', 'AC Ptarmigan', 'AC Red Island', 'AC Saguenor', 'AC Stampede Russet', 'AC Sunbury', 'Abeille', 'Abnaki', 'Acadia', 'Acadia Russet', 'Accent', 'Adirondack Blue', 'Adirondack Red', 'Adora', 'Agria', 'All Blue', 'All Red', 'Alpha', 'Alta Russet', 'Alturas Russet', 'Amandine', 'Amisk', 'Andover', 'Anoka', 'Anson', 'Aquilon', 'Arran Consul', 'Asterix', 'Atlantic', 'Austrian Crescent', 'Avalanche', 'Banana', 'Bannock Russet', 'Batoche', 'BeRus', 'Belle De Fonteney', 'Belleisle', 'Bintje', 'Blossom', 'Blue Christie', 'Blue Mac', 'Brigus', 'Brise du Nord', 'Butte', 'Butterfinger', 'Caesar', 'CalWhite', 'CalRed', 'Caribe', 'Carlingford', 'Carlton', 'Carola', 'Cascade', 'Castile', 'Centennial Russet', 'Century Russet', 'Charlotte', 'Cherie', 'Cherokee', 'Cherry Red', 'Chieftain', 'Chipeta', 'Coastal Russet', 'Colorado Rose', 'Concurrent', 'Conestoga', 'Cowhorn', 'Crestone Russet', 'Crispin', 'Cupids', 'Daisy Gold', 'Dakota Pearl', 'Defender', 'Delikat', 'Denali', 'Desiree', 'Divina', 'Dundrod', 'Durango Red', 'Early Rose', 'Elba', 'Envol', 'Epicure', 'Eramosa', 'Estima', 'Eva', 'Fabula', 'Fambo', 'Fremont Russet', 'French Fingerling', 'Frontier Russet', 'Fundy', 'Garnet Chile', 'Gem Russet', 'GemStar Russet', 'Gemchip', 'German Butterball', 'Gigant', 'Goldrush', 'Granola', 'Green Mountain', 'Haida', 'Hertha', 'Hilite Russet', 'Huckleberry', 'Hunter', 'Huron', 'IdaRose', 'Innovator', 'Irish Cobbler', 'Island Sunshine', 'Ivory Crisp', 'Jacqueline Lee', 'Jemseg', 'Kanona', 'Katahdin', 'Kennebec', "Kerr's Pink", 'Keswick', 'Keuka Gold', 'Keystone Russet', 'King Edward VII', 'Kipfel', 'Klamath Russet', 'Krantz', 'LaRatte', 'Lady Rosetta', 'Latona', 'Lemhi Russet', 'Liberator', 'Lili', 'MaineChip', 'Marfona', 'Maris Bard', 'Maris Piper', 'Matilda', 'Mazama', 'McIntyre', 'Michigan Purple', 'Millenium Russet', 'Mirton Pearl', 'Modoc', 'Mondial', 'Monona', 'Morene', 'Morning Gold', 'Mouraska', 'Navan', 'Nicola', 'Nipigon', 'Niska', 'Nooksack', 'NorValley', 'Norchip', 'Nordonna', 'Norgold Russet', 'Norking Russet', 'Norland', 'Norwis', 'Obelix', 'Ozette', 'Peanut', 'Penta', 'Peribonka', 'Peruvian Purple', 'Pike', 'Pink Pearl', 'Prospect', 'Pungo', 'Purple Majesty', 'Purple Viking', 'Ranger Russet', 'Reba', 'Red Cloud', 'Red Gold', 'Red La Soda', 'Red Pontiac', 'Red Ruby', 'Red Thumb', 'Redsen', 'Rocket', 'Rose Finn Apple', 'Rose Gold', 'Roselys', 'Rote Erstling', 'Ruby Crescent', 'Russet Burbank', 'Russet Legend', 'Russet Norkotah', 'Russet Nugget', 'Russian Banana', 'Saginaw Gold', 'Sangre', 'Sant�', 'Satina', 'Saxon', 'Sebago', 'Shepody', 'Sierra', 'Silverton Russet', 'Simcoe', 'Snowden', 'Spunta', "St. John's", 'Summit Russet', 'Sunrise', 'Superior', 'Symfonia', 'Tolaas', 'Trent', 'True Blue', 'Ulla', 'Umatilla Russet', 'Valisa', 'Van Gogh', 'Viking', 'Wallowa Russet', 'Warba', 'Western Russet', 'White Rose', 'Willamette', 'Winema', 'Yellow Finn', 'Yukon Gold'] + @hook.command def potato(inp, me=None, input=None): ".potato - Makes a tasty little potato." diff --git a/plugins/quote.py b/plugins/quote.py index 6553018..d1a49b6 100755 --- a/plugins/quote.py +++ b/plugins/quote.py @@ -4,24 +4,27 @@ import time from util import hook + def format_quote(q, num, n_quotes): - "Returns a formatted string of a quote" + """Returns a formatted string of a quote""" ctime, nick, msg = q return "[%d/%d] <%s> %s" % (num, n_quotes, nick, msg) + def create_table_if_not_exists(db): - "Creates an empty quote table if one does not already exist" + """Creates an empty quote table if one does not already exist""" db.execute("create table if not exists quote" "(chan, nick, add_nick, msg, time real, deleted default 0, " "primary key (chan, nick, msg))") db.commit() + def add_quote(db, chan, nick, add_nick, msg): - "Adds a quote to a nick, returns message string" + """Adds a quote to a nick, returns message string""" try: - db.execute('''INSERT OR FAIL INTO quote - (chan, nick, add_nick, msg, time) + db.execute('''INSERT OR FAIL INTO quote + (chan, nick, add_nick, msg, time) VALUES(?,?,?,?,?)''', (chan, nick, add_nick, msg, time.time())) db.commit() @@ -29,30 +32,34 @@ def add_quote(db, chan, nick, add_nick, msg): return "Message already stored, doing nothing." return "Quote added." + def del_quote(db, chan, nick, add_nick, msg): - "Deletes a quote from a nick" + """Deletes a quote from a nick""" db.execute('''UPDATE quote SET deleted = 1 WHERE chan=? AND lower(nick)=lower(?) AND msg=msg''') db.commit() + def get_quote_num(num, count, name): - "Returns the quote number to fetch from the DB" + """Returns the quote number to fetch from the DB""" if num: # Make sure num is a number if it isn't false num = int(num) - if count == 0: # If there are no quotes in the database, raise an Exception. + if count == 0: # Error on no quotes raise Exception("No quotes found for %s." % name) - if num and num < 0: # If the selected quote is less than 0, count back if possible. + if num and num < 0: # Count back if possible num = count + num + 1 if num + count > -1 else count + 1 - if num and num > count: # If a number is given and and there are not enough quotes, raise an Exception. - raise Exception("I only have %d quote%s for %s." % (count, ('s', '')[count == 1], name)) + if num and num > count: # If there are not enough quotes, raise an error + raise Exception("I only have %d quote%s for %s."\ + % (count, ('s', '')[count == 1], name)) if num and num == 0: # If the number is zero, set it to one num = 1 if not num: # If a number is not given, select a random one num = random.randint(1, count) return num + def get_quote_by_nick(db, nick, num=False): - "Returns a formatted quote from a nick, random or selected by number" + """Returns a formatted quote from a nick, random or selected by number""" count = db.execute('''SELECT COUNT(*) FROM quote WHERE deleted != 1 AND lower(nick) = lower(?)''', [nick]).fetchall()[0][0] @@ -60,17 +67,18 @@ def get_quote_by_nick(db, nick, num=False): num = get_quote_num(num, count, nick) except Exception as error_message: return error_message - + quote = db.execute('''SELECT time, nick, msg FROM quote WHERE deleted != 1 AND lower(nick) = lower(?) ORDER BY time - LIMIT ?, 1''', (nick, (num-1))).fetchall()[0] + LIMIT ?, 1''', (nick, (num - 1))).fetchall()[0] return format_quote(quote, num, count) - + + def get_quote_by_nick_chan(db, chan, nick, num=False): - "Returns a formatted quote from a nick in a channel, random or selected by number" + """Returns a formatted quote from a nick in a channel, random or selected by number""" count = db.execute('''SELECT COUNT(*) FROM quote WHERE deleted != 1 @@ -88,11 +96,12 @@ def get_quote_by_nick_chan(db, chan, nick, num=False): AND chan = ? AND lower(nick) = lower(?) ORDER BY time - LIMIT ?, 1''', (chan, nick, (num-1))).fetchall()[0] + LIMIT ?, 1''', (chan, nick, (num - 1))).fetchall()[0] return format_quote(quote, num, count) -def get_quote_by_chan(db, chan, num=False): - "Returns a formatted quote from a channel, random or selected by number" + +def get_quote_by_chan(db, chan, num=False): + """Returns a formatted quote from a channel, random or selected by number""" count = db.execute('''SELECT COUNT(*) FROM quote WHERE deleted != 1 @@ -103,14 +112,15 @@ def get_quote_by_chan(db, chan, num=False): except Exception as error_message: return error_message - quote = db.execute('''SELECT time, nick, msg + quote = db.execute('''SELECT time, nick, msg FROM quote WHERE deleted != 1 - AND chan = ? + AND chan = ? ORDER BY time - LIMIT ?, 1''', (chan, (num -1))).fetchall()[0] + LIMIT ?, 1''', (chan, (num - 1))).fetchall()[0] return format_quote(quote, num, count) + @hook.command('q') @hook.command def quote(inp, nick='', chan='', db=None, notice=None): @@ -128,12 +138,12 @@ def quote(inp, nick='', chan='', db=None, notice=None): elif retrieve: select, num = retrieve.groups() by_chan = True if select.startswith('#') else False - if by_chan: + if by_chan: return get_quote_by_chan(db, select, num) else: return get_quote_by_nick(db, select, num) elif retrieve_chan: chan, nick, num = retrieve_chan.groups() return get_quote_by_nick_chan(db, chan, nick, num) - + notice(quote.__doc__) diff --git a/plugins/shorten.py b/plugins/shorten.py index 7e7daf2..7ab07e6 100755 --- a/plugins/shorten.py +++ b/plugins/shorten.py @@ -1,5 +1,4 @@ # Plugin by Lukeroge -# from util import hook, http from re import match diff --git a/plugins/sieve.py b/plugins/sieve.py index cdbeb9c..ccc4174 100755 --- a/plugins/sieve.py +++ b/plugins/sieve.py @@ -5,7 +5,7 @@ from util import hook @hook.sieve def sieve_suite(bot, input, func, kind, args): - if input.command == 'PRIVMSG' and \ + if input.command == 'PRIVMSG' and\ input.nick.endswith('bot') and args.get('ignorebots', True): return None @@ -32,7 +32,7 @@ def sieve_suite(bot, input, func, kind, args): if args.get('adminonly', False): admins = bot.config.get('admins', []) - if input.mask not in admins and input.nick not in admins: + if input.nick not in admins and input.mask not in admins: input.notice("Sorry, you are not allowed to use this command.") return None diff --git a/plugins/time.py b/plugins/time.py index 1bb9f1f..d8cd9ed 100755 --- a/plugins/time.py +++ b/plugins/time.py @@ -1,5 +1,4 @@ # Plugin by Lukeroge with some code from Phenny -# from util import hook from util import http diff --git a/plugins/translate.py b/plugins/translate.py index 253e5f5..d61ab14 100755 --- a/plugins/translate.py +++ b/plugins/translate.py @@ -1,4 +1,4 @@ -# BING translation plugin by lukeroge and neersighted +# BING translation plugin by Lukeroge and neersighted from util import hook from util import http import re diff --git a/plugins/twitter.py b/plugins/twitter.py index 9b78fef..6186823 100755 --- a/plugins/twitter.py +++ b/plugins/twitter.py @@ -1,17 +1,17 @@ -""" -twitter.py: written by Scaevolus 2009, modified by Lukeroge 2012 -retrieves most recent tweets -""" +# written by Scaevolus, modified by Lukeroge import random import re -from time import strptime, strftime +from time import strftime +from time import strptime from datetime import datetime - -from util import hook, http, timesince +from util import hook +from util import http +from util import timesince def unescape_xml(string): + """Unescapes XML""" return string.replace('>', '>').replace('<', '<').replace(''', "'").replace('"e;', '"').replace('&', '&') @@ -20,6 +20,7 @@ history_max_size = 250 def parseDateTime(s): + """Parses the date from a string""" if s is None: return None m = re.match(r'(.*?)(?:\.(\d+))?(([-+]\d{1,2}):(\d{2}))?$', diff --git a/plugins/violence.py b/plugins/violence.py index 603f7c5..9eda0e1 100755 --- a/plugins/violence.py +++ b/plugins/violence.py @@ -46,7 +46,7 @@ with open("plugins/data/kill_bodyparts.txt") as f: def slap(inp, me=None, nick=None, conn=None, notice=None): ".slap -- Makes the bot slap ." target = inp.lower() - + if not re.match(nick_re, target): notice("Invalid username!") return @@ -56,11 +56,11 @@ def slap(inp, me=None, nick=None, conn=None, notice=None): target = nick else: target = inp - + out = random.choice(slaps) out = out.replace('', target) out = out.replace('', random.choice(slap_items)) - + # act out the message me(out) @@ -78,7 +78,7 @@ def lart(inp, me=None, nick=None, conn=None, notice=None): target = nick else: target = inp - + out = random.choice(larts) out = out.replace('', target) out = out.replace('', random.choice(slap_items)) @@ -98,7 +98,7 @@ def kill(inp, me=None, nick=None, conn=None, notice=None): target = nick else: target = inp - + out = random.choice(kills) out = out.replace('', target) out = out.replace('', random.choice(kill_bodyparts)) diff --git a/plugins/wordoftheday.py b/plugins/wordoftheday.py index 3d4b631..ebf6c1c 100755 --- a/plugins/wordoftheday.py +++ b/plugins/wordoftheday.py @@ -10,8 +10,8 @@ def word(inp, say=False, nick=False): soup = BeautifulSoup(page) - word = soup.find('strong', {'class' : 'main_entry_word'}).renderContents() - function = soup.find('p', {'class' : 'word_function'}).renderContents() + word = soup.find('strong', {'class': 'main_entry_word'}).renderContents() + function = soup.find('p', {'class': 'word_function'}).renderContents() #definitions = re.findall(r':' # r' *([^<]+)', content) From a659cebde6e3ea32775f5f440b330deed66f9532 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 2 Apr 2012 09:19:44 -0700 Subject: [PATCH 198/205] Bugfix --- plugins/log.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/log.py b/plugins/log.py index 4b761a9..1d37563 100755 --- a/plugins/log.py +++ b/plugins/log.py @@ -27,10 +27,10 @@ formats = { } ctcp_formats = { -'ACTION': '* %(nick)s %(ctcpmsg)s' -'VERSION': '%(nick)s has requested CTCP %(ctcpcmd)s from %(chan)s: %(ctcpmsg)s' -'PING': '%(nick)s has requested CTCP %(ctcpcmd)s from %(chan)s: %(ctcpmsg)s' -'TIME': '%(nick)s has requested CTCP %(ctcpcmd)s from %(chan)s: %(ctcpmsg)s' +'ACTION': '* %(nick)s %(ctcpmsg)s', +'VERSION': '%(nick)s has requested CTCP %(ctcpcmd)s from %(chan)s: %(ctcpmsg)s', +'PING': '%(nick)s has requested CTCP %(ctcpcmd)s from %(chan)s: %(ctcpmsg)s', +'TIME': '%(nick)s has requested CTCP %(ctcpcmd)s from %(chan)s: %(ctcpmsg)s', 'FINGER': '%(nick)s has requested CTCP %(ctcpcmd)s from %(chan)s: %(ctcpmsg)s' } From 84e1a1fe5ac02ef6b759c3261b7daefb22550228 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 2 Apr 2012 09:32:21 -0700 Subject: [PATCH 199/205] Added actual data to CTCP TIME/FINGER --- plugins/ctcp.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/ctcp.py b/plugins/ctcp.py index 800115b..83ea55e 100755 --- a/plugins/ctcp.py +++ b/plugins/ctcp.py @@ -1,22 +1,27 @@ +# Plugin by neersighted +import time +import getpass from util import hook # CTCP responses @hook.regex(r'^\x01VERSION\x01$') -def ctcpversion(inp, notice=None): +def ctcp_version(inp, notice=None): notice('\x01VERSION: CloudBot - http://git.io/cloudbotirc') @hook.regex(r'^\x01PING\x01$') -def ctcpping(inp, notice=None): +def ctcp_ping(inp, notice=None): notice('\x01PING: PONG') @hook.regex(r'^\x01TIME\x01$') -def ctcptime(inp, notice=None): - notice('\x01TIME: GET A WATCH') +def ctcp_time(inp, notice=None): + the_time = time.strftime("%r", time.localtime()) + notice('\x01TIME: The time is: ' + the_time) @hook.regex(r'^\x01FINGER\x01$') -def ctcpfinger(inp, notice=None): - notice('\x01FINGER: WHERE ARE YOU PUTTING THAT') +def ctcp_finger(inp, notice=None): + user = getpass.getuser() + notice('\x01FINGER: Username is: ' + user) From 1b9d89c15fcc8264a1554b74c047526e2c31069e Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 2 Apr 2012 09:32:56 -0700 Subject: [PATCH 200/205] Updated fileperms --- plugins/op.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 plugins/op.py diff --git a/plugins/op.py b/plugins/op.py old mode 100644 new mode 100755 From 339b18d6c7783524a173c9f651373ac36b84a663 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 2 Apr 2012 09:33:37 -0700 Subject: [PATCH 201/205] Made screen default backend (upon popular request) --- cloudbot | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cloudbot b/cloudbot index 2b2a605..d6fbc09 100755 --- a/cloudbot +++ b/cloudbot @@ -23,10 +23,10 @@ running() { } checkbackend() { - if dpkg -l| grep ^ii|grep daemon|grep 'turns other' > /dev/null; then - backend="daemon" - elif dpkg -l| grep ^ii|grep screen|grep 'terminal multi' > /dev/null; then + if dpkg -l| grep ^ii|grep screen|grep 'terminal multi' > /dev/null; then backend="screen" + elif dpkg -l| grep ^ii|grep daemon|grep 'turns other' > /dev/null; then + backend="daemon" else backend="manual" fi From 004f7916c7f86bba18cd4518ede933719be32f48 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 2 Apr 2012 09:37:35 -0700 Subject: [PATCH 202/205] Minor tweaks --- plugins/admin.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/admin.py b/plugins/admin.py index 65673e2..8582602 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -91,6 +91,13 @@ def join(inp, conn=None, notice=None): conn.join(inp) +@hook.command(adminonly=True) +def part(inp, conn=None, notice=None): + ".part -- Leaves ." + notice("Attempting to part from %s..." % inp) + conn.part(inp) + + @hook.command(adminonly=True) def cycle(inp, conn=None, notice=None): ".cycle -- Cycles ." @@ -99,13 +106,6 @@ def cycle(inp, conn=None, notice=None): conn.join(inp) -@hook.command(adminonly=True) -def part(inp, conn=None, notice=None): - ".part -- Leaves ." - notice("Attempting to part from %s..." % inp) - conn.part(inp) - - @hook.command(adminonly=True) def nick(inp, input=None, notice=None, conn=None): ".nick -- Changes the bots nickname to ." From f1c75e30952bf574556cb250d2d0b9f42810c354 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 2 Apr 2012 09:49:27 -0700 Subject: [PATCH 203/205] Punct fixes --- plugins/data/insults.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/data/insults.txt b/plugins/data/insults.txt index 0eb5d09..3a7cd71 100755 --- a/plugins/data/insults.txt +++ b/plugins/data/insults.txt @@ -18,8 +18,8 @@ Is your name Maple Syrup? It should be, you sap. Bite my shiny metal ass! Up yours, meatbag. Jam a bastard in it you crap! -Don't piss me off today, I'm running out of places to hide the bodies -Why don't you go outside and play hide and go fuck yourself +Don't piss me off today, I'm running out of places to hide the bodies... +Why don't you go outside and play hide and go fuck yourself! I'll use small words you're sure to understand, you warthog-faced buffoon. You are a sad, strange little man, and you have my pity. Sit your five dollar ass down before I make change. From ad7112902956fcbde72cdc39fca8191a3fc5d402 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 2 Apr 2012 09:50:32 -0700 Subject: [PATCH 204/205] Added more bodyparts --- plugins/data/kill_bodyparts.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/data/kill_bodyparts.txt b/plugins/data/kill_bodyparts.txt index 35dcc8d..8477e68 100755 --- a/plugins/data/kill_bodyparts.txt +++ b/plugins/data/kill_bodyparts.txt @@ -1,5 +1,9 @@ head arms -leg +legs arm +leg +toes +fingers "special parts" +"man bits" From c94f2f0daee62465ae13c0ea1624a49a31be5a94 Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 2 Apr 2012 10:01:46 -0700 Subject: [PATCH 205/205] Version Bump --- README.md | 4 ++-- bot.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 14d316d..f0f4b12 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# CloudBot/DEV +# CloudBot/1.2 ## About @@ -102,7 +102,7 @@ The programs `screen` or `daemon` are recomended for the wrapper to run optimaly ## License CloudBot is **licensed** under the **GPL v3** license. The terms are as follows. - CloudBot/DEV + CloudBot/1.2 Copyright © 2011 ClouDev - <[cloudev.github.com](http://cloudev.github.com)> diff --git a/bot.py b/bot.py index e754380..470c577 100755 --- a/bot.py +++ b/bot.py @@ -13,7 +13,7 @@ os.chdir(sys.path[0] or '.') # do stuff relative to the install directory class Bot(object): pass -print 'Welcome to Cloudbot - Version DEV - http://git.io/cloudbotirc' +print 'Welcome to Cloudbot - Version 1.2 - http://git.io/cloudbotirc' bot = Bot() bot.start_time = time.time()