module formatting tweaks; tabs -> spaces and more
parent
733d3fd39e
commit
56f116732d
|
@ -49,4 +49,3 @@ eightball.commands = ['8ball']
|
|||
|
||||
if __name__ == '__main__':
|
||||
print(__doc__.strip())
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ Licensed under the Eiffel Forum License 2.
|
|||
http://inamidst.com/phenny/
|
||||
|
||||
modified from Wikipedia module
|
||||
author: mutantmonkey <mutantmonkey@gmail.com>
|
||||
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
||||
"""
|
||||
|
||||
import re, urllib.request, urllib.parse, urllib.error
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python2
|
||||
"""
|
||||
botfight.py - .botfight module
|
||||
author: mutantmonkey <mutantmonkey@gmail.com>
|
||||
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
||||
"""
|
||||
|
||||
import random
|
||||
|
@ -23,4 +23,3 @@ bothug.priority = 'low'
|
|||
|
||||
if __name__ == '__main__':
|
||||
print(__doc__.strip())
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python2
|
||||
"""
|
||||
botsnack.py - .botsnack module (aka simulated hunger 1.0)
|
||||
author: mutantmonkey <mutantmonkey@gmail.com>
|
||||
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
||||
author: Casey Link <unnamedrambler@gmail.com>
|
||||
|
||||
This module simulates bot hunger and provides a mechanism
|
||||
|
@ -107,4 +107,3 @@ botsnack.coolingdown = False
|
|||
|
||||
if __name__ == '__main__':
|
||||
print(__doc__.strip())
|
||||
|
||||
|
|
|
@ -34,4 +34,3 @@ fcc.rule = (['fcc'], r'(.*)')
|
|||
|
||||
if __name__ == '__main__':
|
||||
print(__doc__.strip())
|
||||
|
||||
|
|
|
@ -58,4 +58,3 @@ hs.rule = (['hs'], r'(.*)')
|
|||
|
||||
if __name__ == '__main__':
|
||||
print(__doc__.strip())
|
||||
|
||||
|
|
|
@ -32,4 +32,3 @@ linx.rule = (['linx'], r'(.*)')
|
|||
|
||||
if __name__ == '__main__':
|
||||
print(__doc__.strip())
|
||||
|
||||
|
|
|
@ -149,4 +149,3 @@ mlit.commands = ['mlit']
|
|||
|
||||
if __name__ == '__main__':
|
||||
print(__doc__.strip())
|
||||
|
||||
|
|
|
@ -10,9 +10,7 @@ def nsfw(phenny, input):
|
|||
phenny.say(".nsfw <link> - for when a link isn't safe for work")
|
||||
return
|
||||
phenny.say("!!NSFW!! -> %s <- !!NSFW!!" % (link))
|
||||
|
||||
nsfw.rule = (['nsfw'], r'(.*)')
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(__doc__.strip())
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python3
|
||||
"""
|
||||
tfw.py - the fucking weather module
|
||||
author: mutantmonkey <mutantmonkey@gmail.com>
|
||||
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
||||
"""
|
||||
|
||||
from urllib.parse import quote as urlquote
|
||||
|
@ -82,4 +82,3 @@ tfwc.rule = (['tfwc'], r'(.*)')
|
|||
|
||||
if __name__ == '__main__':
|
||||
print(__doc__.strip())
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ Licensed under the Eiffel Forum License 2.
|
|||
http://inamidst.com/phenny/
|
||||
|
||||
modified from Wikipedia module
|
||||
author: mutantmonkey <mutantmonkey@gmail.com>
|
||||
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
||||
"""
|
||||
|
||||
import re, urllib.request, urllib.parse, urllib.error
|
||||
|
|
|
@ -37,4 +37,3 @@ urbandict.rule = (['urb'], r'(.*)')
|
|||
|
||||
if __name__ == '__main__':
|
||||
print(__doc__.strip())
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ Licensed under the Eiffel Forum License 2.
|
|||
http://inamidst.com/phenny/
|
||||
|
||||
modified from Wikipedia module
|
||||
author: mutantmonkey <mutantmonkey@gmail.com>
|
||||
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
||||
"""
|
||||
|
||||
import re, urllib.request, urllib.parse, urllib.error
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
#!/usr/bin/python2
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
wargame.py - wargame module for the vtluug wargame
|
||||
http://wargame.vtluug.org
|
||||
author: Casey Link <unnamedrambler@gmail.com>
|
||||
"""
|
||||
|
||||
import random
|
||||
|
||||
import configparser, os
|
||||
from urllib.parse import quote as urlquote
|
||||
from urllib.request import urlopen
|
||||
from urllib.error import HTTPError
|
||||
from lxml import etree
|
||||
from lxml import objectify
|
||||
from datetime import datetime
|
||||
import re
|
||||
|
||||
|
||||
APIURL = "http://wargame.vtluug.org/scoreboard.xml"
|
||||
|
||||
class server(object):
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.players = []
|
||||
def __str__(self):
|
||||
s = "%s - %d players: " %(self.name, len(self.players))
|
||||
s += ", ".join([str(p) for p in self.players])
|
||||
return s
|
||||
|
||||
class player(object):
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.score = "-1"
|
||||
self.isOwner = False
|
||||
def __str__(self):
|
||||
return "%s%s: %s points" %(self.name, " (Current King)" if self.isOwner else "", self.score)
|
||||
def __cmp__(self, other):
|
||||
if int(self.score) < int(other.score):
|
||||
return -1
|
||||
elif int(self.score) == int(other.score):
|
||||
return 0
|
||||
else:
|
||||
return 1
|
||||
|
||||
|
||||
def parse_player(player_element):
|
||||
p = player( player_element.attrib.get("name") )
|
||||
p.score = player_element.attrib.get("score")
|
||||
p.isOwner = player_element.attrib.get("isOwner") == "True"
|
||||
return p
|
||||
|
||||
def parse_server(server_element):
|
||||
s = server( server_element.name.text )
|
||||
for player_e in server_element.players.player:
|
||||
s.players.append( parse_player( player_e ) )
|
||||
s.players.sort()
|
||||
s.players.reverse()
|
||||
return s
|
||||
|
||||
def wargame(phenny, input):
|
||||
|
||||
if input.group(2) is not None:
|
||||
rest = input.group(2)
|
||||
m = re.match("^scores\s+(\S+)\s*$",rest)
|
||||
if m is not None and len( m.groups() ) == 1:
|
||||
return wargame_scores(phenny, m.group(1))
|
||||
m = re.match("^scores\s*$",rest)
|
||||
if m is not None:
|
||||
return wargame_scores(phenny, "Total")
|
||||
m = re.match("^help\s*$",rest)
|
||||
if m is not None:
|
||||
phenny.say("VTLUUG King of the Root - http://wargame.vtluug.org'")
|
||||
phenny.say("syntax: '.wargame' to see network status and target list'")
|
||||
phenny.say("syntax: '.wargame scores <target name>' to get current scores for a target'")
|
||||
return
|
||||
else:
|
||||
phenny.say("hmm.. I don't know what you mean. try '.wargame help'")
|
||||
return
|
||||
try:
|
||||
req = urlopen(APIURL)
|
||||
except HTTPError as e:
|
||||
phenny.say("uhoh. try again later, mmkay?")
|
||||
return
|
||||
root = objectify.parse(req).getroot()
|
||||
online = root.attrib.get("online") == "True"
|
||||
updated = root.attrib.get("updated")
|
||||
|
||||
servers = []
|
||||
for server_e in root.servers.server:
|
||||
servers.append( parse_server( server_e ) )
|
||||
|
||||
phenny.say( "wargame network is %s. last updated %s. available targets: %s" % ( "ONLINE" if online else "OFFLINE", updated, ", ".join([s.name for s in servers])) )
|
||||
def wargame_scores(phenny, s_name):
|
||||
try:
|
||||
req = urlopen(APIURL)
|
||||
except HTTPError as e:
|
||||
phenny.say("uhoh. try again later, mmkay?")
|
||||
return
|
||||
root = objectify.parse(req).getroot()
|
||||
online = root.attrib.get("online") == "True"
|
||||
updated = root.attrib.get("updated")
|
||||
|
||||
servers = {}
|
||||
for server_e in root.servers.server:
|
||||
s = parse_server( server_e )
|
||||
servers[s.name] = s
|
||||
if not s_name in servers:
|
||||
phenny.say("sorry, i couldn't find %s" % ( s_name ))
|
||||
return
|
||||
|
||||
phenny.say( str(servers[s_name]) )
|
||||
|
||||
|
||||
wargame.commands = ['wargame']
|
Loading…
Reference in New Issue