| |
- builtins.Exception(builtins.BaseException)
-
- ProtocolError
- builtins.object
-
- Irc
-
- FakeIRC
- IrcChannel
- IrcServer
- IrcUser
- Protocol
-
- FakeProto
class FakeIRC(Irc) |
|
Fake IRC object used for unit tests. |
|
- Method resolution order:
- FakeIRC
- Irc
- builtins.object
Methods defined here:
- connect(self)
- Runs the connect loop for the IRC object. This is usually called by
__init__ in a separate thread to allow multiple concurrent connections.
- run(self, data)
- Queues a message to the fake IRC server.
- send(self, data)
- Sends raw text to the uplink server.
- takeCommands(self, msgs)
- Returns a list of commands parsed from the output of takeMsgs().
- takeHooks(self)
- Returns a list of hook arguments sent by the protocol module since
the last takeHooks() call.
- takeMsgs(self)
- Returns a list of messages sent by the protocol module since
the last takeMsgs() call, so we can track what has been sent.
Methods inherited from Irc:
- __init__(self, netname, proto, conf)
- Initializes an IRC object. This takes 3 variables: the network name
(a string), the name of the protocol module to use for this connection,
and a configuration object.
- __repr__(self)
- Return repr(self).
- applyModes(self, target, changedmodes)
- Takes a list of parsed IRC modes, and applies them on the given target.
The target can be either a channel or a user; this is handled automatically.
- callCommand(self, source, text)
- Calls a PyLink bot command. source is the caller's UID, and text is the
full, unparsed text of the message.
- callHooks(self, hook_args)
- Calls a hook function with the given hook args.
- checkAuthenticated(self, uid, allowAuthed=True, allowOper=True)
- Checks whether the given user has operator status on PyLink, raising
NotAuthenticatedError and logging the access denial if not.
- disconnect(self)
- Handle disconnects from the remote server.
- getHostmask(self, user, realhost=False, ip=False)
- Returns the hostmask of the given user, if present. If the realhost option
is given, return the real host of the user instead of the displayed host.
If the ip option is given, return the IP address of the user (this overrides
realhost).
- getServer(self, numeric)
- Finds the SID of the server a user is on.
- initVars(self)
- (Re)sets an IRC object to its default state. This should be called when
an IRC object is first created, and on every reconnection to a network.
- isInternalClient(self, numeric)
- Checks whether the given numeric is a PyLink Client,
returning the SID of the server it's on if so.
- isInternalServer(self, sid)
- Returns whether the given SID is an internal PyLink server.
- isManipulatableClient(self, uid)
- Returns whether the given user is marked as an internal, manipulatable
client. Usually, automatically spawned services clients should have this
set True to prevent interactions with opers (like mode changes) from
causing desyncs.
- isOper(self, uid, allowAuthed=True, allowOper=True)
- Returns whether the given user has operator status on PyLink. This can be achieved
by either identifying to PyLink as admin (if allowAuthed is True),
or having user mode +o set (if allowOper is True). At least one of
allowAuthed or allowOper must be True for this to give any meaningful
results.
- isServiceBot(self, uid)
- Checks whether the given UID is a registered service bot. If True,
returns the cooresponding ServiceBot object.
- logSetup(self)
- Initializes any channel loggers defined for the current network.
- msg(self, target, text, notice=False, source=None)
- Handy function to send messages/notices to clients. Source
is optional, and defaults to the main PyLink client if not specified.
- nickToUid(self, nick)
- Looks up the UID of a user with the given nick, if one is present.
- parseModes(self, target, args)
- Parses a modestring list into a list of (mode, argument) tuples.
['+mitl-o', '3', 'person'] => [('+m', None), ('+i', None), ('+t', None), ('+l', '3'), ('-o', 'person')]
- reply(self, text, notice=False, source=None)
- Replies to the last caller in the right context (channel or PM).
- reverseModes(self, target, modes, oldobj=None)
- Reverses/Inverts the mode string or mode list given.
Optionally, an oldobj argument can be given to look at an earlier state of
a channel/user object, e.g. for checking the op status of a mode setter
before their modes are processed and added to the channel state.
This function allows both mode strings or mode lists. Example uses:
"+mi-lk test => "-mi+lk test"
"mi-k test => "-mi+k test"
[('+m', None), ('+r', None), ('+l', '3'), ('-o', 'person')
=> {('-m', None), ('-r', None), ('-l', None), ('+o', 'person')})
{('s', None), ('+o', 'whoever') => {('-s', None), ('-o', 'whoever')})
- runline(self, line)
- Sends a command to the protocol module.
- schedulePing(self)
- Schedules periodic pings in a loop.
- toLower(self, text)
- Returns a lowercase representation of text based on the IRC object's
casemapping (rfc1459 or ascii).
- version(self)
- Returns a detailed version string including the PyLink daemon version,
the protocol module in use, and the server hostname.
Static methods inherited from Irc:
- joinModes(modes)
- Takes a list of (mode, arg) tuples in parseModes() format, and
joins them into a string.
See testJoinModes in tests/test_utils.py for some examples.
Data descriptors inherited from Irc:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class FakeProto(Protocol) |
|
Dummy protocol module for testing purposes. |
|
- Method resolution order:
- FakeProto
- Protocol
- builtins.object
Methods defined here:
- connect(self)
- handle_events(self, data)
- join(self, client, channel)
- spawnClient(self, nick, *args, **kwargs)
Data and other attributes defined here:
- Class = <class 'classes.FakeProto'>
- Dummy protocol module for testing purposes.
Methods inherited from Protocol:
- __init__(self, irc)
- Initialize self. See help(type(self)) for accurate signature.
- parseArgs(self, args)
- Parses a string of RFC1459-style arguments split into a list, where ":" may
be used for multi-word arguments that last until the end of a line.
- removeClient(self, numeric)
- Internal function to remove a client from our internal state.
- updateTS(self, channel, their_ts)
- Compares the current TS of the channel given with the new TS, resetting
all modes we have if the one given is older.
Data descriptors inherited from Protocol:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class Irc(builtins.object) |
|
Base IRC object for PyLink. |
|
Methods defined here:
- __init__(self, netname, proto, conf)
- Initializes an IRC object. This takes 3 variables: the network name
(a string), the name of the protocol module to use for this connection,
and a configuration object.
- __repr__(self)
- Return repr(self).
- applyModes(self, target, changedmodes)
- Takes a list of parsed IRC modes, and applies them on the given target.
The target can be either a channel or a user; this is handled automatically.
- callCommand(self, source, text)
- Calls a PyLink bot command. source is the caller's UID, and text is the
full, unparsed text of the message.
- callHooks(self, hook_args)
- Calls a hook function with the given hook args.
- checkAuthenticated(self, uid, allowAuthed=True, allowOper=True)
- Checks whether the given user has operator status on PyLink, raising
NotAuthenticatedError and logging the access denial if not.
- connect(self)
- Runs the connect loop for the IRC object. This is usually called by
__init__ in a separate thread to allow multiple concurrent connections.
- disconnect(self)
- Handle disconnects from the remote server.
- getHostmask(self, user, realhost=False, ip=False)
- Returns the hostmask of the given user, if present. If the realhost option
is given, return the real host of the user instead of the displayed host.
If the ip option is given, return the IP address of the user (this overrides
realhost).
- getServer(self, numeric)
- Finds the SID of the server a user is on.
- initVars(self)
- (Re)sets an IRC object to its default state. This should be called when
an IRC object is first created, and on every reconnection to a network.
- isInternalClient(self, numeric)
- Checks whether the given numeric is a PyLink Client,
returning the SID of the server it's on if so.
- isInternalServer(self, sid)
- Returns whether the given SID is an internal PyLink server.
- isManipulatableClient(self, uid)
- Returns whether the given user is marked as an internal, manipulatable
client. Usually, automatically spawned services clients should have this
set True to prevent interactions with opers (like mode changes) from
causing desyncs.
- isOper(self, uid, allowAuthed=True, allowOper=True)
- Returns whether the given user has operator status on PyLink. This can be achieved
by either identifying to PyLink as admin (if allowAuthed is True),
or having user mode +o set (if allowOper is True). At least one of
allowAuthed or allowOper must be True for this to give any meaningful
results.
- isServiceBot(self, uid)
- Checks whether the given UID is a registered service bot. If True,
returns the cooresponding ServiceBot object.
- logSetup(self)
- Initializes any channel loggers defined for the current network.
- msg(self, target, text, notice=False, source=None)
- Handy function to send messages/notices to clients. Source
is optional, and defaults to the main PyLink client if not specified.
- nickToUid(self, nick)
- Looks up the UID of a user with the given nick, if one is present.
- parseModes(self, target, args)
- Parses a modestring list into a list of (mode, argument) tuples.
['+mitl-o', '3', 'person'] => [('+m', None), ('+i', None), ('+t', None), ('+l', '3'), ('-o', 'person')]
- reply(self, text, notice=False, source=None)
- Replies to the last caller in the right context (channel or PM).
- reverseModes(self, target, modes, oldobj=None)
- Reverses/Inverts the mode string or mode list given.
Optionally, an oldobj argument can be given to look at an earlier state of
a channel/user object, e.g. for checking the op status of a mode setter
before their modes are processed and added to the channel state.
This function allows both mode strings or mode lists. Example uses:
"+mi-lk test => "-mi+lk test"
"mi-k test => "-mi+k test"
[('+m', None), ('+r', None), ('+l', '3'), ('-o', 'person')
=> {('-m', None), ('-r', None), ('-l', None), ('+o', 'person')})
{('s', None), ('+o', 'whoever') => {('-s', None), ('-o', 'whoever')})
- run(self)
- Main IRC loop which listens for messages.
- runline(self, line)
- Sends a command to the protocol module.
- schedulePing(self)
- Schedules periodic pings in a loop.
- send(self, data)
- Sends raw text to the uplink server.
- toLower(self, text)
- Returns a lowercase representation of text based on the IRC object's
casemapping (rfc1459 or ascii).
- version(self)
- Returns a detailed version string including the PyLink daemon version,
the protocol module in use, and the server hostname.
Static methods defined here:
- joinModes(modes)
- Takes a list of (mode, arg) tuples in parseModes() format, and
joins them into a string.
See testJoinModes in tests/test_utils.py for some examples.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class IrcChannel(builtins.object) |
|
PyLink IRC channel class. |
|
Methods defined here:
- __init__(self, name=None)
- Initialize self. See help(type(self)) for accurate signature.
- __repr__(self)
- Return repr(self).
- deepcopy(self)
- Returns a deep copy of the channel object.
- getPrefixModes(self, uid, prefixmodes=None)
- Returns a list of all named prefix modes the given user has in the channel.
Optionally, a prefixmodes argument can be given to look at an earlier state of
the channel's prefix modes mapping, e.g. for checking the op status of a mode
setter before their modes are processed and added to the channel state.
- isAdmin(self, uid)
- Returns whether the given user is admin (&) in the channel.
- isHalfop(self, uid)
- Returns whether the given user is halfop in the channel.
- isHalfopPlus(self, uid)
- Returns whether the given user is halfop or above in the channel.
- isOp(self, uid)
- Returns whether the given user is op in the channel.
- isOpPlus(self, uid)
- Returns whether the given user is op or above in the channel.
- isOwner(self, uid)
- Returns whether the given user is owner (~) in the channel.
- isVoice(self, uid)
- Returns whether the given user is voice in the channel.
- isVoicePlus(self, uid)
- Returns whether the given user is voice or above in the channel.
- removeuser(self, target)
- Removes a user from a channel.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class IrcServer(builtins.object) |
|
PyLink IRC server class.
uplink: The SID of this IrcServer instance's uplink. This is set to None
for the main PyLink PseudoServer!
name: The name of the server.
internal: Whether the server is an internal PyLink PseudoServer. |
|
Methods defined here:
- __init__(self, uplink, name, internal=False, desc='(None given)')
- Initialize self. See help(type(self)) for accurate signature.
- __repr__(self)
- Return repr(self).
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class IrcUser(builtins.object) |
|
PyLink IRC user class. |
|
Methods defined here:
- __init__(self, nick, ts, uid, ident='null', host='null', realname='PyLink dummy client', realhost='null', ip='0.0.0.0', manipulatable=False, opertype='IRC Operator')
- Initialize self. See help(type(self)) for accurate signature.
- __repr__(self)
- Return repr(self).
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class Protocol(builtins.object) |
|
Base Protocol module class for PyLink. |
|
Methods defined here:
- __init__(self, irc)
- Initialize self. See help(type(self)) for accurate signature.
- parseArgs(self, args)
- Parses a string of RFC1459-style arguments split into a list, where ":" may
be used for multi-word arguments that last until the end of a line.
- removeClient(self, numeric)
- Internal function to remove a client from our internal state.
- updateTS(self, channel, their_ts)
- Compares the current TS of the channel given with the new TS, resetting
all modes we have if the one given is older.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class ProtocolError(builtins.Exception) |
|
Common base class for all non-exit exceptions. |
|
- Method resolution order:
- ProtocolError
- builtins.Exception
- builtins.BaseException
- builtins.object
Data descriptors defined here:
- __weakref__
- list of weak references to the object (if defined)
Methods inherited from builtins.Exception:
- __init__(self, /, *args, **kwargs)
- Initialize self. See help(type(self)) for accurate signature.
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Methods inherited from builtins.BaseException:
- __delattr__(self, name, /)
- Implement delattr(self, name).
- __getattribute__(self, name, /)
- Return getattr(self, name).
- __reduce__(...)
- helper for pickle
- __repr__(self, /)
- Return repr(self).
- __setattr__(self, name, value, /)
- Implement setattr(self, name, value).
- __setstate__(...)
- __str__(self, /)
- Return str(self).
- with_traceback(...)
- Exception.with_traceback(tb) --
set self.__traceback__ to tb and return self.
Data descriptors inherited from builtins.BaseException:
- __cause__
- exception cause
- __context__
- exception context
- __dict__
- __suppress_context__
- __traceback__
- args
| |