mirror of
https://github.com/wr34k/IRCUFC.git
synced 2024-11-21 23:16:38 +00:00
Fixing IRC colors
This commit is contained in:
parent
3329b113f4
commit
69c7df50ec
4
fight.py
4
fight.py
@ -35,8 +35,8 @@ class Fight(object):
|
||||
def startFight(self):
|
||||
self.state = 'starting_fight'
|
||||
|
||||
self.fighters[0] = Fighter(self.fighters[0], self.IRC.mirc.RED)
|
||||
self.fighters[1] = Fighter(self.fighters[1], self.IRC.mirc.BLUE)
|
||||
self.fighters[0] = Fighter(self.fighters[0], self.IRC.mirc.colors.RED)
|
||||
self.fighters[1] = Fighter(self.fighters[1], self.IRC.mirc.colors.BLUE)
|
||||
|
||||
|
||||
# who start?
|
||||
|
18
irc.py
18
irc.py
@ -11,12 +11,12 @@ from ircCommands import IrcCommands
|
||||
|
||||
server = 'irc.servercentral.net'
|
||||
port = 9999
|
||||
channel = ('#wololo', None) # (chan, key)
|
||||
channel = ('#IRCUFC', None) # (chan, key)
|
||||
use_ssl = True
|
||||
|
||||
nickname = 'devbruce'
|
||||
username = 'rrarrar'
|
||||
realname = '** WE BOTTIN **'
|
||||
nickname = 'IRCUFC'
|
||||
username = 'McBuffer'
|
||||
realname = '** WE FIGHTIN **'
|
||||
|
||||
optkey= "!"
|
||||
timeout=0.4
|
||||
@ -25,8 +25,6 @@ DEBUG = True
|
||||
sys.dont_write_bytecode = True
|
||||
|
||||
|
||||
|
||||
|
||||
class Irc(object):
|
||||
|
||||
def __init__(self):
|
||||
@ -159,10 +157,10 @@ class Irc(object):
|
||||
if args[0] == '{}reload'.format(self.optkey):
|
||||
ret = recompile(args[1]) # Let you add new code to the bot without restarting it
|
||||
if ret == True:
|
||||
self.privmsg(chan, "{} recompiled successfully!".format(args[1]))
|
||||
self.privmsg(chan, "{} recompiled successfully!".format(self.mirc.color(args[1], self.mirc.colors.GREEN)))
|
||||
return
|
||||
else:
|
||||
self.privmsg(chan, "Man we had a issue while recompiling {}".format(args[1]))
|
||||
self.privmsg(chan, "Man we had a issue while recompiling {}".format(self.mirc.color(args[1], self.mirc.colors.GREEN)))
|
||||
self.log.error(ret)
|
||||
return
|
||||
|
||||
@ -173,11 +171,11 @@ class Irc(object):
|
||||
if chan not in self.timeouts:
|
||||
self.timeouts[chan] = {'last_cmd': time.time(), 'burst': 0, 'timeout': 0}
|
||||
self.raw("PRIVMSG {} :{}".format(chan, msg), self.timeouts[chan]['timeout'])
|
||||
self.editTimeouts()
|
||||
self.editTimeouts(chan)
|
||||
|
||||
|
||||
|
||||
def editTimeouts(self):
|
||||
def editTimeouts(self, chan):
|
||||
if (time.time() - self.timeouts[chan]['last_cmd']) < 3:
|
||||
self.timeouts[chan]['burst'] += 1
|
||||
else:
|
||||
|
@ -23,13 +23,13 @@ class IrcCommands(object):
|
||||
if self.IRC.flood_flag[chan] and (time.time() - self.IRC.last_cmd[chan]) < 5:
|
||||
return True
|
||||
if (time.time() - self.IRC.last_cmd[chan]) < 2 and self.IRC.flood_count[chan] > 2:
|
||||
self.IRC.privmsg(chan, "\00305,01{}\00315 Slow down m8".format(nick))
|
||||
self.IRC.privmsg(chan, "{} Slow down m8".format(self.IRC.mirc.color(nick, self.IRC.mirc.colors.RED) ))
|
||||
self.IRC.flood_flag[chan]=True
|
||||
self.IRC.last_cmd[chan] = time.time()
|
||||
return True
|
||||
if (time.time() - self.IRC.last_cmd[chan]) < 1:
|
||||
self.IRC.flood_count[chan]+=1
|
||||
self.IRC.privmsg(chan, "\00305,01{}\00315 Slow down m8".format(nick))
|
||||
self.IRC.privmsg(chan, "{} Slow down m8".format(self.IRC.mirc.color(nick, self.IRC.mirc.colors.RED) ))
|
||||
self.IRC.last_cmd[chan] = time.time()
|
||||
return True
|
||||
|
||||
@ -64,7 +64,7 @@ class IrcCommands(object):
|
||||
|
||||
else:
|
||||
if cmd == 'status':
|
||||
self.fight.getStatus(nick)
|
||||
self.fight.getStatus(chan)
|
||||
|
||||
|
||||
if self.fight.state == 'waiting_fighters_action':
|
||||
@ -72,7 +72,7 @@ class IrcCommands(object):
|
||||
if chan != self.IRC.channel:
|
||||
self.fight.set_next_action(nick, args)
|
||||
else:
|
||||
self.IRC.privmsg(self.IRC.channel, "Not here retard your opponent can see your next move!")
|
||||
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.flood_flag[chan] = False
|
||||
|
@ -6,19 +6,30 @@ class MIRCFormat(object):
|
||||
UNDERLINED = "\x1F"
|
||||
REVERSE = "\x16"
|
||||
RESET = "\x0F"
|
||||
WHITE = "\x0300"
|
||||
BLACK = "\x0301"
|
||||
BLUE = "\x0302"
|
||||
GREEN = "\x0303"
|
||||
RED = "\x0304"
|
||||
BROWN = "\x0305"
|
||||
PURPLE = "\x0306"
|
||||
ORANGE = "\x0307"
|
||||
YELLOW = "\x0308"
|
||||
LIGHTGREEN = "\x0309"
|
||||
CYAN = "\x0310"
|
||||
LIGHTCYAN = "\x0311"
|
||||
LIGHTBLUE = "\x0312"
|
||||
PINK = "\x0313"
|
||||
GREY = "\x0314"
|
||||
LIGHTGREY = "\x0315"
|
||||
|
||||
class Colors():
|
||||
WHITE = "00"
|
||||
BLACK = "01"
|
||||
BLUE = "02"
|
||||
GREEN = "03"
|
||||
RED = "04"
|
||||
BROWN = "05"
|
||||
PURPLE = "06"
|
||||
ORANGE = "07"
|
||||
YELLOW = "08"
|
||||
LIGHTGREEN = "09"
|
||||
CYAN = "10"
|
||||
LIGHTCYAN = "11"
|
||||
LIGHTBLUE = "12"
|
||||
PINK = "13"
|
||||
GREY = "14"
|
||||
LIGHTGREY = "15"
|
||||
|
||||
def __init__(self):
|
||||
self.colors = self.Colors()
|
||||
|
||||
def color(self, msg, fg, bg=None):
|
||||
if bg:
|
||||
return "\x03{},{}{}{}".format(fg,bg,msg,self.RESET)
|
||||
else:
|
||||
return "\x03{}{}{}".format(fg, msg, self.RESET)
|
||||
|
Loading…
Reference in New Issue
Block a user