Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parsemsg():
s = b(":foo!bar@localhost NICK foobar")
source, command, args = parsemsg(s)
assert source == (u("foo"), u("bar"), u("localhost"))
assert command == "NICK"
assert args == [u("foobar")]
s = b("")
source, command, args = parsemsg(s)
assert source == (None, None, None)
assert command is None
assert args == []
def RPL_WELCOME(network):
return _M(u("001"), u("Welcome to the {0} IRC Network").format(network))
def __unicode__(self):
args = self.args[:]
if any(u(' ') in arg for arg in args[:-1]):
raise Error("Space can only appear in the very last arg")
if any(u('\n') in arg for arg in args):
raise Error("No newline allowed")
if args and u(" ") in args[-1] and not args[-1].startswith(u(":")):
args[-1] = u(":{0:s}").format(args[-1])
return u("{prefix:s}{command:s} {args:s}\r\n").format(
prefix=(
u(":{0:s} ").format(self.prefix)
if self.prefix is not None
else u("")
),
command=text_type(self.command),
args=u(" ").join(args)
)
def RPL_WHOISOPERATOR(nick):
return _M(u("313"), nick, u("is an IRC operator"))
"""
if len(s) > 0:
if s[0] == u(":"):
s = s[1:]
if color:
s = s.replace(u("\x01"), u(""))
s = s.replace(u("\x02"), u("")) # bold
s = s.replace(u("\x1d"), u("")) # italics
s = s.replace(u("\x1f"), u("")) # underline
s = s.replace(u("\x1e"), u("")) # strikethrough
s = s.replace(u("\x11"), u("")) # monospace
s = s.replace(u("\x16"), u("")) # reverse color
s = COLOR.sub(u(""), s) # color codes
s = s.replace(u("\x03"), u("")) # color
s = s.replace(u("\x0f"), u("")) # reset
return s
def RPL_MOTD(text):
return _M(u("372"), u("- {0}").format(text))
def RPL_WHOREPLY(channel, user, host, server, nick, status, hops, name):
return _M(
u("352"), channel, user, host, server, nick, status, u(":{0} {1}").format(hops, name)
)
def ERR_NOPRIVILEGES():
return _M(u("481"), u("Permission Denied- You're not an IRC operator"))
def RPL_TOPICWHO(channel, setter, timestamp):
return _M(u("333"), channel, setter, u("{0}".format(timestamp)))