Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- from __future__ import print_function
- import re
- import urllib.request
- import xchat
- __module_name__ = "altwfc stats"
- __module_version__ = "0.01a"
- __module_description__ = "Checks the stats page for a gamecode [/stat]"
- print("\0034", __module_name__, __module_version__, "(/stat) loading...\003")
- def delayed_say(text, context):
- def on_timer(userdata):
- context.command("SAY " + text)
- return 0
- xchat.hook_timer(1, on_timer)
- def stat(word, word_eol, userdata):
- if re.search('(?:^!stat$|^!s$)', word[1], re.IGNORECASE):
- source = urllib.request.urlopen("http://104.131.93.87:9001").read().decode('utf-8')
- games = re.findall("<tr>\n +<td>(.+?)</td>\n +<td><center>(\d+)</center>", source)
- if len(games) == 0:
- s = 'No-one online.'
- delayed_say(s, xchat.get_context())
- else:
- s = ''
- for i in games:
- s += '{:}: {:}; '.format(*i)
- delayed_say(s[:-2], xchat.get_context())
- xchat.hook_print("Channel Message", stat)
- xchat.hook_print("Your Message", stat)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement