mirror of
https://github.com/wr34k/IRCUFC.git
synced 2024-11-22 07:26:39 +00:00
Fixed status command + log module
This commit is contained in:
parent
2e6e55a499
commit
b021bd8ae8
6
fight.py
6
fight.py
@ -100,6 +100,11 @@ class Fight(object):
|
|||||||
|
|
||||||
|
|
||||||
def getStatus(self, nick):
|
def getStatus(self, nick):
|
||||||
|
if self.state == 'inactive':
|
||||||
|
self.IRC.privmsg(nick, "Standby, waiting for a fight to start...")
|
||||||
|
elif self.state == 'waiting_fighter':
|
||||||
|
self.IRC.privmsg(nick, "Waiting for 2nd opponent, type {}fight to register for the next fight!".format(self.IRC.optkey))
|
||||||
|
else:
|
||||||
for f in self.fighters:
|
for f in self.fighters:
|
||||||
if f.nick == nick:
|
if f.nick == nick:
|
||||||
self.IRC.privmsg(nick, "Status for {} -> Current health: {} | Current stance: {} | Next action: {}".format(f.nick, f.hp, f.stance, f.nextAction))
|
self.IRC.privmsg(nick, "Status for {} -> Current health: {} | Current stance: {} | Next action: {}".format(f.nick, f.hp, f.stance, f.nextAction))
|
||||||
@ -107,7 +112,6 @@ class Fight(object):
|
|||||||
self.IRC.privmsg(nick, "Status for {} -> Current health: {} | Current stance: {}".format(f.nick, f.hp, f.stance))
|
self.IRC.privmsg(nick, "Status for {} -> Current health: {} | Current stance: {}".format(f.nick, f.hp, f.stance))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def fightOver(self):
|
def fightOver(self):
|
||||||
winner = self.fighters[0] if self.fighters[1].hp <= 0 else self.fighters[1]
|
winner = self.fighters[0] if self.fighters[1].hp <= 0 else self.fighters[1]
|
||||||
looser = self.fighters[0] if self.fighters[0].hp <= 0 else self.fighters[1]
|
looser = self.fighters[0] if self.fighters[0].hp <= 0 else self.fighters[1]
|
||||||
|
12
irc.py
12
irc.py
@ -85,6 +85,7 @@ class Irc(object):
|
|||||||
|
|
||||||
def listen(self):
|
def listen(self):
|
||||||
while True:
|
while True:
|
||||||
|
try:
|
||||||
if self.lag:
|
if self.lag:
|
||||||
self.lag=False
|
self.lag=False
|
||||||
data += self.sock.recv(1024).decode('utf-8', 'ignore')
|
data += self.sock.recv(1024).decode('utf-8', 'ignore')
|
||||||
@ -130,6 +131,17 @@ class Irc(object):
|
|||||||
host = line[0].split("@")[1]
|
host = line[0].split("@")[1]
|
||||||
self.handle_msg(line[2], self.isAdmin(line[0][1:]), nick, user, host, ' '.join(line[3:])[1:])
|
self.handle_msg(line[2], self.isAdmin(line[0][1:]), nick, user, host, ' '.join(line[3:])[1:])
|
||||||
|
|
||||||
|
except (UnicodeDecodeError, UnicodeEncodeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
self.log.warn("^C, Exiting...")
|
||||||
|
return
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
self.log.error("Exception in listen()", e)
|
||||||
|
pass
|
||||||
|
|
||||||
def join(self):
|
def join(self):
|
||||||
self.log.info("Now joining {} ...".format(self.channel))
|
self.log.info("Now joining {} ...".format(self.channel))
|
||||||
self.raw("JOIN {} {}".format(self.channel, self.chankey)) if self.chankey else self.raw("JOIN {}".format(self.channel))
|
self.raw("JOIN {} {}".format(self.channel, self.chankey)) if self.chankey else self.raw("JOIN {}".format(self.channel))
|
||||||
|
@ -55,6 +55,8 @@ class IrcCommands(object):
|
|||||||
self.IRC.raw(" ".join(args))
|
self.IRC.raw(" ".join(args))
|
||||||
|
|
||||||
|
|
||||||
|
if cmd == 'status':
|
||||||
|
self.fight.getStatus(chan)
|
||||||
|
|
||||||
if self.fight.state in ('inactive', 'waiting_fighter'):
|
if self.fight.state in ('inactive', 'waiting_fighter'):
|
||||||
if cmd == 'fight':
|
if cmd == 'fight':
|
||||||
@ -69,9 +71,6 @@ class IrcCommands(object):
|
|||||||
else:
|
else:
|
||||||
self.IRC.privmsg(self.IRC.channel, "{}".format(self.IRC.mirc.color("Not here retard your opponent can see your next move!", self.IRC.mirc.colors.LIGHTRED)))
|
self.IRC.privmsg(self.IRC.channel, "{}".format(self.IRC.mirc.color("Not here retard your opponent can see your next move!", self.IRC.mirc.colors.LIGHTRED)))
|
||||||
|
|
||||||
else:
|
|
||||||
if cmd == 'status':
|
|
||||||
self.fight.getStatus(chan)
|
|
||||||
|
|
||||||
self.IRC.flood_flag[chan] = False
|
self.IRC.flood_flag[chan] = False
|
||||||
self.IRC.flood_count[chan] = 0
|
self.IRC.flood_count[chan] = 0
|
||||||
|
4
log.py
4
log.py
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import traceback
|
||||||
|
|
||||||
class Colors(object):
|
class Colors(object):
|
||||||
class Format(object):
|
class Format(object):
|
||||||
@ -60,7 +61,7 @@ class Log(object):
|
|||||||
self.func = func
|
self.func = func
|
||||||
|
|
||||||
def construct(self, *args):
|
def construct(self, *args):
|
||||||
return "".join(a for a in args)
|
return "".join(args)
|
||||||
|
|
||||||
def info(self, msg):
|
def info(self, msg):
|
||||||
if self.debug:
|
if self.debug:
|
||||||
@ -75,3 +76,4 @@ class Log(object):
|
|||||||
self.func( self.construct( "[", self.colors.fg.LIGHTRED, "x", self.colors.fg.DEFAULT, "] ", msg ) )
|
self.func( self.construct( "[", self.colors.fg.LIGHTRED, "x", self.colors.fg.DEFAULT, "] ", msg ) )
|
||||||
if exception:
|
if exception:
|
||||||
self.func( self.construct( "[", self.colors.fg.LIGHTRED, "x", self.colors.fg.DEFAULT, "] ", str(exception) ) )
|
self.func( self.construct( "[", self.colors.fg.LIGHTRED, "x", self.colors.fg.DEFAULT, "] ", str(exception) ) )
|
||||||
|
traceback.print_tb(exception.__traceback__)
|
||||||
|
Loading…
Reference in New Issue
Block a user