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_DGREY = "14"
|
||||||
IRC_GRAY = "15"
|
IRC_GRAY = "15"
|
||||||
|
|
||||||
# test:
|
# obsolete test:
|
||||||
# {rred {ggreen {yyellow {bblue {mmagenta {ccyan {wwhite {xdgrey
|
# {rred {ggreen {yyellow {bblue {mmagenta {ccyan {wwhite {xdgrey
|
||||||
# {Rdred {Gdgreen {Ydyellow {Bdblue {Mdmagenta {Cdcyan {Wlgrey {Xblack
|
# {Rdred {Gdgreen {Ydyellow {Bdblue {Mdmagenta {Cdcyan {Wlgrey {Xblack
|
||||||
# {[rredbg {[ggreenbg {[yyellowbg {[bbluebg {[mmagentabg {[ccyanbg {[wlgreybg {[xblackbg
|
# {[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([
|
IRC_COLOR_MAP = dict([
|
||||||
# obs - {-type colors are deprecated but still used in many places.
|
# obs - {-type colors are deprecated but still used in many places.
|
||||||
(r'{n', IRC_RESET), # reset
|
(r'{n', IRC_RESET), # reset
|
||||||
|
|
@ -117,9 +122,10 @@ IRC_COLOR_MAP = dict([
|
||||||
(r'|[x', IRC_COLOR + IRC_NORMAL + "," + IRC_BLACK) # pure black background
|
(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_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)
|
RE_ANSI_ESCAPES = re.compile(r"(%s)" % "|".join(("{{", "%%", "\\\\")), re.DOTALL)
|
||||||
|
|
||||||
|
|
||||||
def sub_irc(ircmatch):
|
def sub_irc(ircmatch):
|
||||||
"""
|
"""
|
||||||
Substitute irc color info. Used by re.sub.
|
Substitute irc color info. Used by re.sub.
|
||||||
|
|
@ -133,6 +139,7 @@ def sub_irc(ircmatch):
|
||||||
"""
|
"""
|
||||||
return IRC_COLOR_MAP.get(ircmatch.group(), "")
|
return IRC_COLOR_MAP.get(ircmatch.group(), "")
|
||||||
|
|
||||||
|
|
||||||
def parse_irc_colors(string):
|
def parse_irc_colors(string):
|
||||||
"""
|
"""
|
||||||
Parse {-type syntax and replace with IRC color markers
|
Parse {-type syntax and replace with IRC color markers
|
||||||
|
|
@ -156,9 +163,10 @@ def parse_irc_colors(string):
|
||||||
|
|
||||||
# IRC bot
|
# IRC bot
|
||||||
|
|
||||||
|
|
||||||
class IRCBot(irc.IRCClient, Session):
|
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
|
as sends text to it when prompted
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
@ -246,14 +254,14 @@ class IRCBot(irc.IRCClient, Session):
|
||||||
self.sendLine("NAMES %s" % self.channel)
|
self.sendLine("NAMES %s" % self.channel)
|
||||||
|
|
||||||
def irc_RPL_NAMREPLY(self, prefix, params):
|
def irc_RPL_NAMREPLY(self, prefix, params):
|
||||||
"Handles IRC NAME request returns (nicklist)"
|
""""Handles IRC NAME request returns (nicklist)"""
|
||||||
channel = params[2].lower()
|
channel = params[2].lower()
|
||||||
if channel != self.channel.lower():
|
if channel != self.channel.lower():
|
||||||
return
|
return
|
||||||
self.nicklist += params[3].split(' ')
|
self.nicklist += params[3].split(' ')
|
||||||
|
|
||||||
def irc_RPL_ENDOFNAMES(self, prefix, params):
|
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()
|
channel = params[1].lower()
|
||||||
if channel != self.channel.lower():
|
if channel != self.channel.lower():
|
||||||
return
|
return
|
||||||
|
|
@ -271,7 +279,6 @@ class IRCBot(irc.IRCClient, Session):
|
||||||
"""
|
"""
|
||||||
self.data_in(text="", type="ping", user="server", channel=self.channel, timing=time)
|
self.data_in(text="", type="ping", user="server", channel=self.channel, timing=time)
|
||||||
|
|
||||||
|
|
||||||
def data_in(self, text=None, **kwargs):
|
def data_in(self, text=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Data IRC -> Server.
|
Data IRC -> Server.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue