diff --git a/cloudbot.py b/cloudbot.py index e077734..43d6367 100755 --- a/cloudbot.py +++ b/cloudbot.py @@ -7,8 +7,8 @@ import time import signal # check python version -if sys.version_info < (2, 7, 0): - print("CloudBot requires Python 2.7 or newer.") +if sys.version_info < (3, 2, 0): + print("CloudBot3 requires Python 3.2 or newer.") sys.exit(1) # set up enviroment @@ -18,10 +18,10 @@ os.chdir(sys.path[0] or '.') # do stuff relative to the install directory if os.path.exists(os.path.abspath('lib')): sys.path += ['lib'] -print('CloudBot2 ') +print('CloudBot3 ') def exit_gracefully(signum, frame): - # this doesn't really work that well + # this doesn't really work at all cloudbot.stop() # restore the original handler so if they do it again it triggers @@ -42,6 +42,7 @@ while True: else: if cloudbot.do_restart: # create a new bot thread and start it + # THIS DOES NOT WORK del cloudbot cloudbot = bot.Bot() cloudbot.start() diff --git a/plugins/github.py b/plugins/github.py index a3f054d..c7e5d63 100644 --- a/plugins/github.py +++ b/plugins/github.py @@ -37,7 +37,7 @@ def ghissues(inp): except IndexError: return "Invalid syntax. .github issues username/repo [number]" try: - url += "/%s" % args[1] + url += "/{}".format(args[1]) number = True except IndexError: number = False diff --git a/plugins/help.py b/plugins/help.py index 3cb9f30..5aed73b 100644 --- a/plugins/help.py +++ b/plugins/help.py @@ -41,8 +41,8 @@ def help_command(inp, notice=None, conn=None, bot=None): if len(out) > 1: for x in out[1:]: notice(x) - notice("For detailed help, do '%shelp ' where " - "is the name of the command you want help for." % conn.conf["command_prefix"]) + notice("For detailed help, do '{}help ' where " + "is the name of the command you want help for.".format(conn.conf["command_prefix"])) else: if inp in commands: diff --git a/plugins/horoscope.py b/plugins/horoscope.py index 5ccb0f0..8f8e6b3 100644 --- a/plugins/horoscope.py +++ b/plugins/horoscope.py @@ -46,7 +46,7 @@ def horoscope(inp, db=None, notice=None, nick=None): title = soup.find_all('h1', {'class': 'h1b'})[1] horoscope_text = soup.find('div', {'class': 'fontdef1'}) - result = "\x02%s\x02 %s" % (title, horoscope_text) + result = "\x02{}\x02 {}".format(title, horoscope_text) result = text.strip_html(result) #result = unicode(result, "utf8").replace('flight ','') diff --git a/plugins/snopes.py b/plugins/snopes.py index 9850a68..5dadaf7 100644 --- a/plugins/snopes.py +++ b/plugins/snopes.py @@ -25,8 +25,8 @@ def snopes(inp): if status is not None: status = status.group(0).strip() else: # new-style statuses - status = "Status: %s." % re.search(r"FALSE|TRUE|MIXTURE|UNDETERMINED", - snopes_text).group(0).title() + status = "Status: {}.".format(re.search(r"FALSE|TRUE|MIXTURE|UNDETERMINED", + snopes_text).group(0).title()) claim = re.sub(r"[\s\xa0]+", " ", claim) # compress whitespace status = re.sub(r"[\s\xa0]+", " ", status) diff --git a/plugins/spotify.py b/plugins/spotify.py index 4d44c80..4af2b1f 100644 --- a/plugins/spotify.py +++ b/plugins/spotify.py @@ -24,8 +24,8 @@ def sptfy(inp, sptfy=False): link = soup.find('div', {'class': 'resultLink'}).text.strip() return link except: - message = "Unable to shorten URL: %s" % \ - soup.find('div', {'class': 'messagebox_text'}).find('p').text.split("
")[0] + message = "Unable to shorten URL: {}".format(soup.find('div', { + 'class': 'messagebox_text'}).find('p').text.split("
")[0]) return message else: return web.try_isgd(inp) diff --git a/plugins/urban.py b/plugins/urban.py index cea57db..77c391d 100644 --- a/plugins/urban.py +++ b/plugins/urban.py @@ -41,7 +41,6 @@ def urban(inp): url = definitions[id_num - 1]['permalink'] - output = "[%i/%i] %s :: %s" % \ - (id_num, len(definitions), definition, url) + output = "[{}/{}] {} :: {}".format(id_num, len(definitions), definition, url) return output diff --git a/plugins/xkcd.py b/plugins/xkcd.py index f4490d7..6ec286c 100644 --- a/plugins/xkcd.py +++ b/plugins/xkcd.py @@ -11,10 +11,10 @@ months = {1: 'January', 2: 'February', 3: 'March', 4: 'April', 5: 'May', 6: 'Jun def xkcd_info(xkcd_id, url=False): """ takes an XKCD entry ID and returns a formatted string """ data = http.get_json("http://www.xkcd.com/" + xkcd_id + "/info.0.json") - date = "%s %s %s" % (data['day'], months[int(data['month'])], data['year']) + date = "{} {} {}".format(data['day'], months[int(data['month'])], data['year']) if url: url = " | http://xkcd.com/" + xkcd_id.replace("/", "") - return "xkcd: \x02%s\x02 (%s)%s" % (data['title'], date, url if url else "") + return "xkcd: \x02{}\x02 ({}){}".format(data['title'], date, url if url else "") def xkcd_search(term): diff --git a/plugins/youtube.py b/plugins/youtube.py index e8094f3..27d68e0 100644 --- a/plugins/youtube.py +++ b/plugins/youtube.py @@ -134,4 +134,4 @@ def ytplaylist_url(match): author = soup.find('img', {'class': 'channel-header-profile-image'})['title'] num_videos = soup.find('ul', {'class': 'header-stats'}).findAll('li')[0].text.split(' ')[0] views = soup.find('ul', {'class': 'header-stats'}).findAll('li')[1].text.split(' ')[0] - return "\x02%s\x02 - \x02%s\x02 views - \x02%s\x02 videos - \x02%s\x02" % (title, views, num_videos, author) + return "\x02{}\x02 - \x02{}\x02 views - \x02{}\x02 videos - \x0{}\x02".format(title, views, num_videos, author) diff --git a/util/web.py b/util/web.py index 2b4aba8..67ea94f 100644 --- a/util/web.py +++ b/util/web.py @@ -23,7 +23,7 @@ def isgd(url): """ shortens a URL with the is.gd API """ url = urlnorm.normalize(url.encode('utf-8'), assume_scheme='http') params = urllib.parse.urlencode({'format': 'json', 'url': url}) - request = http.get_json("http://is.gd/create.php?%s" % params) + request = http.get_json("http://is.gd/create.php?{}".format(params)) if "errorcode" in request: raise ShortenError(request["errorcode"], request["errormessage"])