This module is useful for users to display the latest server issues regarding their region’s server for League of Legends.
It requires 2 libraries that should already have came with Python (urllib2 and json).
Syntax is pretty simple: !status [region] – it will display the English translation if there is one. It grabs the status directly from Riot’s site http://status.leagueoflegends.com. So whatever you see there is what the bot will pull (always grabs the latest update under Game Section)
This module will be included in version 1.2 of the bot when it is released as well.
Simply copy and paste the code below into a new file or download my copy which can be found below the code.
import urllib2 import json def on_load(bot): bot.add_command('status', status) def on_exit(bot): bot.del_command('status') def status(bot, user, channel, args): if len(args) < 1: return shard = 'http://status.leagueoflegends.com/shards/' region = args.lower() full_url = shard + region response = urllib2.urlopen(full_url) json_response = response.read() incidents = json_response.count("content") - 1 readable_json = json.loads(json_response) try: content = str(readable_json['services']['incidents']['updates']['content'].encode('utf8')) except: content = "There are no reported issues at this time." content_replace = content.replace('rn', "") bot.send_msg(channel, "%s Server Status: %s" % (region.upper(), content_replace))