Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of https://github.com/renemilk/relayhost

Conflicts:
	Main.conf.example
  • Loading branch information...
commit afde9983d09a7345d3fced65507c6946c95f1efa 2 parents 1b71b53 + 31bc946
@BrainDamage authored
View
35 Main.conf.example
@@ -1,14 +1,25 @@
----the following things need to be added in addition to the basic config entries listed in tasbot's example config file
-plugins=channels,manager,help,lag,systemlog;
-slavesnick=account;
-slavespass=password;
-hostports=8400:8415,8500,8800:10000;
-ahports=12000:14000, 5000;
-bans=[][]aweres[],[P][E]aweres[E][T],[PinK]Aweres[t],HOMOTINTTI;
-keepscript=0;
+[tasbot]
+serveraddr=springrts.com;
+serverport=8200;
+nick=NICK;
+password=PASSWORD;
+plugins=join_channels,manager,help,lag,systemlog;
admins=YOURNICK,YOURNICK2;
-enabled=1;
-springdedpath=/path/to/it;
----bindip=; if this line is present, it will force spring-dec to bind to given interface
----springdatapath=; force springdatapath if present
+logfile=$HOME/logs/relayhost.log
+pidfile=$HOME/pids/relayhost.pid
+springdedpath=/path/to/it
+debug=1
+[autohost]
+slavesnick=account
+slavespass=password
+hostports=8400:8415,8500,8800:10000
+ahports=12000:14000, 5000
+bans=[][]aweres[],[P][E]aweres[E][T],[PinK]Aweres[t],HOMOTINTTI
+keepscript=0
+enabled=1
+#bindip=; if this line is present, it will force spring-dec to bind to given interface
+#springdatapath=; force springdatapath if present
+
+[join_channels]
+channels=autohost
View
2  README.markdown
@@ -2,5 +2,5 @@
* copy Main.conf.example to Main.conf
* edit Main.conf to fit login, admins, plugins, etc
- * make sure you got the tasbot package somewhere in your python module search path (PYTHONPATH)
* run ./main.py
+ * make sure you have tasbor in python path
View
88 autohost.py
@@ -1,14 +1,21 @@
# -*- coding: utf-8 -*-
-from tasbot.ParseConfig import *
-import commands,thread,signal,os,time
-import udpinterface,subprocess
-import platform,sys,traceback
-from tasbot.customlog import Log
+import commands
+import thread
+import signal
+import os
+import time
+import subprocess
+import platform
+import sys
+import traceback
if platform.system() == "Windows":
import win32api
+
from tasbot.utilities import *
+from tasbot.plugin import IPlugin
+from tasbot.customlog import Log
-from tasbot.Plugin import IPlugin
+import udpinterface
class Main(IPlugin):
def __init__(self,name,tasclient):
@@ -33,7 +40,8 @@ def __init__(self,name,tasclient):
self.redirectspring = False
self.redirectbattleroom = False
self.users = dict()
- self.logger.Debug( "INIT MoTH" )
+ self.logger.debug( "INIT MoTH" )
+
def ecb(self,event,data):
if self.redirectspring:
ags = []
@@ -44,16 +52,18 @@ def ecb(self,event,data):
else:
data2 += c
self.saypm(self.battleowner,"#"+str(event)+"#".join(ags)+" "+data2)
+
def onloggedin(self,socket):
self.hosted = 0
self.sock = socket
+
def mscb(self,p,msg):
try:
if p == self.battleowner:
if msg.startswith("!"):
self.u.sayingame("/"+msg[1:])
except Exception, e:
- self.logger.Except( e )
+ self.logger.exception(e)
exc = traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2])
self.sayex("*** EXCEPTION: BEGIN")
for line in exc:
@@ -61,7 +71,7 @@ def mscb(self,p,msg):
self.sayex("*** EXCEPTION: END")
def killbot(self):
- self.logger.Info( "setting force_quit True" )
+ self.logger.info( "setting force_quit True" )
self.app.force_quit = True
def timeoutthread(self):
@@ -69,7 +79,7 @@ def timeoutthread(self):
time.sleep(20.0)
try:
if not ( not self.noowner and self.hosted == 1) and not self.gamestarted:
- self.logger.Error("Timeouted hosting")
+ self.logger.error("Timeouted hosting")
self.killbot()
return
except:
@@ -87,13 +97,13 @@ def startspring(self,socket,g):
socket.send("MYSTATUS 1\n")
st = time.time()
#status,j = commands.getstatusoutput("spring-dedicated "+os.path.join(self.scriptbasepath,"%f.txt" % g ))
- self.sayex("*** Starting spring: command line \"%s\"" % (self.app.config["springdedpath"]+" "+os.path.join(self.scriptbasepath,"%f.txt" % g )))
+ self.sayex("*** Starting spring: command line \"%s\"" % (self.app.config.get('tasbot', "springdedpath")+" "+os.path.join(self.scriptbasepath,"%f.txt" % g )))
if platform.system() == "Windows":
- dedpath = "\\".join(self.app.config["springdedpath"].replace("/","\\").split("\\")[:self.app.config["springdedpath"].replace("/","\\").count("\\")])
+ dedpath = "\\".join(self.app.config.get('tasbot', "springdedpath").replace("/","\\").split("\\")[:self.app.config.get('tasbot', "springdedpath").replace("/","\\").count("\\")])
if not dedpath in sys.path:
sys.path.append(dedpath)
- if "springdatapath" in self.app.config:
- springdatapath = self.app.config["springdatapath"]
+ if self.app.config.has_option('tasbot', "springdatapath"):
+ springdatapath = self.app.config.get('tasbot', "springdatapath")
if not springdatapath in sys.path:
sys.path.append(springdatapath)
os.chdir(springdatapath)
@@ -101,7 +111,7 @@ def startspring(self,socket,g):
springdatapath = None
if springdatapath!= None:
os.environ['SPRING_DATADIR'] = springdatapath
- self.pr = subprocess.Popen((self.app.config["springdedpath"],os.path.join(self.scriptbasepath,"%f.txt" % g )),stdout=subprocess.PIPE,stderr=subprocess.STDOUT,cwd=springdatapath)
+ self.pr = subprocess.Popen((self.app.config.get('tasbot', "springdedpath"),os.path.join(self.scriptbasepath,"%f.txt" % g )),stdout=subprocess.PIPE,stderr=subprocess.STDOUT,cwd=springdatapath)
self.gamestarted = True
l = self.pr.stdout.readline()
while len(l) > 0:
@@ -127,7 +137,7 @@ def startspring(self,socket,g):
self.sayex(line)
self.sayex("*** EXCEPTION: END")
try:
- if int(self.app.config["keepscript"]) == 0:
+ if int(self.app.config.get('autohost', "keepscript")) == 0:
os.remove(os.path.join(self.scriptbasepath,"%f.txt" % g))
except:
pass
@@ -135,28 +145,29 @@ def startspring(self,socket,g):
self.gamestarted = False
if self.noowner == True:
self.sayex("The host is no longer in the battle, exiting")
- self.logger.Info("Exiting")
+ self.logger.info("Exiting")
self.killbot()
+
def onload(self,tasc):
try:
self.tasclient = tasc
self.app = tasc.main
self.hosttime = time.time()
- self.startThread(self.timeoutthread)
- self.u = udpinterface.UDPint(int(self.app.config["ahport"]),self.mscb,self.ecb)
+ self.start_thread(self.timeoutthread)
+ self.u = udpinterface.UDPint(int(self.app.config.get('autohost', "ahport")),self.mscb,self.ecb)
except Exception, e:
- self.logger.Except( e )
+ self.logger.exception(e)
def oncommandfromserver(self,command,args,s):
#print "From server: %s | Args : %s" % (command,str(args))
self.sock = s
if command == "RING" and len(args) > 0:
- s.send("RING " + self.app.config["spawnedby"] + "\n")
+ s.send("RING " + self.app.config.get('autohost', "spawnedby") + "\n")
if command == "CLIENTBATTLESTATUS" and len(args) > 0 and self.redirectbattleroom:
- self.saypm(self.app.config["spawnedby"], "!" + command + " " + " ".join(args[0:]) )
+ self.saypm(self.app.config.get('autohost', "spawnedby"), "!" + command + " " + " ".join(args[0:]) )
if command == "SAIDBATTLE" and len(args) > 0:
if self.redirectbattleroom:
- self.saypm(self.app.config["spawnedby"], "!" + command + " " + " ".join(args[0:]))
+ self.saypm(self.app.config.get('autohost', "spawnedby"), "!" + command + " " + " ".join(args[0:]))
if args[1].startswith("!") and args[0] == self.battleowner:
try:
msg = " ".join(args[1:])
@@ -167,16 +178,16 @@ def oncommandfromserver(self,command,args,s):
for line in exc:
self.sayex(line)
if command == "SAIDBATTLEEX" and len(args) > 0 and self.redirectbattleroom:
- self.saypm(self.app.config["spawnedby"], "!" + command + " " + " ".join(args[0:]))
+ self.saypm(self.app.config.get('autohost', "spawnedby"), "!" + command + " " + " ".join(args[0:]))
if command == "REQUESTBATTLESTATUS":
s.send( "MYBATTLESTATUS 4194816 255\n" )#spectator+synced/white
- if command == "SAIDPRIVATE" and args[0] not in self.app.config["bans"] and args[0] == self.app.config["spawnedby"]:
+ if command == "SAIDPRIVATE" and args[0] not in self.app.config.get('autohost', "bans") and args[0] == self.app.config.get('autohost', "spawnedby"):
if args[1] == "!openbattle" and not self.hosted == 1:
if len(args) < 6:
- self.logger.Error("Got invalid openbattle with params:"+" ".join(args))
+ self.logger.error("Got invalid openbattle with params:"+" ".join(args))
return
- args[5] = self.app.config["hostport"]
- self.logger.Info("OPENBATTLE "+" ".join(args[2:]))
+ args[5] = self.app.config.get('autohost',"hostport")
+ self.logger.info("OPENBATTLE "+" ".join(args[2:]))
s.send("OPENBATTLE "+" ".join(args[2:])+"\n")
self.battleowner = args[0]
return
@@ -279,11 +290,12 @@ def oncommandfromserver(self,command,args,s):
f = open(os.path.join(self.scriptbasepath,"%f.txt" % g),"a")
s1 = self.script.find("MyPlayerName=")
s2 = self.script[s1:].find(";")+1+s1
- self.script = self.script.replace(self.script[s1:s2],"MyPlayerName=%s;\n\tAutoHostPort=%i;" % (self.app.config["nick"],int(self.app.config["ahport"])))
+ self.script = self.script.replace(self.script[s1:s2],"MyPlayerName=%s;\n\tAutoHostPort=%i;" %
+ (self.app.config.get('tasbot', "nick"),int(self.app.config.get('autohost', "ahport"))))
s1 = self.script.find("HostIP=")
s2 = self.script[s1:].find(";")+1+s1
- if "bindip" in self.app.config:
- self.script = self.script.replace(self.script[s1:s2],"HostIP=%s;" % (self.app.config["bindip"]))
+ if self.app.config.has_option('autohost', "bindip"):
+ self.script = self.script.replace(self.script[s1:s2],"HostIP=%s;" % (self.app.config.get('autohost', "bindip")))
else:
self.script = self.script[0:s1] + self.script[s2:]
f.write(self.script)
@@ -348,19 +360,21 @@ def onloggedin(self,socket):
def saypm(self,p,m):
try:
- self.logger.Debug("PM To:%s, Message: %s" %(p,m))
+ self.logger.debug("PM To:%s, Message: %s" %(p,m))
self.tasclient.socket.send("SAYPRIVATE %s %s\n" %(p,m))
except Exception, e:
- self.logger.Except( e )
+ self.logger.exception(e)
+
def say(self,m):
try:
- self.logger.Debug("SAY autohost %s\n" % m)
+ self.logger.debug("SAY autohost %s\n" % m)
self.tasclient.socket.send("SAY autohost %s\n" % m)
except Exception, e:
- self.logger.Except( e )
+ self.logger.exception(e)
+
def sayex(self,m):
try:
- self.logger.Debug("SAYEX autohost %s\n" % m)
+ self.logger.debug("SAYEX autohost %s\n" % m)
self.tasclient.socket.send("SAYEX autohost %s\n" % m)
except Exception, e:
- self.logger.Except( e )
+ self.logger.exception(e)
View
11 channels.py
@@ -1,11 +0,0 @@
-from tasbot.Plugin import IPlugin
-
-class Main(IPlugin):
- def __init__(self,name,tasclient):
- IPlugin.__init__(self,name,tasclient)
- def onload(self,tasc):
- pass
- def oncommandfromserver(self,command,args,socket):
- pass
- def onloggedin(self,socket):
- socket.send("JOIN autohost\n")
View
2  help.py
@@ -1,6 +1,6 @@
import string
helptext = "Relayed Host Bot\n Documentation is at http://springlobby.info/wiki/1/HostManagerProtocol"
-from tasbot.Plugin import IPlugin
+from tasbot.plugin import IPlugin
class Main(IPlugin):
def __init__(self,name,tasclient):
View
11 lag.py
@@ -1,11 +0,0 @@
-from tasbot.ParseConfig import *
-from tasbot.Plugin import IPlugin
-
-class Main(IPlugin):
- def __init__(self,name,tasclient):
- IPlugin.__init__(self,name,tasclient)
- def onload(self,tasc):
- pass
- def oncommandfromserver(self,command,args,socket):
- if command == "SAIDPRIVATE" and len(args) > 1 and args[1] == "!lag":
- self.tasclient.socket("SAYPRIVATE %s %s\n" % ( args[0], str((self.app.lpo-self.app.lp)*1000) +" ms"))
View
19 main.py
@@ -1,22 +1,25 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import tasbot,sys,os
+import sys
+
+import tasbot
from tasbot.customlog import Log
-if __name__=="__main__":
- configfile = os.path.join( os.getcwd(), "Main.conf")
- config = tasbot.ParseConfig.Config(configfile)
- Log.Init( config['logfile'], 'debug', True )
+if __name__=="__main__":
+ tasbot.check_min_version((1,))
+ configfile = "Main.conf"
+ config = tasbot.config.Config(configfile)
+ Log.init( config.get('tasbot','logfile','relayhost.log'), 'info', True )
r = False
for arg in sys.argv:
if arg.strip() == "-r":
r = True
- Log.notice("Registering account")
- pidfile = config['pidfile']
+ Log.Notice("Registering account")
+ pidfile = config.get('tasbot','pidfile','relayhost.pid')
print 'using pidfile %s'%pidfile
inst = tasbot.DefaultApp(configfile,pidfile,r,True)
- if bool(config.GetSingleOption( 'debug', False )):
+ if int(config.get( 'tasbot','debug', 0 )):
inst.run()#exec in fg
else:
inst.start()
View
91 manager.py
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
-#from tasbot.ParseConfig import *
-import tasbot
+from ConfigParser import SafeConfigParser as ConfigParser
import commands
-from tasbot.customlog import Log
import thread
import os
import sys
@@ -14,18 +12,23 @@
if platform.system() == "Windows":
import win32api
+import tasbot
+from tasbot.customlog import Log
+from tasbot.plugin import IPlugin
+from tasbot.utilities import parselist
+
+
def parseportrange(arg):
separator = ":"
tempvariable = []
if ( arg.find( separator ) >= 0 ):
- extremes = tasbot.ParseConfig.parselist(arg,separator)
+ extremes = parselist(arg,separator)
for num in range( int(extremes[0]), int(extremes[1]) +1 ):
tempvariable.append(str(num))
else:
tempvariable.append(arg)
return tempvariable
-
-from tasbot.Plugin import IPlugin
+
class Main(IPlugin):
def __init__(self,name,tasclient):
@@ -39,26 +42,29 @@ def __init__(self,name,tasclient):
def botthread(self,slot,nick,s,r,p,ist):
try:
self.say_ah("Spawning (Requested by %s) " % r +nick)
- d = dict()
- d.update([("serveraddr",self.app.config["serveraddr"])])
- d.update([("spawnedby",r)])
- d.update([("serverport",self.app.config["serverport"])])
- d.update([("springdedpath",self.app.config["springdedpath"])])
- if "springdatapath" in self.app.config:
- d.update([("springdatapath",self.app.config["springdatapath"])])
- if "bindip" in self.app.config:
- d.update([("bindip",self.app.config["bindip"])])
- d.update([("admins",self.app.config["admins"])])
- d.update([("nick",nick)])
- d.update([("password",p)])
- d.update([("hostport",self.hostports[slot])])
- d.update([("ahport",self.controlports[slot])])
- d.update([("plugins","channels,autohost,help")])
- d.update([("bans",self.app.config["bans"])])
- d.update([("keepscript",self.app.config["keepscript"])])
cfg = "%s" % (nick+".cfg")
- cfg_path = os.path.join(self.app.config['cfg_dir'],cfg )
- tasbot.ParseConfig.writeconfigfile(cfg_path,d)
+ cfg_path = os.path.join(self.app.config.get('tasbot', 'cfg_dir'),cfg )
+ self.app.config.write(cfg_path)
+ slave_cfg = ConfigParser()
+ slave_cfg.read(cfg_path)
+
+ #d.update([("serveraddr",self.app.config["serveraddr"])])
+ #d.update([("admins",self.app.config["admins"])])
+ #d.update([("serverport",self.app.config["serverport"])])
+ #d.update([("springdedpath",self.app.config["springdedpath"])])
+ #if "springdatapath" in self.app.config:
+ #d.update([("springdatapath",self.app.config["springdatapath"])])
+ #if "bindip" in self.app.config:
+ #d.update([("bindip",self.app.config["bindip"])])
+ #d.update([("bans",self.app.config["bans"])])
+ #d.update([("keepscript",self.app.config["keepscript"])])
+ slave_cfg.set('autohost', "spawnedby", r)
+ slave_cfg.set('tasbot', "nick", nick)
+ slave_cfg.set('tasbot', "password", p)
+ slave_cfg.set('autohost', "hostport", self.hostports[slot])
+ slave_cfg.set('autohost', "ahport", self.controlports[slot])
+ slave_cfg.set('tasbot', "plugins", "join_channels,autohost,help")
+ slave_cfg.write(open(cfg_path, 'wb'))
#p = subprocess.Popen(("python","Main.py","-c", "%s" % (nick+".cfg")),stdout=sys.stdout)
inst = tasbot.DefaultApp( cfg_path, cfg_path+".pid", False, True)
@@ -75,40 +81,42 @@ def botthread(self,slot,nick,s,r,p,ist):
ist.updatestatus(s)
ist.botstatus[slot] = False
except Exception,e:
- self.logger.Except( e )
+ self.logger.exception(e)
+
def onload(self,tasc):
self.tasclient = tasc
self.bans = []
self.app = tasc.main
- self.bans = tasbot.ParseConfig.parselist(self.app.config["bans"],",")
+ self.bans = self.app.config.get_optionlist('autohost', "bans")
self.hostports = []
- for port in tasbot.ParseConfig.parselist(self.app.config["hostports"],","):
+ for port in self.app.config.get_optionlist('autohost', "hostports"):
self.hostports = self.hostports + parseportrange( port )
self.controlports = []
- for port in tasbot.ParseConfig.parselist(self.app.config["ahports"],","):
+ for port in self.app.config.get_optionlist('autohost', "ahports"):
self.controlports = self.controlports + parseportrange( port )
numhosts = min( len(self.hostports), len(self.controlports) ) # number of host is minimum between amount of free ports for host and amount of free ports for control
self.an = []
- basenick = self.app.config["slavesnick"]
+ basenick = self.app.config.get('autohost', "slavesnick")
for i in range( 1, numhosts + 1 ): # fill the list of host names with the format of basenick + slot number
self.an.append( basenick + str(i) )
- self.ap = self.app.config["slavespass"]
- self.disabled = not bool(int(self.app.config["enabled"]))
+ self.ap = self.app.config.get('autohost', "slavespass")
+ self.disabled = not bool(int(self.app.config.get('autohost', "enabled")))
for i in range( 0, numhosts ):
self.botstatus.update([(i,False)])
+
def oncommandfromserver(self,command,args,socket):
try:
if command == "SAIDPRIVATE" and len(args) == 2 and args[1] == "!enable" and args[0] in self.app.admins:
self.disabled = False
socket.send("MYSTATUS %i\n" % int(int(self.listfull)+int(self.disabled)*2))
socket.send("SAYPRIVATE %s %s\n" % (args[0],"Hosting new games enabled"))
- self.app.config["enabled"] = "1"
+ self.app.config.set('autohost', "enabled", "1")
self.app.SaveConfig()
elif command == "SAIDPRIVATE" and len(args) == 2 and args[1] == "!disable" and args[0] in self.app.admins:
self.disabled = True
socket.send("MYSTATUS %i\n" % int(int(self.listfull)+int(self.disabled)*2))
socket.send("SAYPRIVATE %s %s\n" % (args[0],"Hosting new games disabled"))
- self.app.config["enabled"] = "0"
+ self.app.config.set('autohost', "enabled", "0")
self.app.SaveConfig()
elif command == "SAIDPRIVATE" and len(args) == 2 and args[1] == "!listbans" and args[0] in self.app.admins:
x = 0
@@ -129,7 +137,7 @@ def oncommandfromserver(self,command,args,socket):
socket.send("SAYPRIVATE %s %s\n" % (args[0],b+" Banned"))
else:
socket.send("SAYPRIVATE %s %s\n" % (args[0],b+" is already banned"))
- self.app.config["bans"] = ','.join(self.bans)
+ self.app.config.set('autohost', "bans", ','.join(self.bans))
self.app.SaveConfig()
socket.send("SAYPRIVATE %s %s\n" % (args[0],"Done."))
elif command == "SAIDPRIVATE" and len(args) >= 3 and args[1] == "!unban" and args[0] in self.app.admins:
@@ -140,7 +148,7 @@ def oncommandfromserver(self,command,args,socket):
else:
self.bans.remove(b)
socket.send("SAYPRIVATE %s %s\n" % (args[0],b+" has been unbanned"))
- self.app.config["bans"] = ','.join(self.bans)
+ self.app.config.set('autohost', "bans", ','.join(self.bans))
self.app.SaveConfig()
socket.send("SAYPRIVATE %s %s\n" % (args[0],"Done."))
elif command == "SAIDPRIVATE" and len(args) == 2 and args[1] == "!registerall" and args[0] in self.app.admins:
@@ -187,14 +195,15 @@ def oncommandfromserver(self,command,args,socket):
win32api.TerminateProcess(handle, 0)
else:
os.kill(self.bots[args[1]],signal.SIGKILL)
- except:
- pass
- except:
+ except Exception, e:
+ Log.exception(e)
+ except Exception, e:
exc = traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2])
self.sayex_ah("*** EXCEPTION: BEGIN")
for line in exc:
self.sayex_ah(line)
self.sayex_ah("*** EXCEPTION: END")
+ Log.exception(e)
def updatestatus(self,socket):
socket.send("MYSTATUS %i\n" % int(int(self.listfull)+int(self.disabled)*2))
@@ -205,12 +214,12 @@ def onloggedin(self,socket):
def say_ah(self,message):
try:
self.tasclient.say("autohost", message)
- except:
+ except Exception:
pass
def sayex_ah(self,message):
try:
self.tasclient.sayex("autohost", message)
- except:
+ except Exception:
pass
View
13 systemlog.py
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
-from tasbot.ParseConfig import *
import time
import datetime
import os
import sys
from tasbot.customlog import Log
-from tasbot.Plugin import IPlugin
+from tasbot.plugin import IPlugin
class Main(IPlugin):
def __init__(self,name,tasclient):
@@ -16,13 +15,13 @@ def onload(self,tasc):
def oncommandfromserver(self,command,args,socket):
if command == "SAID" and args[0] == "autohost":
- self.logger.Debug("<%s> %s" % ( args[1] , " ".join(args[2:])))
+ self.logger.debug("<%s> %s" % ( args[1] , " ".join(args[2:])))
if command == "SAIDEX" and args[0] == "autohost":
- self.logger.Debug("* %s %s" % ( args[1] , " ".join(args[2:])))
+ self.logger.debug("* %s %s" % ( args[1] , " ".join(args[2:])))
if command == "JOINED" and args[0] == "autohost":
- self.logger.Info("** %s has joined the channel\n" % (args[1]))
+ self.logger.info("** %s has joined the channel\n" % (args[1]))
if command == "LEFT" and args[0] == "autohost":
- self.logger.Info("** %s has left the channel ( %s )\n" % ( args[1] , " ".join(args[2:])))
+ self.logger.info("** %s has left the channel ( %s )\n" % ( args[1] , " ".join(args[2:])))
def onloggedin(self,socket):
- self.logger.Info("********** CONNECTED ***********\n")
+ self.logger.info("********** CONNECTED ***********\n")
View
10 udpinterface.py
@@ -11,13 +11,14 @@ def __init__(self,port,messagecb,eventcb):
self.players = dict()
self.addr = ""
thread.start_new_thread(self.mainloop,(messagecb,eventcb))
- Log.Info("UDP Listening on port "+str(port))
+ Log.info("UDP Listening on port "+str(port))
+
def reset(self):
self.players = dict()
+
def mainloop(self,messagecb,eventcb):
while 1:
try:
-
data, address = self.s.recvfrom(8192)
self.addr = address
event = ord(data[0])
@@ -35,10 +36,11 @@ def mainloop(self,messagecb,eventcb):
self.sayingame("/kill")
eventcb(ord(data[0]),data[1:])
except Exception, e:
- Log.Except( e )
+ Log.exception( e )
+
def sayingame(self,text):
#print "Sending %s to spring" % text
try:
self.s.sendto(text,self.addr)
except Exception, e:
- Log.Except( e )
+ Log.exception( e )
Please sign in to comment.
Something went wrong with that request. Please try again.