]> jfr.im git - erebus.git/blobdiff - modules/twitch.py
test
[erebus.git] / modules / twitch.py
index 68e6586a037a65752ec2264e2412766073563499..ba7e81f5cede41ee80ee91fd12a2e28b43803cc8 100644 (file)
@@ -1,10 +1,10 @@
-# Erebus IRC bot - Author: Conny Sjoblom
-# Spotify URL Checker
+# Erebus IRC bot - Author: Erebus Team
+# Twitch URL Checker
 # This file is released into the public domain; see http://unlicense.org/
 
 # module info
 modinfo = {
-       'author': 'Conny Sjoblom',
+       'author': 'Erebus Team',
        'license': 'public domain',
        'compatible': [1], # compatible module API versions
        'depends': [], # other modules required to work properly?
@@ -20,39 +20,12 @@ modstop = lib.modstop
 import re
 import urllib2
 import json
-from BeautifulSoup import BeautifulSoup
 
 checkfor = "twitch"
-hostmask_regex = re.compile('^(.*)!(.*)@(.*)$')
 url_regex = re.compile('(http|ftp|https):\/\/([\w\-_]+(?:(?:\.[\w\-_]+)+))([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?')
-def parser_hostmask(hostmask):
-       if isinstance(hostmask, dict):
-               return hostmask
-
-       nick = None
-       user = None
-       host = None
-
-       if hostmask is not None:
-               match = hostmask_regex.match(hostmask)
-
-               if not match:
-                       nick = hostmask
-               else:
-                       nick = match.group(1)
-                       user = match.group(2)
-                       host = match.group(3)
-
-       return {
-               'nick': nick,
-               'user': user,
-               'host': host
-       }
 
 @lib.hooknum("PRIVMSG")
 def privmsg_hook(bot, line):
-       sender = parser_hostmask(line[1:line.find(' ')])
-
        try:
                linetx = line.split(None, 3)[3][1:]
        except IndexError:
@@ -67,6 +40,6 @@ def privmsg_hook(bot, line):
                        respdata = urllib2.urlopen(url).read()
                        twitch = json.loads(respdata)
                        try:
-                               bot.msg(line.split()[2], 'Twitch: %s (%s)' % (twitch[0]['channel']['status'], twitch[0]['channel']['meta_game']))
+                               bot.msg(line.split()[2], 'Twitch: %s (%s playing %s)' % (twitch[0]['channel']['status'], twitch[0]['channel']['login'], twitch[0]['channel']['meta_game']))
                        except:
                                bot.msg(line.split()[2], 'Twitch: Channel offline.')