mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-20 17:53:04 +01:00
220 lines
15 KiB
HTML
220 lines
15 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html><head><title>Python: module utils</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>utils</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/utils.py">/home/gl/pylink/utils.py</a></font></td></tr></table>
|
|
<p><tt>utils.py - PyLink utilities module.<br>
|
|
<br>
|
|
This module contains various utility functions related to IRC and/or the PyLink<br>
|
|
framework.</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="collections.html">collections</a><br>
|
|
<a href="conf.html">conf</a><br>
|
|
</td><td width="25%" valign=top><a href="importlib.html">importlib</a><br>
|
|
<a href="os.html">os</a><br>
|
|
</td><td width="25%" valign=top><a href="re.html">re</a><br>
|
|
<a href="string.html">string</a><br>
|
|
</td><td width="25%" valign=top><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="utils.html#NotAuthenticatedError">NotAuthenticatedError</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="utils.html#IncrementalUIDGenerator">IncrementalUIDGenerator</a>
|
|
</font></dt><dt><font face="helvetica, arial"><a href="utils.html#ServiceBot">ServiceBot</a>
|
|
</font></dt></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="IncrementalUIDGenerator">class <strong>IncrementalUIDGenerator</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>Incremental UID Generator module, adapted from InspIRCd source:<br>
|
|
https://github.com/inspircd/inspircd/blob/f449c6b296ab/src/server.cpp#L85-L156<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="IncrementalUIDGenerator-__init__"><strong>__init__</strong></a>(self, sid)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="IncrementalUIDGenerator-increment"><strong>increment</strong></a>(self, pos=None)</dt><dd><tt>Increments the UID generator to the next available UID.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="IncrementalUIDGenerator-next_uid"><strong>next_uid</strong></a>(self)</dt><dd><tt>Returns the next unused UID for the server.</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="NotAuthenticatedError">class <strong>NotAuthenticatedError</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><a href="builtins.html#Exception">Exception</a> raised by checkAuthenticated() when a user fails authentication<br>
|
|
requirements.<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%"><dl><dt>Method resolution order:</dt>
|
|
<dd><a href="utils.html#NotAuthenticatedError">NotAuthenticatedError</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="NotAuthenticatedError-__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="NotAuthenticatedError-__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="NotAuthenticatedError-__delattr__"><strong>__delattr__</strong></a>(self, name, /)</dt><dd><tt>Implement delattr(self, name).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="NotAuthenticatedError-__getattribute__"><strong>__getattribute__</strong></a>(self, name, /)</dt><dd><tt>Return getattr(self, name).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="NotAuthenticatedError-__reduce__"><strong>__reduce__</strong></a>(...)</dt><dd><tt>helper for pickle</tt></dd></dl>
|
|
|
|
<dl><dt><a name="NotAuthenticatedError-__repr__"><strong>__repr__</strong></a>(self, /)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="NotAuthenticatedError-__setattr__"><strong>__setattr__</strong></a>(self, name, value, /)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="NotAuthenticatedError-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>
|
|
|
|
<dl><dt><a name="NotAuthenticatedError-__str__"><strong>__str__</strong></a>(self, /)</dt><dd><tt>Return str(self).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="NotAuthenticatedError-with_traceback"><strong>with_traceback</strong></a>(...)</dt><dd><tt><a href="builtins.html#Exception">Exception</a>.<a href="#NotAuthenticatedError-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> <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="ServiceBot">class <strong>ServiceBot</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
|
|
|
|
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="ServiceBot-__init__"><strong>__init__</strong></a>(self, name, default_help=True, default_request=False, default_list=True, nick=None, ident=None, manipulatable=False)</dt><dd><tt>Initialize self. See <a href="#ServiceBot-help">help</a>(type(self)) for accurate signature.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ServiceBot-add_cmd"><strong>add_cmd</strong></a>(self, func, name=None)</dt><dd><tt>Binds an IRC command function to the given command name.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ServiceBot-call_cmd"><strong>call_cmd</strong></a>(self, irc, source, text, called_by=None, notice=True)</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="ServiceBot-help"><strong>help</strong></a>(self, irc, source, args)</dt><dd><tt><command><br>
|
|
<br>
|
|
Gives help for <command>, if it is available.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ServiceBot-listcommands"><strong>listcommands</strong></a>(self, irc, source, args)</dt><dd><tt>takes no arguments.<br>
|
|
<br>
|
|
Returns a list of available commands this service has to offer.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ServiceBot-remove"><strong>remove</strong></a>(self, irc, source, args)</dt></dl>
|
|
|
|
<dl><dt><a name="ServiceBot-reply"><strong>reply</strong></a>(self, irc, text)</dt><dd><tt>Replies to a message using the right service UID.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ServiceBot-request"><strong>request</strong></a>(self, irc, source, args)</dt></dl>
|
|
|
|
<dl><dt><a name="ServiceBot-spawn"><strong>spawn</strong></a>(self, irc=None)</dt></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></td></tr></table><p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#eeaa77">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
|
|
<td width="100%"><dl><dt><a name="-add_cmd"><strong>add_cmd</strong></a>(func, name=None)</dt><dd><tt>Binds an IRC command function to the given command name.</tt></dd></dl>
|
|
<dl><dt><a name="-add_hook"><strong>add_hook</strong></a>(func, command)</dt><dd><tt>Binds a hook function to the given command name.</tt></dd></dl>
|
|
<dl><dt><a name="-applyModes"><strong>applyModes</strong></a>(irc, 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.<br>
|
|
<br>
|
|
This method is deprecated. Use irc.<a href="#-applyModes">applyModes</a>() instead.</tt></dd></dl>
|
|
<dl><dt><a name="-getDatabaseName"><strong>getDatabaseName</strong></a>(dbname)</dt><dd><tt>Returns a database filename with the given base DB name appropriate for the<br>
|
|
current PyLink instance.<br>
|
|
<br>
|
|
This returns '<dbname>.db' if the running config name is PyLink's default<br>
|
|
(config.yml), and '<dbname>-<config name>.db' for anything else. For example,<br>
|
|
if this is called from an instance running as './pylink testing.yml', it<br>
|
|
would return '<dbname>-testing.db'.</tt></dd></dl>
|
|
<dl><dt><a name="-getProtocolModule"><strong>getProtocolModule</strong></a>(protoname)</dt><dd><tt>Imports and returns the protocol module requested.</tt></dd></dl>
|
|
<dl><dt><a name="-isChannel"><strong>isChannel</strong></a>(s)</dt><dd><tt>Returns whether the string given is a valid channel name.</tt></dd></dl>
|
|
<dl><dt><a name="-isHostmask"><strong>isHostmask</strong></a>(text)</dt><dd><tt>Returns whether the given text is a valid hostmask.</tt></dd></dl>
|
|
<dl><dt><a name="-isNick"><strong>isNick</strong></a>(s, nicklen=None)</dt><dd><tt>Returns whether the string given is a valid nick.</tt></dd></dl>
|
|
<dl><dt><a name="-isServerName"><strong>isServerName</strong></a>(s)</dt><dd><tt>Returns whether the string given is a valid IRC server name.</tt></dd></dl>
|
|
<dl><dt><a name="-loadModuleFromFolder"><strong>loadModuleFromFolder</strong></a>(name, folder)</dt><dd><tt>Imports and returns a module, if existing, from a specific folder.</tt></dd></dl>
|
|
<dl><dt><a name="-parseModes"><strong>parseModes</strong></a>(irc, 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')]<br>
|
|
<br>
|
|
This method is deprecated. Use irc.<a href="#-parseModes">parseModes</a>() instead.</tt></dd></dl>
|
|
<dl><dt><a name="-registerService"><strong>registerService</strong></a>(name, *args, **kwargs)</dt><dd><tt>Registers a service bot.</tt></dd></dl>
|
|
<dl><dt><a name="-unregisterService"><strong>unregisterService</strong></a>(name)</dt><dd><tt>Unregisters an existing service bot.</tt></dd></dl>
|
|
</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>hostmaskRe</strong> = re.compile('^\\S+!\\S+@\\S+$')<br>
|
|
<strong>log</strong> = <logging.RootLogger object></td></tr></table>
|
|
</body></html> |