diff --git a/Furry_Cloudbot.py b/Furry_Cloudbot.py deleted file mode 100644 index 007cc42..0000000 --- a/Furry_Cloudbot.py +++ /dev/null @@ -1,14 +0,0 @@ -from util import hook -import feedparser -import random - -@hook.command -def furry(inp): - d = feedparser.parse('http://backend.deviantart.com/rss.xml?type=deviation&q=furry') - counter = len(d['entries']) - value = random.randint(0, counter) - returnitem = d.entries[value]['link'] - return str(returnitem) - -#Single Liner Code -#import feedparser; import random; d = feedparser.parse('http://backend.deviantart.com/rss.xml?type=deviation&q=furry'); counter = len(d['entries']); value = random.randint(0, counter); returnitem = d.entries[value]['link']; print str(returnitem); diff --git a/ModdedSubreddits_Cloudbot.py b/ModdedSubreddits_Cloudbot.py index 0c9e7e7..6613471 100644 --- a/ModdedSubreddits_Cloudbot.py +++ b/ModdedSubreddits_Cloudbot.py @@ -1,25 +1,27 @@ +# RoboCop 2's ModeratedSubreddits.py - Brings up modded subreddits by an user on reddit. + from bs4 import BeautifulSoup -import urllib, urllib2 +import urllib.error, urllib.request import lxml.html -from util import hook +from cloudbot import hook @hook.command -def mods(inp): +def mods(text): """Usage: @mods [user]""" - address = "http://www.reddit.com/user/" + inp - data = urllib2.Request(address, None, {'User-Agent':'Mosilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11'}) + address = "http://www.reddit.com/user/" + text + data = urllib.request.Request(address, None, {'User-Agent':'Mosilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11'}) try: - urlfile = urllib2.urlopen(data) - except urllib2.HTTPError: + urlfile = urllib.request.urlopen(data) + except urllib.error.HTTPError: return "Huh, that user seems to not exist." page = urlfile.read() soup = BeautifulSoup(page) #Title Message for the console - print soup.title.string + print(soup.title.string); subreddits = soup.findAll("ul", { "id" : "side-mod-list" }) - user = inp + user = text #Return the list of subreddits try: diff --git a/about.py b/about.py new file mode 100644 index 0000000..d990176 --- /dev/null +++ b/about.py @@ -0,0 +1,16 @@ +# RoboCop 2's about.py - This module simply gives information about the bot, licenses, and authors. +# based upon gpl.py and maintainer.py, from the original RoboCop. + +from cloudbot import hook + +@hook.command +def gpl(text): + """[info|license] - gives information about getting source code, or finding the license for the bot""" + if text == "license": + return "RoboCop is licensed under the GPL v3 license. The terms are available at https://github.com/FurCode/TechsupportModules/blob/master/LICENSE" + else: + return "Please email RoboCop@comprepair.tk or go to https://github.com/FurCode/TechsupportModules" + +@hook.command +def about(): + return "RoboCop 2 is a fork of CloudBot Refresh, designed to feel like classic RoboCop. Written by rodthefox, maintained by the #techsupport team. (c) FurCode 2014" diff --git a/color_cloudbot.py b/color_cloudbot.py index a6cdb7c..4f3f800 100644 --- a/color_cloudbot.py +++ b/color_cloudbot.py @@ -1,9 +1,11 @@ -from util import hook +# RoboCop 2's color_cloudbot.py - Color and Rainbow mods for text. + +from cloudbot import hook @hook.command -def rainbow(inp): +def rainbow(text): palette = {1: '04', 2: '07', 3: '08', 4: '09', 5: '11', 6: '12', 7: '06'}; - string = inp; + string = text; sloop = len(string); stack = 0 letters = list(string); diff --git a/colorize2.py b/colorize2.py new file mode 100644 index 0000000..746cb5e --- /dev/null +++ b/colorize2.py @@ -0,0 +1,53 @@ +# RoboCop 2's Colorize2.py - The text colorization module allows the coloring of any text, even on clients without support for it. + +from cloudbot import hook +import random + +@hook.command +def colorize(text): + """[color|random];[text] - colorizes the text input to the color provided.""" + arguments = text.split(";") + color = arguments[0].lower() + text = arguments[1] + if color == "white": + return "0" + text; + elif color == "black": + return "1" + text; + elif color == "navyblue": + return "2" + text; + elif color == "green": + return "3" + text; + elif color == "red": + return "4" + text; + elif color == "brown": + return "5" + text; + elif color == "purple": + return "6" + text; + elif color == "orange": + return "7" + text; + elif color == "yellow": + return "8" + text; + elif color == "lightgreen": + return "9" + text; + elif color == "teal": + return "10" + text; + elif color == "cyan": + return "11" + text; + elif color == "blue": + return "12" + text; + elif color == "pink": + return "13" + text; + elif color == "grey": + return "14" + text; + elif color == "lightgrey": + return "15" + text; + elif color == "random": + letters = list(text) + string = ""; + for x in letters: + value = "%02d" % random.randint(0, 15) + string += "" + str(value) + x + "" + return string + else: + return "\'"+ color + "\' is not a valid color."; + diff --git a/fox.py b/fox.py new file mode 100644 index 0000000..4572fdb --- /dev/null +++ b/fox.py @@ -0,0 +1,23 @@ +# RoboCop 2's fox.py - Brings a cute fox submission from the /r/foxes subreddit + +from cloudbot import hook +import feedparser +import random + +@hook.command +def foxes(text): + d = feedparser.parse('https://www.reddit.com/r/foxes/.rss') + counter = len(d['entries']) + print(counter); + value = random.randint(0, counter) + url = d.entries[value]['link'] + print(url); + link = reddit_small(url) + returnitem = d.entries[value]['title'] + " - " + link + return str(returnitem) + +def reddit_small(url): + baseurl = "http://redd.it/" + urlid = url[40:] + shortid = urlid[:6] + return baseurl + shortid diff --git a/furry.py b/furry.py new file mode 100644 index 0000000..658e88d --- /dev/null +++ b/furry.py @@ -0,0 +1,13 @@ +# RoboCop 2's furry.py, uses the RSS engine to grab random Furry art from DeviantArt + +from cloudbot import hook +import feedparser +import random + +@hook.command +def furry(text): + d = feedparser.parse('http://backend.deviantart.com/rss.xml?type=deviation&q=furry') + counter = len(d['entries']) + value = random.randint(0, counter) + returnitem = d.entries[value]['link'] + return str(returnitem) diff --git a/isos.py b/isos.py index dd5aa2b..c611aaf 100644 --- a/isos.py +++ b/isos.py @@ -1,25 +1,32 @@ -from util import hook +# RoboCop 2's isos.py, adapted from the Original RoboCop module for Python 2.7.x + +from cloudbot import hook @hook.command -def isos(inp): - """isos [edition] [torrent] -- It will grab the correct ISO link for a download.""" +def isos(text): + """- [edition] [torrent] -- It will grab the correct ISO link for a download.""" + inp = text; dict = {'windows 7 pro 64': 'Windows 7 Pro 64-bit: http://msft.digitalrivercontent.net/win/X17-24281.iso'}; - dict['windows 7 home 64'] = "Windows 7 Home Premium 64-bit: http://msft.digitalrivercontent.net/win/X17-24209.iso"; + dict['windows 7 home 64'] = "Windows 7 Home Premium 64-bit: http://msft.digitalrivercontent.net/win/X17-58997.iso"; dict['windows 7 pro 32'] = "Windows 7 Pro 32-bit: http://msft.digitalrivercontent.net/win/X17-24280.iso"; dict['windows 7 home 32'] = "Windows 7 Home Premium 32-bit: http://msft.digitalrivercontent.net/win/X17-24208.iso"; dict['windows 7 ultimate 64'] = "Windows 7 Ultimate 64-bit: http://msft.digitalrivercontent.net/win/X17-24395.iso"; dict['windows 7 ultimate 32'] = "Windows 7 Ultimate 32-bit: http://msft.digitalrivercontent.net/win/X17-24394.iso"; - dict['windows 8 pro 64'] = "Windows 8 Pro 64-bit: http://repo.comprepair.tk/Windows8_Pro/Windows8_Pro_ESD.iso | MD5: e4716c7086db4431a6fb1a8716df3d9f"; + dict['windows 8 pro 64'] = "Windows 8 Pro 64-bit: http://repo.comprepair.tk/Windows8_Pro/Windows8_Pro_ESD.iso | MD5: 72c43a26c2e28c4e801f09ea9cd4b592"; dict['windows 8 pro 32'] = "Windows 8 Pro 32-bit: http://repo.comprepair.tk/Windows8_Pro/Windows8_Pro_ESD_x86.iso | MD5: 255eb2cfaca6cc398361033365f1eb28"; dict['windows 8.1 pro 64'] = "Windows 8.1 Pro 64-bit: http://repo.comprepair.tk/Windows8.1_Pro/Windows_81_ESD_install_x64.iso | MD5: 5119bf941fdb96cbe839e9599186eda3"; dict['windows 8.1 pro 32'] = "We do not have an ISO in the repository for that. Try using the official Microsoft downloader at http://goo.gl/qtfqo if you got a retail key."; dict['windows vista home 32'] = "Windows Vista Home Premium 32-bit: http://repo.comprepair.tk/WindowsVista_HomePremium/LRMCFRE_EN_DVD.iso | MD5: 1008f323d5170c8e614e52ccb85c0491"; - dict['windows vista home 64'] = "We do not have an ISO in the repository for that."; + dict['windows vista home 64'] = "Windows Vista (All Editions) 64-bit: http://repo.comprepair.tk/WindowsVista_HomePremium/LRMCFRE_EN_DVD_64.ISO"; dict['windows xp pro 32'] = "Windows XP Professional 32-bit: http://repo.comprepair.tk/WindowsXP_SP2_Professional/VX2POEM_EN.iso | MD5: 2d7f4e6e334e9a84c45231f5a40aa56f"; - dict['windows xp pro 64'] = "Windows XP Professional 64-bit (Uploaded by blumoon): http://repo.comprepair.tk/WindowsXP_SP2_Professional/CRMPXOEM_EN.ISO | SHA-1: da414d53d2ed40a7e6376d981203c49cc949ad24"; + dict['windows xp pro 64'] = "Windows XP Professional 64-bit (Uploaded by blumoon): http://repo.comprepair.tk/WindowsXP_SP2_Professional/CRMPXOEM_EN.ISO | SHA1: da414d53d2ed40a7e6376d981203c49cc949ad24"; dict['windows torrent'] = "Are you out of your mind? We don't recommend you use a Windows torrent under most circumstances."; - + dict['windows 8 core 64'] = "Windows 8 Core 64-bit (by blumoon): http://repo.comprepair.tk/Windows8_Core/en_windows_8_x64_dvd_915440.iso | SHA1: 1ce53ad5f60419cf04a715cf3233f247e48beec4"; + dict['windows 10 preview 64'] = "Windows 10 Technical Preview 64-bit: http://repo.comprepair.tk/Windows10/WindowsTechnicalPreview-x64-EN-US.iso"; + dict['windows 10 preview 32'] = "Windows 10 Technical Preview 32-bit: http://repo.comprepair.tk/Windows10/WindowsTechnicalPreview-x86-EN-US.iso"; + dict['windows nt4 pro 32'] = "Windows NT 4 Workstation - 32-bit: http://repo.comprepair.tk/WindowsNT4_Workstation/NTWKS40A.iso"; + items_windows = dict.keys() dict['ubuntu 14.04 64'] = "Ubuntu Desktop 14.04 (LTS) 64-bit: http://www.ubuntu.com/download/desktop/thank-you?country=US&version=14.04&architecture=amd64"; @@ -81,7 +88,7 @@ def isos(inp): inp = inp.lower() if inp == "print": - print str(items) + print(str(items)); value = ', '.join(items) else: diff --git a/jsc.py b/jsc.py new file mode 100644 index 0000000..64138b1 --- /dev/null +++ b/jsc.py @@ -0,0 +1,37 @@ +# RoboCop 2's Javascript Interpreter, designed to imitate pyexec.py. Also as reference for creating JavaScript-based RoboCop modules. +from cloudbot import hook +import sys +import urllib.parse, urllib.request +from pastebin_python import PastebinPython + +@hook.command +def jsc(text): + """- Runs JavaScript code and returns the results. Requires a running JavaScript engine""" + remote = "http://services.secretalgorithm.com/" + eval = urllib.parse.quote(text) + address = remote + eval + data = urllib.request.Request(address, None, {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57'}) + try: + urlfile = urllib.request.urlopen(data) + except: + return "Server is down." + page = urlfile.read() + return page.decode("utf-8"); + +@hook.command +def jsp(text): + """- Runs JavaScript code and returns multiline results as a Pastebin.""" + remote = "http://services.secretalgorithm.com/" + eval = urllib.parse.quote(text) + address = remote + eval + data = urllib.request.Request(address, None, {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57'}) + try: + urlfile = urllib.request.urlopen(data) + except: + return "Server is down." + page = urlfile.read() + title = "Javascript Output".encode('utf-8') + key = "cea50129bea8b85d06d4e5342f1575d8".encode('utf-8') + pbin = PastebinPython(api_dev_key=key) + link = pbin.createPaste(page, title) + return str(link); diff --git a/links.py b/links.py new file mode 100644 index 0000000..9846cd4 --- /dev/null +++ b/links.py @@ -0,0 +1,50 @@ +# RoboCop 2's links.py - Universal links module extracts metadata from URLs to provide context. + +import re +import time + +from cloudbot import hook +from cloudbot.util import timeformat, formatting + +from bs4 import BeautifulSoup +import urllib.parse, urllib.request +import lxml.html + +linkre = re.compile(r'(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)/)(?:[^\s()<>{}\[\]]+|\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\))+(?:\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’])|(?:(? -- Search for any part on Octopart.""" + url = "http://octopart.com/api/v3/parts/search" + + # NOTE: Use your API key here (https://octopart.com/api/register) + url += "?apikey=aefcd00e" + + args = [ + ('q', text), + ('start', 0), + ('limit', 2) + ] + + url += '&' + urllib.parse.urlencode(args) + + data = urllib.request.urlopen(url).read() + search_response = json.loads(data.decode("utf-8")) + + # print number of hits + numhits = search_response['hits'] + conn.cmd("PRIVMSG " + chan + " Number of Hits: " + str(numhits)); + + # print results + for result in search_response['results']: + part = result['item'] + + # print matched part + numresult = "%s - %s - %s" % (part['brand']['name'], part['mpn'], part['octopart_url']) + conn.cmd("PRIVMSG " + chan + " " + numresult); diff --git a/outfox.py b/outfox.py index 7012c9e..701a334 100644 --- a/outfox.py +++ b/outfox.py @@ -1,5 +1,5 @@ -from util import hook +from cloudbot import hook @hook.command -def outfox(inp, conn=None, chan=None): +def outfox(text, conn=None, chan=None): return "This function-less command was thought up by Adam2013."; \ No newline at end of file diff --git a/poll.py b/poll.py index 5f47cc6..402d415 100644 --- a/poll.py +++ b/poll.py @@ -1,13 +1,15 @@ -from util import hook +# RoboCop 2's poll.py - Allows running a single poll session on any channel. + +from cloudbot import hook import os import pickle @hook.command -def poll(inp, conn=None, chan=None, action=None, nick=None): - args = inp; - if inp == "help": +def poll(text, conn=None, chan=None, action=None, nick=None): + args = text; + if text == "help": return "This does nothing."; - if inp == "close": + if text == "close": os.remove("plock.txt") tally = readtally(); results = retreive(); @@ -20,21 +22,21 @@ def poll(inp, conn=None, chan=None, action=None, nick=None): os.remove("tally.pkl") os.remove("poll.txt") return "Results from poll: " + printer; - if inp.isdigit(): - numtovote = int(inp) + if text.isdigit(): + numtovote = int(text) tally = readtally(); - print tally; + print(tally); try: - count = tally.get(int(inp)); - tally[int(inp)] = count + 1 + count = tally.get(int(text)); + tally[int(text)] = count + 1 storetally(tally); - notice("Voted for: " + inp, conn, chan, nick); + notice("Voted for: " + text, conn, chan, nick); except TypeError: notice("That is not valid.", conn, chan, nick); - if inp == "list": + if text == "list": results = retreive(); prettylist = ', '.join(results) - print list(); + print(list()); message = "Currently up for votes:"; count = len(results) announce(message, conn, chan); @@ -49,17 +51,17 @@ def poll(inp, conn=None, chan=None, action=None, nick=None): announce(str(count) + " in total.", conn, chan); if ";" in args: if not os.path.exists("plock.txt"): - file("plock.txt", 'w').close() + open("plock.txt", 'w').close() else: return "There is a poll currently running, close it with @poll close first." - arguments = args.split(";") - store(inp); + arguments = args.split(";") + store(text); num = 0 tally = {}; for x in arguments: num = num + 1 tally[num] = 0; - print tally + print(tally) storetally(tally); return arguments; def store(data): @@ -76,14 +78,14 @@ def store(data): def retreive(): try: f = open("poll.txt", "r") - try: - # Read the entire contents of a file at once. - args = f.read() - finally: - f.close() - except IOError: - string = "Could not read file." - arguments = args.split(";") + try: + # Read the entire contents of a file at once. + args = f.read() + finally: + f.close() + except IOError: + string = "Could not read file." + arguments = args.split(";") return arguments; def list(): @@ -97,14 +99,14 @@ def notice(text, conn, chan, nick, action=None): def storetally(tallydata): try: - # This tries to open an existing file but creates a new file if necessary. - with open('tally.pkl', 'wb') as output: + # This tries to open an existing file but creates a new file if necessary. + with open('tally.pkl', 'wb') as output: pickle.dump(tallydata, output, pickle.HIGHEST_PROTOCOL) - except IOError: - pass + except IOError: + pass def readtally(): - # This tries to open an existing file but creates a new file if necessary. - with open('tally.pkl', 'rb') as input: - tallydata = pickle.load(input) - return tallydata; + # This tries to open an existing file but creates a new file if necessary. + with open('tally.pkl', 'rb') as textut: + tallydata = pickle.load(textut) + return tallydata; diff --git a/rules.py b/rules.py index 5836ca5..f3069ba 100644 --- a/rules.py +++ b/rules.py @@ -1,9 +1,12 @@ -from util import hook +# RoboCop 2's rules.py - A rules command designed specifically for #techsupport on Snoonet (IRC) + +from cloudbot import hook @hook.command -def rules(inp, conn=None, chan=None): - if " " in inp: - command,user = inp.split(" ") +def rules(text, conn=None, chan=None): + """[spam|nick|nocoop|abuse|none] - rules command for #techsupport.""" + if " " in text: + command,user = text.split(" ") if command == "spam": return user + ": Your issue was too long. Go to http://pastebin.com and link your issue from there."; if command == "nick": @@ -13,7 +16,11 @@ def rules(inp, conn=None, chan=None): if command == "abuse": return user + ": Abusing the bot might cause you to be kicked from the channel, please refrain from it."; else: - if inp == "debug": + if text == "debug": conn.cmd("PRIVMSG " + chan + " This is a debug message. Thank you for listening."); else: - return inp + ": Welcome to #techsupport! | Do not ask for help or specific skills, just state your issue. | For verbose descriptions, use a pastebin or a link to your /r/techsupport thread. | Generic nicks must be changed by typing /nick . | Please be patient and don't spam."; + bienvenue = "Welcome to #techsupport! | Do not ask for help or specific skills, just state your issue. | For verbose descriptions, use a pastebin or a link to your /r/techsupport thread. | Generic nicks must be changed by typing /nick . | Please be patient and don't spam."; + if text == "": + return bienvenue; + else: + return text + ": " + bienvenue; diff --git a/turkey.py b/turkey.py index 277bdd2..8af80dd 100644 --- a/turkey.py +++ b/turkey.py @@ -1,18 +1,20 @@ +# RoboCop 2's turkey.py, written during Thanksgiving 2014. Serves some delicious stuff! +# Adapted from Original Robocop's turkey.py # coding=utf-8 import re import random -from util import hook +from cloudbot import hook cakes = ['oven-roasted turkey', 'honey-glazed ham', 'orange turkey', 'roast turkey', 'fried turkey', 'citrus-marinated turkey', 'honey-mustard glazed ham', 'baked ham', 'pork ham', 'honey glazed turkey'] @hook.command -def turkey(inp, action=None): +def turkey(text, action=None): """turkey - [Thanksgiving 2014] Serves some thanksgiving turkey (or ham).""" - inp = inp.strip() + text = text.strip() - if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()): + if not re.match("^[A-Za-z0-9_|.-\]\[]*$", text.lower()): return "Nope, no turkey for that user!" turkey_type = random.choice(cakes) @@ -21,4 +23,4 @@ def turkey(inp, action=None): method = random.choice(['makes', 'gives', 'gets', 'buys']) side_dish = random.choice(['mashed potatoes', 'pumpkin pie', 'squash soup', 'cranberry sauce']) - action("{} {} a {} {} {} and serves it with a side of {}!".format(method, inp, flavor, size, turkey_type, side_dish)) + action("{} {} a {} {} {} and serves it with a side of {}!".format(method, text, flavor, size, turkey_type, side_dish))