@@ -0,0 +1,2256 @@
+from bs4 import BeautifulSoup%0Afrom plugin import CommandPlugin%0Aimport requests%0Aimport json%0A%0A%0Aclass PlayingMaps(CommandPlugin):%0A    %22%22%22%0A    Parses Overcast's maps page and prints currently playing maps%0A    %22%22%22%0A%0A    ocn_maps_link = 'https://oc.tc/maps'%0A%0A    def __init__(self):%0A        CommandPlugin.__init__(self)%0A        self.triggers = %5B'playingmaps'%5D%0A        self.short_help = 'Prints out currently playing maps on the Overcast Network'%0A        self.help = self.short_help%0A        self.help_example = %5B'!playingmaps'%5D%0A%0A    @staticmethod%0A    def build_slack_attachment(data):%0A%0A        attach = %7B%0A            'title': 'Overcast Network - Currently playing maps',%0A            'text': '',%0A            'mrkdwn_in': %5B'text'%5D,%0A            'title_link': PlayingMaps.ocn_maps_link%0A        %7D%0A%0A        for server in sorted(data.keys()):%0A            attach%5B'text'%5D += '*%25s:* ' %25 server%0A            attach%5B'text'%5D += ', '.join(data%5Bserver%5D)%0A            attach%5B'text'%5D += '%5Cn'%0A%0A        return attach%0A%0A    @staticmethod%0A    def parse_maps_list():%0A        r = requests.get(PlayingMaps.ocn_maps_link)%0A%0A        if r.status_code != requests.codes.ok:%0A            return%0A%0A        soup = BeautifulSoup(r.text)%0A%0A        # Key: Server Name%0A        # Value: List of currently playing maps%0A        data = %7B%7D%0A        maps_elements = soup.find_all('div', class_='map thumbnail')%0A        for map in maps_elements:%0A            map_name = map.find('h1', class_='lead').a.contents%5B0%5D%0A%0A            # Wrapper around server labels%0A            servers_div = map.find('div', class_='servers')%0A            # Labels of playing servers%0A            playing_on = servers_div.find_all('a', class_='label label-warning')%0A            for server in playing_on:%0A                server_name = server.contents%5B0%5D%0A                # Check if server is not in dictionary%0A                if not data.get(server_name):%0A                    data%5Bserver_name%5D = %5B%5D%0A                data%5Bserver_name%5D.append(map_name)%0A%0A        # Return slack attachment with parsed data%0A        return PlayingMaps.build_slack_attachment(data)%0A%0A    def on_command(self, bot, event, response):%0A        response.update(attachments=json.dumps(%5BPlayingMaps.parse_maps_list()%5D))%0A        bot.sc.api_call('chat.postMessage', **response)%0A

Add command for listing playing OCN maps