From 1363e274750c4adbefbd54e357cc9fcc3ec72345 Mon Sep 17 00:00:00 2001 From: Fletcher Boyd Date: Sat, 7 Sep 2013 17:10:16 +0800 Subject: [PATCH 1/4] Added bot modes to the default config. --- config.default | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config.default b/config.default index c3f99a1..6000338 100644 --- a/config.default +++ b/config.default @@ -60,5 +60,6 @@ [ "mypass", "mysecret" - ] + ], + "mode" = "" } From 5efca90faa0c95f98cdb6491a6ac0d164fdde6af Mon Sep 17 00:00:00 2001 From: Fletcher Boyd Date: Sat, 7 Sep 2013 19:07:22 +0800 Subject: [PATCH 2/4] Good catch there luke. --- config.default | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.default b/config.default index 6000338..a13f1fe 100644 --- a/config.default +++ b/config.default @@ -7,6 +7,7 @@ "nick": "MyCloudBot", "user": "cloudbot", "realname": "CloudBot - http://git.io/cloudbotirc", + "mode": "", "nickserv_password": "", "nickserv_user": "", "channels": ["#cloudbot", "#cloudbot2"], @@ -60,6 +61,5 @@ [ "mypass", "mysecret" - ], - "mode" = "" + ] } From efee5072ad35686c07be00c8b85fc38fcebee3aa Mon Sep 17 00:00:00 2001 From: Fletcher Boyd Date: Sat, 7 Sep 2013 23:44:27 +0800 Subject: [PATCH 3/4] ily --- plugins/steam_calc.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/steam_calc.py b/plugins/steam_calc.py index 10d7f8a..99be329 100644 --- a/plugins/steam_calc.py +++ b/plugins/steam_calc.py @@ -1,6 +1,5 @@ from util import hook, http import csv -import time import StringIO gauge_url = "http://www.mysteamgauge.com/search?username={}" @@ -38,7 +37,7 @@ def steamcalc(inp, reply=None): except (http.HTTPError, http.URLError): return "Could not get data for this user." - csv_data = StringIO.StringIO(request) # we use StringIO because CSV can't read a string + csv_data = StringIO.StringIO(request) # we use StringIO because CSV can't read a string reader = unicode_dictreader(csv_data) # put the games in a list @@ -53,11 +52,11 @@ def steamcalc(inp, reply=None): data["name"] = steam_profile.find('steamID').text online_state = steam_profile.find('stateMessage').text - data["state"] = online_state.replace("
", ": ") # will make this pretty later + data["state"] = online_state.replace("
", ": ") # will make this pretty later # work out the average metascore for all games ms = [float(game["metascore"]) for game in games if is_number(game["metascore"])] - metascore = float(sum(ms))/len(ms) if len(ms) > 0 else float('nan') + metascore = float(sum(ms)) / len(ms) if len(ms) > 0 else float('nan') data["average_metascore"] = "{0:.1f}".format(metascore) # work out the totals @@ -76,11 +75,10 @@ def steamcalc(inp, reply=None): if game["unit"] == "GB": total_size += float(game["size"]) else: - total_size += float(game["size"])/1024 + total_size += float(game["size"]) / 1024 data["size"] = "{0:.1f}".format(total_size) - return "{name} ({state}) has {games} games with a total value of ${value}" \ " and a total size of {size}GB! The average metascore for these" \ " games is {average_metascore}.".format(**data) From 803ca5da9a8dbd576062962a3efd06c38874553a Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Mon, 9 Sep 2013 13:27:18 +0800 Subject: [PATCH 4/4] Re-add portal2sounds plugin Now with 100% less portal2sounds.com interaction! --- plugins/p2sounds.py | 80 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 plugins/p2sounds.py diff --git a/plugins/p2sounds.py b/plugins/p2sounds.py new file mode 100644 index 0000000..3d7d93f --- /dev/null +++ b/plugins/p2sounds.py @@ -0,0 +1,80 @@ +from util import hook, http, web +import json +from urllib2 import HTTPError + + +def getSoundInfo(game, search): + search = search.replace(" ", "+") + try: + data = http.get_json("http://p2sounds.blha303.com.au/search/%s/%s" % (game, search)) + except HTTPError as e: + return "Error: " + json.loads(e.read())["error"] + items = [] + for i in data: + items.append("{} - {} {}".format(i["who"], + i["text"] if len(i["text"]) < 325 else i["text"][:325] + "...", + i["listen"] ) ) + if len(items) == 1: + return items[0] + else: + return "{} (and {} others: {})".format(items[0], len(items) - 1, web.haste("\n".join(items)) ) + + +@hook.command +def portal2(inp): + """portal2 - Look up Portal 2 quote. + Example: .portal2 demand to see life's manager""" + return getSoundInfo("portal2", inp) + + +@hook.command +def portal2dlc(inp): + """portal2dlc - Look up Portal 2 DLC quote. + Example: .portal2dlc1 these exhibits are interactive""" + return getSoundInfo("portal2dlc1", inp) + + +@hook.command("portal2pti") +@hook.command +def portal2dlc2(inp): + """portal2dlc2 - Look up Portal 2 Perpetual Testing Inititive quote. + Example: .portal2 Cave here.""" + return getSoundInfo("portal2dlc2", inp) + + +@hook.command +def portal2music(inp): + """portal2music - Look up Portal 2 music. + Example: .portal2music turret opera""" + return getSoundInfo("portal2music", inp) + + +@hook.command('portal1') +@hook.command +def portal(inp): + """portal <quote> - Look up Portal quote. + Example: .portal The last thing you want to do is hurt me""" + return getSoundInfo("portal1", inp) + + +@hook.command('portal1music') +@hook.command +def portalmusic(inp): + """portalmusic <title> - Look up Portal music. + Example: .portalmusic still alive""" + return getSoundInfo("portal1music", inp) + + +@hook.command('tf2sound') +@hook.command +def tf2(inp): + """tf2 [who - ]<quote> - Look up TF2 quote. + Example: .tf2 may i borrow your earpiece""" + return getSoundInfo("tf2", inp) + + +@hook.command +def tf2music(inp): + """tf2music title - Look up TF2 music lyrics. + Example: .tf2music rocket jump waltz""" + return getSoundInfo("tf2music", inp)