irc3.utils
Utils¶
-
class
irc3.utils.
IrcString
[source]¶ Argument wrapper
-
hostname
¶ return host name:
>>> print(IrcString('foo!user@host').hostname) host >>> IrcString('#foo').hostname is None True >>> IrcString('irc.freenode.net').hostname is None True
-
is_channel
¶ return True if the string is a channel:
>>> IrcString('#channel').is_channel True >>> IrcString('&channel').is_channel True
-
is_nick
¶ return True if the string is a nickname:
>>> IrcString('foo').is_nick True
-
is_server
¶ return True if the string is a server:
>>> IrcString('irc.freenode.net').is_server True
-
lnick
¶ return nick name in lowercase:
>>> print(IrcString('Foo').lnick) foo
-
nick
¶ return nick name:
>>> print(IrcString('foo').nick) foo >>> print(IrcString('foo!user@host').nick) foo >>> IrcString('#foo').nick is None True >>> IrcString('irc.freenode.net').nick is None True
-
tagdict
¶ return a dict converted from this string interpreted as a tag-string
>>> from pprint import pprint >>> dict_ = IrcString('aaa=bbb;ccc;example.com/ddd=eee').tagdict >>> pprint({str(k): str(v) for k, v in dict_.items()}) {'aaa': 'bbb', 'ccc': 'None', 'example.com/ddd': 'eee'}
-
username
¶ return user name:
>>> print(IrcString('foo!user@host').username) user >>> IrcString('#foo').username is None True >>> IrcString('irc.freenode.net').username is None True
-
-
irc3.utils.
as_list
(value)[source]¶ clever string spliting:
>>> print(as_list('value')) ['value'] >>> print(as_list('v1 v2')) ['v1', 'v2'] >>> print(as_list(None)) [] >>> print(as_list(['v1'])) ['v1']
-
irc3.utils.
as_channel
(value)[source]¶ Always return a channel name:
>>> print(as_channel('chan')) #chan >>> print(as_channel('#chan')) #chan >>> print(as_channel('&chan')) &chan
-
class
irc3.utils.
Logger
(name, level=0)[source]¶ Replace the default logger to add a set_irc_targets() method