mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-24 19:49:24 +01:00
569 lines
43 KiB
HTML
569 lines
43 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html><head><title>Python: module classes</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
</head><body bgcolor="#f0f0f8">
|
|
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
|
<tr bgcolor="#7799ee">
|
|
<td valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>classes</strong></big></big></font></td
|
|
><td align=right valign=bottom
|
|
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/gl/pylink/classes.py">/home/gl/pylink/classes.py</a></font></td></tr></table>
|
|
<p><tt>classes.py - Base classes for PyLink IRC Services.<br>
|
|
<br>
|
|
This module contains the base classes used by PyLink, including threaded IRC<br>
|
|
connections and objects used to represent IRC servers, users, and channels.<br>
|
|
<br>
|
|
Here be dragons.</tt></p>
|
|
<p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#aa55cc">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
|
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="hashlib.html">hashlib</a><br>
|
|
<a href="inspect.html">inspect</a><br>
|
|
<a href="logging.html">logging</a><br>
|
|
</td><td width="25%" valign=top><a href="os.html">os</a><br>
|
|
<a href="socket.html">socket</a><br>
|
|
<a href="ssl.html">ssl</a><br>
|
|
</td><td width="25%" valign=top><a href="structures.html">structures</a><br>
|
|
<a href="sys.html">sys</a><br>
|
|
<a href="threading.html">threading</a><br>
|
|
</td><td width="25%" valign=top><a href="time.html">time</a><br>
|
|
<a href="utils.html">utils</a><br>
|
|
<a href="world.html">world</a><br>
|
|
</td></tr></table></td></tr></table><p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ee77aa">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
|
<td width="100%"><dl>
|
|
<dt><font face="helvetica, arial"><a href="builtins.html#Exception">builtins.Exception</a>(<a href="builtins.html#BaseException">builtins.BaseException</a>)
|
|
</font></dt><dd>
|
|
<dl>
|
|
<dt><font face="helvetica, arial"><a href="classes.html#ProtocolError">ProtocolError</a>
|
|
</font></dt></dl>
|
|
</dd>
|
|
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
|
|
</font></dt><dd>
|
|
<dl>
|
|
<dt><font face="helvetica, arial"><a href="classes.html#Irc">Irc</a>
|
|
</font></dt><dd>
|
|
<dl>
|
|
<dt><font face="helvetica, arial"><a href="classes.html#FakeIRC">FakeIRC</a>
|
|
</font></dt></dl>
|
|
</dd>
|
|
<dt><font face="helvetica, arial"><a href="classes.html#IrcChannel">IrcChannel</a>
|
|
</font></dt><dt><font face="helvetica, arial"><a href="classes.html#IrcServer">IrcServer</a>
|
|
</font></dt><dt><font face="helvetica, arial"><a href="classes.html#IrcUser">IrcUser</a>
|
|
</font></dt><dt><font face="helvetica, arial"><a href="classes.html#Protocol">Protocol</a>
|
|
</font></dt><dd>
|
|
<dl>
|
|
<dt><font face="helvetica, arial"><a href="classes.html#FakeProto">FakeProto</a>
|
|
</font></dt></dl>
|
|
</dd>
|
|
</dl>
|
|
</dd>
|
|
</dl>
|
|
<p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="FakeIRC">class <strong>FakeIRC</strong></a>(<a href="classes.html#Irc">Irc</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>Fake IRC <a href="builtins.html#object">object</a> used for unit tests.<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%"><dl><dt>Method resolution order:</dt>
|
|
<dd><a href="classes.html#FakeIRC">FakeIRC</a></dd>
|
|
<dd><a href="classes.html#Irc">Irc</a></dd>
|
|
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
|
</dl>
|
|
<hr>
|
|
Methods defined here:<br>
|
|
<dl><dt><a name="FakeIRC-connect"><strong>connect</strong></a>(self)</dt><dd><tt>Runs the connect loop for the IRC <a href="builtins.html#object">object</a>. This is usually called by<br>
|
|
__init__ in a separate thread to allow multiple concurrent connections.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-run"><strong>run</strong></a>(self, data)</dt><dd><tt>Queues a message to the fake IRC server.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-send"><strong>send</strong></a>(self, data)</dt><dd><tt>Sends raw text to the uplink server.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-takeCommands"><strong>takeCommands</strong></a>(self, msgs)</dt><dd><tt>Returns a list of commands parsed from the output of <a href="#FakeIRC-takeMsgs">takeMsgs</a>().</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-takeHooks"><strong>takeHooks</strong></a>(self)</dt><dd><tt>Returns a list of hook arguments sent by the protocol module since<br>
|
|
the last <a href="#FakeIRC-takeHooks">takeHooks</a>() call.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-takeMsgs"><strong>takeMsgs</strong></a>(self)</dt><dd><tt>Returns a list of messages sent by the protocol module since<br>
|
|
the last <a href="#FakeIRC-takeMsgs">takeMsgs</a>() call, so we can track what has been sent.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Methods inherited from <a href="classes.html#Irc">Irc</a>:<br>
|
|
<dl><dt><a name="FakeIRC-__init__"><strong>__init__</strong></a>(self, netname, proto, conf)</dt><dd><tt>Initializes an IRC <a href="builtins.html#object">object</a>. This takes 3 variables: the network name<br>
|
|
(a string), the name of the protocol module to use for this connection,<br>
|
|
and a configuration <a href="builtins.html#object">object</a>.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-applyModes"><strong>applyModes</strong></a>(self, target, changedmodes)</dt><dd><tt>Takes a list of parsed IRC modes, and applies them on the given target.<br>
|
|
<br>
|
|
The target can be either a channel or a user; this is handled automatically.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-callCommand"><strong>callCommand</strong></a>(self, source, text)</dt><dd><tt>Calls a PyLink bot command. source is the caller's UID, and text is the<br>
|
|
full, unparsed text of the message.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-callHooks"><strong>callHooks</strong></a>(self, hook_args)</dt><dd><tt>Calls a hook function with the given hook args.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-checkAuthenticated"><strong>checkAuthenticated</strong></a>(self, uid, allowAuthed=True, allowOper=True)</dt><dd><tt>Checks whether the given user has operator status on PyLink, raising<br>
|
|
NotAuthenticatedError and logging the access denial if not.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-disconnect"><strong>disconnect</strong></a>(self)</dt><dd><tt>Handle disconnects from the remote server.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-getHostmask"><strong>getHostmask</strong></a>(self, user, realhost=False, ip=False)</dt><dd><tt>Returns the hostmask of the given user, if present. If the realhost option<br>
|
|
is given, return the real host of the user instead of the displayed host.<br>
|
|
If the ip option is given, return the IP address of the user (this overrides<br>
|
|
realhost).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-getServer"><strong>getServer</strong></a>(self, numeric)</dt><dd><tt>Finds the SID of the server a user is on.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-initVars"><strong>initVars</strong></a>(self)</dt><dd><tt>(Re)sets an IRC <a href="builtins.html#object">object</a> to its default state. This should be called when<br>
|
|
an IRC <a href="builtins.html#object">object</a> is first created, and on every reconnection to a network.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-isInternalClient"><strong>isInternalClient</strong></a>(self, numeric)</dt><dd><tt>Checks whether the given numeric is a PyLink Client,<br>
|
|
returning the SID of the server it's on if so.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-isInternalServer"><strong>isInternalServer</strong></a>(self, sid)</dt><dd><tt>Returns whether the given SID is an internal PyLink server.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-isManipulatableClient"><strong>isManipulatableClient</strong></a>(self, uid)</dt><dd><tt>Returns whether the given user is marked as an internal, manipulatable<br>
|
|
client. Usually, automatically spawned services clients should have this<br>
|
|
set True to prevent interactions with opers (like mode changes) from<br>
|
|
causing desyncs.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-isOper"><strong>isOper</strong></a>(self, uid, allowAuthed=True, allowOper=True)</dt><dd><tt>Returns whether the given user has operator status on PyLink. This can be achieved<br>
|
|
by either identifying to PyLink as admin (if allowAuthed is True),<br>
|
|
or having user mode +o set (if allowOper is True). At least one of<br>
|
|
allowAuthed or allowOper must be True for this to give any meaningful<br>
|
|
results.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-isServiceBot"><strong>isServiceBot</strong></a>(self, uid)</dt><dd><tt>Checks whether the given UID is a registered service bot. If True,<br>
|
|
returns the cooresponding ServiceBot <a href="builtins.html#object">object</a>.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-logSetup"><strong>logSetup</strong></a>(self)</dt><dd><tt>Initializes any channel loggers defined for the current network.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-msg"><strong>msg</strong></a>(self, target, text, notice=False, source=None)</dt><dd><tt>Handy function to send messages/notices to clients. Source<br>
|
|
is optional, and defaults to the main PyLink client if not specified.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-nickToUid"><strong>nickToUid</strong></a>(self, nick)</dt><dd><tt>Looks up the UID of a user with the given nick, if one is present.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-parseModes"><strong>parseModes</strong></a>(self, target, args)</dt><dd><tt>Parses a modestring list into a list of (mode, argument) tuples.<br>
|
|
['+mitl-o', '3', 'person'] => [('+m', None), ('+i', None), ('+t', None), ('+l', '3'), ('-o', 'person')]</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-reply"><strong>reply</strong></a>(self, text, notice=False, source=None)</dt><dd><tt>Replies to the last caller in the right context (channel or PM).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-reverseModes"><strong>reverseModes</strong></a>(self, target, modes, oldobj=None)</dt><dd><tt>Reverses/Inverts the mode string or mode list given.<br>
|
|
<br>
|
|
Optionally, an oldobj argument can be given to look at an earlier state of<br>
|
|
a channel/user <a href="builtins.html#object">object</a>, e.g. for checking the op status of a mode setter<br>
|
|
before their modes are processed and added to the channel state.<br>
|
|
<br>
|
|
This function allows both mode strings or mode lists. Example uses:<br>
|
|
"+mi-lk test => "-mi+lk test"<br>
|
|
"mi-k test => "-mi+k test"<br>
|
|
[('+m', None), ('+r', None), ('+l', '3'), ('-o', 'person')<br>
|
|
=> {('-m', None), ('-r', None), ('-l', None), ('+o', 'person')})<br>
|
|
{('s', None), ('+o', 'whoever') => {('-s', None), ('-o', 'whoever')})</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-runline"><strong>runline</strong></a>(self, line)</dt><dd><tt>Sends a command to the protocol module.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-schedulePing"><strong>schedulePing</strong></a>(self)</dt><dd><tt>Schedules periodic pings in a loop.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-toLower"><strong>toLower</strong></a>(self, text)</dt><dd><tt>Returns a lowercase representation of text based on the IRC <a href="builtins.html#object">object</a>'s<br>
|
|
casemapping (rfc1459 or ascii).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeIRC-version"><strong>version</strong></a>(self)</dt><dd><tt>Returns a detailed version string including the PyLink daemon version,<br>
|
|
the protocol module in use, and the server hostname.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Static methods inherited from <a href="classes.html#Irc">Irc</a>:<br>
|
|
<dl><dt><a name="FakeIRC-joinModes"><strong>joinModes</strong></a>(modes)</dt><dd><tt>Takes a list of (mode, arg) tuples in <a href="#FakeIRC-parseModes">parseModes</a>() format, and<br>
|
|
joins them into a string.<br>
|
|
<br>
|
|
See testJoinModes in tests/test_utils.py for some examples.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors inherited from <a href="classes.html#Irc">Irc</a>:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="FakeProto">class <strong>FakeProto</strong></a>(<a href="classes.html#Protocol">Protocol</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>Dummy protocol module for testing purposes.<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%"><dl><dt>Method resolution order:</dt>
|
|
<dd><a href="classes.html#FakeProto">FakeProto</a></dd>
|
|
<dd><a href="classes.html#Protocol">Protocol</a></dd>
|
|
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
|
</dl>
|
|
<hr>
|
|
Methods defined here:<br>
|
|
<dl><dt><a name="FakeProto-connect"><strong>connect</strong></a>(self)</dt></dl>
|
|
|
|
<dl><dt><a name="FakeProto-handle_events"><strong>handle_events</strong></a>(self, data)</dt></dl>
|
|
|
|
<dl><dt><a name="FakeProto-join"><strong>join</strong></a>(self, client, channel)</dt></dl>
|
|
|
|
<dl><dt><a name="FakeProto-spawnClient"><strong>spawnClient</strong></a>(self, nick, *args, **kwargs)</dt></dl>
|
|
|
|
<hr>
|
|
Data and other attributes defined here:<br>
|
|
<dl><dt><strong>Class</strong> = <class 'classes.FakeProto'><dd><tt>Dummy protocol module for testing purposes.</tt></dl>
|
|
|
|
<hr>
|
|
Methods inherited from <a href="classes.html#Protocol">Protocol</a>:<br>
|
|
<dl><dt><a name="FakeProto-__init__"><strong>__init__</strong></a>(self, irc)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeProto-parseArgs"><strong>parseArgs</strong></a>(self, args)</dt><dd><tt>Parses a string of <a href="http://www.rfc-editor.org/rfc/rfc1459.txt">RFC1459</a>-style arguments split into a list, where ":" may<br>
|
|
be used for multi-word arguments that last until the end of a line.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeProto-removeClient"><strong>removeClient</strong></a>(self, numeric)</dt><dd><tt>Internal function to remove a client from our internal state.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FakeProto-updateTS"><strong>updateTS</strong></a>(self, channel, their_ts)</dt><dd><tt>Compares the current TS of the channel given with the new TS, resetting<br>
|
|
all modes we have if the one given is older.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors inherited from <a href="classes.html#Protocol">Protocol</a>:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="Irc">class <strong>Irc</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>Base IRC <a href="builtins.html#object">object</a> for PyLink.<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="Irc-__init__"><strong>__init__</strong></a>(self, netname, proto, conf)</dt><dd><tt>Initializes an IRC <a href="builtins.html#object">object</a>. This takes 3 variables: the network name<br>
|
|
(a string), the name of the protocol module to use for this connection,<br>
|
|
and a configuration <a href="builtins.html#object">object</a>.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-applyModes"><strong>applyModes</strong></a>(self, target, changedmodes)</dt><dd><tt>Takes a list of parsed IRC modes, and applies them on the given target.<br>
|
|
<br>
|
|
The target can be either a channel or a user; this is handled automatically.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-callCommand"><strong>callCommand</strong></a>(self, source, text)</dt><dd><tt>Calls a PyLink bot command. source is the caller's UID, and text is the<br>
|
|
full, unparsed text of the message.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-callHooks"><strong>callHooks</strong></a>(self, hook_args)</dt><dd><tt>Calls a hook function with the given hook args.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-checkAuthenticated"><strong>checkAuthenticated</strong></a>(self, uid, allowAuthed=True, allowOper=True)</dt><dd><tt>Checks whether the given user has operator status on PyLink, raising<br>
|
|
NotAuthenticatedError and logging the access denial if not.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-connect"><strong>connect</strong></a>(self)</dt><dd><tt>Runs the connect loop for the IRC <a href="builtins.html#object">object</a>. This is usually called by<br>
|
|
__init__ in a separate thread to allow multiple concurrent connections.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-disconnect"><strong>disconnect</strong></a>(self)</dt><dd><tt>Handle disconnects from the remote server.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-getHostmask"><strong>getHostmask</strong></a>(self, user, realhost=False, ip=False)</dt><dd><tt>Returns the hostmask of the given user, if present. If the realhost option<br>
|
|
is given, return the real host of the user instead of the displayed host.<br>
|
|
If the ip option is given, return the IP address of the user (this overrides<br>
|
|
realhost).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-getServer"><strong>getServer</strong></a>(self, numeric)</dt><dd><tt>Finds the SID of the server a user is on.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-initVars"><strong>initVars</strong></a>(self)</dt><dd><tt>(Re)sets an IRC <a href="builtins.html#object">object</a> to its default state. This should be called when<br>
|
|
an IRC <a href="builtins.html#object">object</a> is first created, and on every reconnection to a network.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-isInternalClient"><strong>isInternalClient</strong></a>(self, numeric)</dt><dd><tt>Checks whether the given numeric is a PyLink Client,<br>
|
|
returning the SID of the server it's on if so.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-isInternalServer"><strong>isInternalServer</strong></a>(self, sid)</dt><dd><tt>Returns whether the given SID is an internal PyLink server.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-isManipulatableClient"><strong>isManipulatableClient</strong></a>(self, uid)</dt><dd><tt>Returns whether the given user is marked as an internal, manipulatable<br>
|
|
client. Usually, automatically spawned services clients should have this<br>
|
|
set True to prevent interactions with opers (like mode changes) from<br>
|
|
causing desyncs.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-isOper"><strong>isOper</strong></a>(self, uid, allowAuthed=True, allowOper=True)</dt><dd><tt>Returns whether the given user has operator status on PyLink. This can be achieved<br>
|
|
by either identifying to PyLink as admin (if allowAuthed is True),<br>
|
|
or having user mode +o set (if allowOper is True). At least one of<br>
|
|
allowAuthed or allowOper must be True for this to give any meaningful<br>
|
|
results.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-isServiceBot"><strong>isServiceBot</strong></a>(self, uid)</dt><dd><tt>Checks whether the given UID is a registered service bot. If True,<br>
|
|
returns the cooresponding ServiceBot <a href="builtins.html#object">object</a>.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-logSetup"><strong>logSetup</strong></a>(self)</dt><dd><tt>Initializes any channel loggers defined for the current network.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-msg"><strong>msg</strong></a>(self, target, text, notice=False, source=None)</dt><dd><tt>Handy function to send messages/notices to clients. Source<br>
|
|
is optional, and defaults to the main PyLink client if not specified.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-nickToUid"><strong>nickToUid</strong></a>(self, nick)</dt><dd><tt>Looks up the UID of a user with the given nick, if one is present.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-parseModes"><strong>parseModes</strong></a>(self, target, args)</dt><dd><tt>Parses a modestring list into a list of (mode, argument) tuples.<br>
|
|
['+mitl-o', '3', 'person'] => [('+m', None), ('+i', None), ('+t', None), ('+l', '3'), ('-o', 'person')]</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-reply"><strong>reply</strong></a>(self, text, notice=False, source=None)</dt><dd><tt>Replies to the last caller in the right context (channel or PM).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-reverseModes"><strong>reverseModes</strong></a>(self, target, modes, oldobj=None)</dt><dd><tt>Reverses/Inverts the mode string or mode list given.<br>
|
|
<br>
|
|
Optionally, an oldobj argument can be given to look at an earlier state of<br>
|
|
a channel/user <a href="builtins.html#object">object</a>, e.g. for checking the op status of a mode setter<br>
|
|
before their modes are processed and added to the channel state.<br>
|
|
<br>
|
|
This function allows both mode strings or mode lists. Example uses:<br>
|
|
"+mi-lk test => "-mi+lk test"<br>
|
|
"mi-k test => "-mi+k test"<br>
|
|
[('+m', None), ('+r', None), ('+l', '3'), ('-o', 'person')<br>
|
|
=> {('-m', None), ('-r', None), ('-l', None), ('+o', 'person')})<br>
|
|
{('s', None), ('+o', 'whoever') => {('-s', None), ('-o', 'whoever')})</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-run"><strong>run</strong></a>(self)</dt><dd><tt>Main IRC loop which listens for messages.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-runline"><strong>runline</strong></a>(self, line)</dt><dd><tt>Sends a command to the protocol module.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-schedulePing"><strong>schedulePing</strong></a>(self)</dt><dd><tt>Schedules periodic pings in a loop.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-send"><strong>send</strong></a>(self, data)</dt><dd><tt>Sends raw text to the uplink server.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-toLower"><strong>toLower</strong></a>(self, text)</dt><dd><tt>Returns a lowercase representation of text based on the IRC <a href="builtins.html#object">object</a>'s<br>
|
|
casemapping (rfc1459 or ascii).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Irc-version"><strong>version</strong></a>(self)</dt><dd><tt>Returns a detailed version string including the PyLink daemon version,<br>
|
|
the protocol module in use, and the server hostname.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Static methods defined here:<br>
|
|
<dl><dt><a name="Irc-joinModes"><strong>joinModes</strong></a>(modes)</dt><dd><tt>Takes a list of (mode, arg) tuples in <a href="#Irc-parseModes">parseModes</a>() format, and<br>
|
|
joins them into a string.<br>
|
|
<br>
|
|
See testJoinModes in tests/test_utils.py for some examples.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors defined here:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="IrcChannel">class <strong>IrcChannel</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>PyLink IRC channel class.<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="IrcChannel-__init__"><strong>__init__</strong></a>(self, name=None)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="IrcChannel-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="IrcChannel-deepcopy"><strong>deepcopy</strong></a>(self)</dt><dd><tt>Returns a deep copy of the channel <a href="builtins.html#object">object</a>.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="IrcChannel-getPrefixModes"><strong>getPrefixModes</strong></a>(self, uid, prefixmodes=None)</dt><dd><tt>Returns a list of all named prefix modes the given user has in the channel.<br>
|
|
<br>
|
|
Optionally, a prefixmodes argument can be given to look at an earlier state of<br>
|
|
the channel's prefix modes mapping, e.g. for checking the op status of a mode<br>
|
|
setter before their modes are processed and added to the channel state.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="IrcChannel-isAdmin"><strong>isAdmin</strong></a>(self, uid)</dt><dd><tt>Returns whether the given user is admin (&) in the channel.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="IrcChannel-isHalfop"><strong>isHalfop</strong></a>(self, uid)</dt><dd><tt>Returns whether the given user is halfop in the channel.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="IrcChannel-isHalfopPlus"><strong>isHalfopPlus</strong></a>(self, uid)</dt><dd><tt>Returns whether the given user is halfop or above in the channel.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="IrcChannel-isOp"><strong>isOp</strong></a>(self, uid)</dt><dd><tt>Returns whether the given user is op in the channel.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="IrcChannel-isOpPlus"><strong>isOpPlus</strong></a>(self, uid)</dt><dd><tt>Returns whether the given user is op or above in the channel.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="IrcChannel-isOwner"><strong>isOwner</strong></a>(self, uid)</dt><dd><tt>Returns whether the given user is owner (~) in the channel.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="IrcChannel-isVoice"><strong>isVoice</strong></a>(self, uid)</dt><dd><tt>Returns whether the given user is voice in the channel.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="IrcChannel-isVoicePlus"><strong>isVoicePlus</strong></a>(self, uid)</dt><dd><tt>Returns whether the given user is voice or above in the channel.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="IrcChannel-removeuser"><strong>removeuser</strong></a>(self, target)</dt><dd><tt>Removes a user from a channel.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors defined here:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="IrcServer">class <strong>IrcServer</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>PyLink IRC server class.<br>
|
|
<br>
|
|
uplink: The SID of this <a href="#IrcServer">IrcServer</a> instance's uplink. This is set to None<br>
|
|
for the main PyLink PseudoServer!<br>
|
|
name: The name of the server.<br>
|
|
internal: Whether the server is an internal PyLink PseudoServer.<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="IrcServer-__init__"><strong>__init__</strong></a>(self, uplink, name, internal=False, desc='(None given)')</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="IrcServer-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors defined here:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="IrcUser">class <strong>IrcUser</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>PyLink IRC user class.<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="IrcUser-__init__"><strong>__init__</strong></a>(self, nick, ts, uid, ident='null', host='null', realname='PyLink dummy client', realhost='null', ip='0.0.0.0', manipulatable=False, opertype='IRC Operator')</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="IrcUser-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors defined here:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="Protocol">class <strong>Protocol</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>Base <a href="#Protocol">Protocol</a> module class for PyLink.<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="Protocol-__init__"><strong>__init__</strong></a>(self, irc)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Protocol-parseArgs"><strong>parseArgs</strong></a>(self, args)</dt><dd><tt>Parses a string of <a href="http://www.rfc-editor.org/rfc/rfc1459.txt">RFC1459</a>-style arguments split into a list, where ":" may<br>
|
|
be used for multi-word arguments that last until the end of a line.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Protocol-removeClient"><strong>removeClient</strong></a>(self, numeric)</dt><dd><tt>Internal function to remove a client from our internal state.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Protocol-updateTS"><strong>updateTS</strong></a>(self, channel, their_ts)</dt><dd><tt>Compares the current TS of the channel given with the new TS, resetting<br>
|
|
all modes we have if the one given is older.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors defined here:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="ProtocolError">class <strong>ProtocolError</strong></a>(<a href="builtins.html#Exception">builtins.Exception</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>Common base class for all non-exit exceptions.<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%"><dl><dt>Method resolution order:</dt>
|
|
<dd><a href="classes.html#ProtocolError">ProtocolError</a></dd>
|
|
<dd><a href="builtins.html#Exception">builtins.Exception</a></dd>
|
|
<dd><a href="builtins.html#BaseException">builtins.BaseException</a></dd>
|
|
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
|
</dl>
|
|
<hr>
|
|
Data descriptors defined here:<br>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
<hr>
|
|
Methods inherited from <a href="builtins.html#Exception">builtins.Exception</a>:<br>
|
|
<dl><dt><a name="ProtocolError-__init__"><strong>__init__</strong></a>(self, /, *args, **kwargs)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ProtocolError-__new__"><strong>__new__</strong></a>(*args, **kwargs)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Create and return a new <a href="builtins.html#object">object</a>. See help(type) for accurate signature.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Methods inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
|
|
<dl><dt><a name="ProtocolError-__delattr__"><strong>__delattr__</strong></a>(self, name, /)</dt><dd><tt>Implement delattr(self, name).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ProtocolError-__getattribute__"><strong>__getattribute__</strong></a>(self, name, /)</dt><dd><tt>Return getattr(self, name).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ProtocolError-__reduce__"><strong>__reduce__</strong></a>(...)</dt><dd><tt>helper for pickle</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ProtocolError-__repr__"><strong>__repr__</strong></a>(self, /)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ProtocolError-__setattr__"><strong>__setattr__</strong></a>(self, name, value, /)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ProtocolError-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>
|
|
|
|
<dl><dt><a name="ProtocolError-__str__"><strong>__str__</strong></a>(self, /)</dt><dd><tt>Return str(self).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ProtocolError-with_traceback"><strong>with_traceback</strong></a>(...)</dt><dd><tt><a href="builtins.html#Exception">Exception</a>.<a href="#ProtocolError-with_traceback">with_traceback</a>(tb) --<br>
|
|
set self.<strong>__traceback__</strong> to tb and return self.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
|
|
<dl><dt><strong>__cause__</strong></dt>
|
|
<dd><tt>exception cause</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__context__</strong></dt>
|
|
<dd><tt>exception context</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
</dl>
|
|
<dl><dt><strong>__suppress_context__</strong></dt>
|
|
</dl>
|
|
<dl><dt><strong>__traceback__</strong></dt>
|
|
</dl>
|
|
<dl><dt><strong>args</strong></dt>
|
|
</dl>
|
|
</td></tr></table></td></tr></table><p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#55aa55">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
|
|
<td width="100%"><strong>conf</strong> = {'bot': {'nick': 'PyLink', 'realname': 'PyLink Service Client', 'serverdesc': 'PyLink unit tests', 'user': 'pylink'}, 'logging': {'stdout': 'CRITICAL'}, 'servers': defaultdict(<function <lambda> at 0x7fcfaf78de18>, {})}<br>
|
|
<strong>confname</strong> = 'testconf'<br>
|
|
<strong>curdir</strong> = '/home/gl/pylink'<br>
|
|
<strong>files</strong> = None<br>
|
|
<strong>log</strong> = <logging.RootLogger object><br>
|
|
<strong>logdir</strong> = '/home/gl/pylink/log'<br>
|
|
<strong>logformatter</strong> = <logging.Formatter object><br>
|
|
<strong>stdout_level</strong> = 'CRITICAL'</td></tr></table>
|
|
</body></html> |