Skip to content

Commit

Permalink
Added more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Fosmark committed Aug 18, 2010
1 parent aab26a3 commit 648fc2d
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 49 deletions.
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
#show_authors = False

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = 'tango'

# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
Expand Down Expand Up @@ -148,10 +148,10 @@
#html_split_index = False

# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
html_show_sourcelink = False

# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
html_show_sphinx = False

# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
Expand Down
21 changes: 12 additions & 9 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ IRCUtils |version|
It's designed for ease of use for anything you'd need. It also has fast and
simple support for writing bots.

.. note::
These docs were last updated on |today|. Documentation is being added daily,
so be sure to check back again in the future. If there is documentation
that you wish to request,
`file a ticket </projects/ircutils/newticket>`_ on the project page.

Document contents
-----------------

Getting started
----------------
.. toctree::
:maxdepth: 2

intro
installation
tutorial
bot
Expand All @@ -24,10 +28,9 @@ Document contents
ident


Indices and tables
------------------

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

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.
9 changes: 5 additions & 4 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ IRCUtils is designed to be compatible with both Windows systems and Linux.

Installing on Windows
---------------------
1. Navigate to http://dev.guardedcode.com/projects/ircutils and download the
newest version of IRCUtils as a windows installer.
1. Download the
`windows installer </download/ircutils/ircutils-0.1.1.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.


Installing from source
----------------------
1. Navigate to http://dev.guardedcode.com/projects/ircutils grab a copy of the
tar.gz compressed source of the newest version.
1. Download the
`compressed source </download/ircutils/ircutils-0.1.1.tar.gz>`_.
2. ``tar -xsf ircutils-0.1.1.tar.gz``
3. ``cd ircutils-0.1.1/``
4. ``python setup.py install``
Expand Down
3 changes: 0 additions & 3 deletions docs/intro.rst

This file was deleted.

59 changes: 35 additions & 24 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
The 5-Minute Tutorial
Tutorial
=====================

Let's start off with something simple.


Getting warmed up
-----------------
It'll be an IRC bot that that simply responds to any channel message with that
same message. We'll call it `EchoBot`.

Expand All @@ -15,16 +18,13 @@ Next, we'll use the SimpleBot class to build upon::
from ircutils import bot

class EchoBot(bot.SimpleBot):
# The bot is currently empty
# We'll add event handlers next!
pass

if __name__ == "__main__":
echo = EchoBot("echobot")
echo.connect("irc.freenode.com")
echo.start()

Right now, we actually have a working IRC bot; however, it doesn't do anything
other than connect to the server. Let's tell it to connect to #ircutils once it
receives the IRC welcome message::
Right now, we actually have a working IRC bot; however, it isn't able to respond
to any events since we haven't added any event handlers.
Let's tell it to connect to #ircutils once it receives the IRC welcome message::

from ircutils import bot

Expand All @@ -33,11 +33,6 @@ receives the IRC welcome message::
def on_welcome(self, event):
self.join("#ircutils")

if __name__ == "__main__":
echo = EchoBot("echobot")
echo.connect("irc.freenode.com")
echo.start()

Finally, let's provide a handler that any time it recieves a message on a
channel, it outputs that same message to that same channel::

Expand All @@ -51,13 +46,34 @@ channel, it outputs that same message to that same channel::
def on_channel_message(self, event):
self.send_message(event.target, event.message)

Done! This bot will successfully do what we specified. Let's add some code to
run it::

from ircutils import bot

class EchoBot(bot.SimpleBot):
def on_welcome(self, event):
self.join("#ircutils")

def on_channel_message(self, event):
self.send_message(event.target, event.message)
if __name__ == "__main__":
echo = EchoBot("echobot")
echo.connect("irc.freenode.com")
# Create an instance of the bot
# We set the bot's nickname here
echo = EchoBot("echo_bot")
# Let's connect to the host
echo.connect("irc.freenode.com", 6667)
# Start running the bot
echo.start()

Done! This bot will successfully do what we specified. Run it and make sure
everything is working! But hey, that's a bit boring. Let's make it send an

Kick it up a notch
------------------
But hey, that's a bit boring. Let's make it send an
action whenever it joins a channel, and welcome anybody who joins::

from ircutils import bot
Expand All @@ -76,9 +92,4 @@ action whenever it joins a channel, and welcome anybody who joins::
def on_channel_message(self, event):
self.send_message(event.target, event.message)

if __name__ == "__main__":
echo = EchoBot("echobot")
echo.connect("irc.freenode.com")
echo.start()

That's it!
7 changes: 1 addition & 6 deletions ircutils/events.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
"""
Events and event listeners.
Author: Evan Fosmark <me@evanfosmark.com>
Description: This module gets used by client.py for event handling and
management.
""" This module gets used by client.py for event handling and management.
"""
import bisect
import collections
Expand Down

0 comments on commit 648fc2d

Please sign in to comment.