Markup change, whitespace and typo fixes
This commit is contained in:
parent
6fae85c32a
commit
f14667cdd6
1 changed files with 25 additions and 18 deletions
|
|
@ -40,11 +40,16 @@ IRC_MAGENTA = "13"
|
|||
IRC_DGREY = "14"
|
||||
IRC_GRAY = "15"
|
||||
|
||||
# test:
|
||||
# obsolete test:
|
||||
# {rred {ggreen {yyellow {bblue {mmagenta {ccyan {wwhite {xdgrey
|
||||
# {Rdred {Gdgreen {Ydyellow {Bdblue {Mdmagenta {Cdcyan {Wlgrey {Xblack
|
||||
# {[rredbg {[ggreenbg {[yyellowbg {[bbluebg {[mmagentabg {[ccyanbg {[wlgreybg {[xblackbg
|
||||
|
||||
# test:
|
||||
# |rred |ggreen |yyellow |bblue |mmagenta |ccyan |wwhite |xdgrey
|
||||
# |Rdred |Gdgreen |Ydyellow |Bdblue |Mdmagenta |Cdcyan |Wlgrey |Xblack
|
||||
# |[rredbg |[ggreenbg |[yyellowbg |[bbluebg |[mmagentabg |[ccyanbg |[wlgreybg |[xblackbg
|
||||
|
||||
IRC_COLOR_MAP = dict([
|
||||
# obs - {-type colors are deprecated but still used in many places.
|
||||
(r'{n', IRC_RESET), # reset
|
||||
|
|
@ -117,9 +122,10 @@ IRC_COLOR_MAP = dict([
|
|||
(r'|[x', IRC_COLOR + IRC_NORMAL + "," + IRC_BLACK) # pure black background
|
||||
])
|
||||
RE_IRC_COLOR = re.compile(r"|".join([re.escape(key) for key in viewkeys(IRC_COLOR_MAP)]), re.DOTALL)
|
||||
RE_MXP = re.compile(r'\{lc(.*?)\{lt(.*?)\{le', re.DOTALL)
|
||||
RE_MXP = re.compile(r'\|lc(.*?)\|lt(.*?)\|le', re.DOTALL)
|
||||
RE_ANSI_ESCAPES = re.compile(r"(%s)" % "|".join(("{{", "%%", "\\\\")), re.DOTALL)
|
||||
|
||||
|
||||
def sub_irc(ircmatch):
|
||||
"""
|
||||
Substitute irc color info. Used by re.sub.
|
||||
|
|
@ -133,6 +139,7 @@ def sub_irc(ircmatch):
|
|||
"""
|
||||
return IRC_COLOR_MAP.get(ircmatch.group(), "")
|
||||
|
||||
|
||||
def parse_irc_colors(string):
|
||||
"""
|
||||
Parse {-type syntax and replace with IRC color markers
|
||||
|
|
@ -156,9 +163,10 @@ def parse_irc_colors(string):
|
|||
|
||||
# IRC bot
|
||||
|
||||
|
||||
class IRCBot(irc.IRCClient, Session):
|
||||
"""
|
||||
An IRC bot that tracks actitivity in a channel as well
|
||||
An IRC bot that tracks activity in a channel as well
|
||||
as sends text to it when prompted
|
||||
|
||||
"""
|
||||
|
|
@ -246,14 +254,14 @@ class IRCBot(irc.IRCClient, Session):
|
|||
self.sendLine("NAMES %s" % self.channel)
|
||||
|
||||
def irc_RPL_NAMREPLY(self, prefix, params):
|
||||
"Handles IRC NAME request returns (nicklist)"
|
||||
""""Handles IRC NAME request returns (nicklist)"""
|
||||
channel = params[2].lower()
|
||||
if channel != self.channel.lower():
|
||||
return
|
||||
self.nicklist += params[3].split(' ')
|
||||
|
||||
def irc_RPL_ENDOFNAMES(self, prefix, params):
|
||||
"Called when the nicklist has finished being returned."
|
||||
"""Called when the nicklist has finished being returned."""
|
||||
channel = params[1].lower()
|
||||
if channel != self.channel.lower():
|
||||
return
|
||||
|
|
@ -271,7 +279,6 @@ class IRCBot(irc.IRCClient, Session):
|
|||
"""
|
||||
self.data_in(text="", type="ping", user="server", channel=self.channel, timing=time)
|
||||
|
||||
|
||||
def data_in(self, text=None, **kwargs):
|
||||
"""
|
||||
Data IRC -> Server.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue