Permalink
Browse files

(no commit message)

  • Loading branch information...
Evan Fosmark
Evan Fosmark committed Aug 31, 2010
1 parent 8c160b4 commit e8b9241b4353d9257a66cf495c05c78a72e63215
Showing with 34 additions and 54 deletions.
  1. +1 −39 docs/index.rst
  2. +3 −3 docs/installation.rst
  3. +17 −6 ircutils/bot.py
  4. +7 −2 ircutils/client.py
  5. +1 −2 ircutils/events.py
  6. +3 −0 ircutils/ident.py
  7. +2 −2 setup.py
View
@@ -33,42 +33,4 @@ Reporting a bug
---------------
`Create a bug report </projects/ircutils/newticket?type=defect>`_ on the
IRCUtils project page. If you have a solution to the bug, you are encouraged
-to include it in your report.
-
-
-Oh god how did this get here i am no good with computer
--------------------------------------------------------
-::
-
- ░░░░░░░░██░░░░░░██████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
- ░░░░░░░░████░░██████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
- ░░░░░░░░██▓▓████▓▓██░░░░░░██████████░░░░░░░░░░░░░░░░░░
- ░░░░░░████▓▓▓▓▓▓▓▓██░░██████▓▓▓▓▓▓████░░░░░░░░░░░░░░░░
- ░░░░████▓▓▓▓▓▓▓▓▓▓██████▓▓▓▓▓▓▓▓▓▓▓▓▓▓██░░░░░░████░░░░
- ░░░░██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██████████░░░░
- ░░██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████░░░░
- ░░██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██████
- ░░██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████░░
- ░░██▓▓▓▓▓▓▓▓▓▓▓▓▓▓██████▒▒▒▒▒▒██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██░░░░
- ░░██▓▓▓▓▓▓▓▓▓▓████▒▒▒▒▒▒▒▒▒▒██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██░░░░
- ░░░░██████████▒▒▒▒▒▒▒▒▒▒▒▒██████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████░░
- ░░░░░░░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒██▒▒██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██░░
- ░░░░░░░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██░░
- ░░░░░░░░████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██░░
- ░░░░░░░░████████████▒▒▒▒▒▒████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██░░
- ░░░░░░████░░░░░░░░▓▓██▒▒▒▒██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██░░░░
- ░░░░░░████▓▓░░░░░░░░██▒▒▒▒██████████▓▓▓▓▓▓▓▓▓▓██░░░░░░
- ░░░░░░████░░░░░░░░▓▓██▒▒▒▒██▓▓▒▒▒▒▓▓██▓▓▓▓▓▓██░░░░░░░░
- ░░░░████████████████▒▒▒▒▒▒██▓▓▒▒▓▓▒▒▓▓██▓▓██░░░░░░░░░░
- ░░████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▒▒▓▓▓▓▓▓▓▓████░░░░░░░░░░░░
- ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓██████░░░░░░░░░░░░░░
- ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓██░░░░░░░░░░░░░░
- ░░██████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░░░░░░░░░░░░░
- ░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓██░░░░░░░░░░░░░░
- ░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░░░░░░░░░░░░░
- ░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓██░░░░░░░░░░░░
- ░░██▒▒▒▒▒▒▒▒▒▒██████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████░░░░░░░░░░
- ░░████████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████░░░░░░░░
- ░░░░░░░░░░░░░░░░░░████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██▓▓▓▓██░░░░░░
- ░░░░░░░░░░░░░░░░░░░░████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██▓▓██▓▓██░░░░
- ░░░░░░░░░░░░░░░░░░░░░░████▒▒▒▒▒▒▒▒▒▒▒▒████▓▓▓▓▓▓▓▓██░░
+to include it in your report.
View
@@ -6,7 +6,7 @@ IRCUtils is designed to be compatible with both Windows systems and Linux.
Installing on Windows
---------------------
1. Download the
- `windows installer </download/ircutils/0.1.2/ircutils-0.1.2.exe>`_.
+ `windows installer </download/ircutils/0.1.3/ircutils-0.1.3.exe>`_.
2. Execute the installer and follow the instructions.
3. To make sure everything is working, open up a Python console and type
``import ircutils`` to ensure it has been installed.
@@ -17,13 +17,13 @@ Installing by using easy_install
This is likely the easiest solution on Linux-based machines. Run the
following command::
- easy_install http://dev.guardedcode.com/download/ircutils/0.1.2/ircutils-0.1.2.tar.gz
+ easy_install http://dev.guardedcode.com/download/ircutils/0.1.3/ircutils-0.1.3.tar.gz
Installing from source
----------------------
1. Download the
- `compressed source </download/ircutils/0.1.2/ircutils-0.1.2.tar.gz>`_.
+ `compressed source </download/ircutils/0.1.3/ircutils-0.1.3.tar.gz>`_.
2. Uncompress the file and navigate to the ``setup.py`` file.
3. Run ``python setup.py install``
4. To make sure everything is working, open up a Python console and type
View
@@ -1,5 +1,5 @@
""" This module contains a class for quickly creating bots. It is the highest
-level of abstraction of the IRC protocol available in IRCUtils.
+level of abstraction of the IRC protocol available in ``ircutils``.
"""
try:
@@ -29,6 +29,9 @@ class SimpleBot(client.SimpleClient):
to check that documentation to see more of what is available.
"""
+ def __init__(self, nick):
+ client.SimpleClient.__init__(self, nick)
+ self._autobind_handlers()
def _autobind_handlers(self):
""" Looks for "on_<event-name>" methods on the object and automatically
@@ -40,10 +43,17 @@ def _autobind_handlers(self):
if hasattr(self, name):
handler = getattr(self, name).__func__
self.events[listener_name].add_handler(handler)
-
- def start(self):
- self._autobind_handlers()
- client.SimpleClient.start(self)
+
+ def register_listener(self, event_name, listener):
+ """ Same as :func:`ircutils.client.SimpleClient.register_listener`
+ execpt that if there is a handler in the bot already, it auto-binds it
+ to the listener.
+ """
+ self.events.register_listener(event_name, listener)
+ handler_name = "on_{0}".format(event_name)
+ if hasattr(self, event_name):
+ handler = getattr(self, event_name).__func__
+ self.events[handler_name].add_handler(handler)
class _TestBot(SimpleBot):
@@ -52,9 +62,10 @@ class _TestBot(SimpleBot):
"""
def __init__(self, nick):
SimpleBot.__init__(self, nick)
+ self["any"].add_handler(self.print_line)
self.verbose = True
- def on_any(self, event):
+ def print_line(self, client, event):
kwds = {
"cmd": event.command,
"src": event.source,
View
@@ -26,6 +26,7 @@ class SimpleClient(object):
"""
software = "http://dev.guardedcode.com/projects/ircutils/"
version = (0,1,3)
+ custom_listeners = {}
def __init__(self, nick, mode="+B", auto_handle=True):
self.nickname = nick
@@ -45,7 +46,7 @@ def __getitem__(self, name):
return self.events[name]
def __setitem__(self, name, value):
- self.events[name] = value
+ self.register_listener(name, value)
def _register_default_listeners(self):
@@ -66,6 +67,10 @@ def _register_default_listeners(self):
# RPL_ events
for name in events.replies:
self.events.register_listener(name, events.replies[name]())
+
+ # Custom listeners
+ for name in self.custom_listeners:
+ self.events.register_listener(name, self.custom_listeners[name]())
def _add_built_in_handlers(self):
@@ -157,7 +162,7 @@ def identify(self, ns_password):
This assumes that NickServ is present on the server.
"""
- self.send_message("NickServ", "IDENTIFY %s" % ns_password)
+ self.send_message("NickServ", "IDENTIFY {0}".format(ns_password))
def join_channel(self, channel, key=None):
View
@@ -50,7 +50,7 @@ def dispatch(self, client, event):
# ------------------------------------------------------------------------------
-# > BEGIN EVENT OBJECTS
+# > BEGIN EVENT OBJECTS
# ------------------------------------------------------------------------------
@@ -85,7 +85,6 @@ class MessageEvent(StandardEvent):
from ircutils import bot
class PrinterBot(bot.SimpleBot):
-
def on_message(self, event):
print "<{0}> {1}".format(event.source, event.message)
View
@@ -7,6 +7,8 @@
"""
import asyncore, asynchat
import os
+import socket
+import uuid
def get_operating_system():
@@ -47,6 +49,7 @@ def __init__(self, userid, sock, addr):
asynchat.async_chat.__init__(self, sock)
self.set_terminator("\r\n")
self.userid = userid
+ self.collect_incoming_data = self._collect_incoming_data
def found_terminator(self):
""" When this is activated, it means that the terminator (\r\n) has been
View
@@ -14,7 +14,7 @@
readme_file = os.path.join(os.path.dirname(__file__), 'README')
setup(name='ircutils',
- version='0.1.2',
+ version='0.1.3',
description='IRC framework and utilities. Great for bot creation.',
long_description=open(readme_file).read(),
author='Evan Fosmark',
@@ -24,7 +24,7 @@
platforms="Any",
packages=['ircutils'],
classifiers=[
- "Development Status :: 4 - Beta",
+ "Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",

0 comments on commit e8b9241

Please sign in to comment.