Skip to content

Commit

Permalink
Fixed ircclient example (Opps)
Browse files Browse the repository at this point in the history
  • Loading branch information
prologic committed Jul 24, 2014
1 parent 743decf commit 82c6735
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions examples/ircclient.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-


"""Example IRC Client
A basic IRC client with a very basic console interface.
Expand All @@ -11,15 +12,22 @@
"""


import os
from socket import gethostname
from optparse import OptionParser

from circuits.io import stdin

from circuits import handler, Component
from circuits import __version__ as systemVersion
from circuits.net.sockets import TCPClient, Connect
from circuits.net.protocols.irc import IRC, PRIVMSG, USER, NICK, JOIN

from circuits.io import stdin

from circuits.net.events import connect
from circuits.net.sockets import TCPClient

from circuits.protocols.irc import IRC, PRIVMSG, USER, NICK, JOIN


USAGE = "%prog [options] host [port]"
VERSION = "%prog v" + systemVersion
Expand Down Expand Up @@ -68,16 +76,16 @@ def init(self, host, port=6667, opts=None):
IRC(channel=self.channel).register(self)

def ready(self, component):
"""Ready Event
"""ready Event
This event is triggered by the underlying ``TCPClient`` Component
when it is ready to start making a new connection.
"""

self.fire(Connect(self.host, self.port))
self.fire(connect(self.host, self.port))

def connected(self, host, port):
"""Connected Event
"""connected Event
This event is triggered by the underlying ``TCPClient`` Component
when a successfully connection has been made.
Expand All @@ -93,7 +101,7 @@ def connected(self, host, port):
self.fire(NICK(nick))

def numeric(self, source, target, numeric, args, message):
"""Numeric Event
"""numeric Event
This event is triggered by the ``IRC`` Protocol Component when we have
received an IRC Numberic Event from server we are connected to.
Expand All @@ -106,7 +114,7 @@ def numeric(self, source, target, numeric, args, message):
self.fire(NICK(newnick))

def join(self, source, channel):
"""Join Event
"""join Event
This event is triggered by the ``IRC`` Protocol Component when a
user has joined a channel.
Expand All @@ -118,7 +126,7 @@ def join(self, source, channel):
print("--> %s (%s) has joined %s" % (source[0], source, channel))

def notice(self, source, target, message):
"""Notice Event
"""notice Event
This event is triggered by the ``IRC`` Protocol Component for each
notice we receieve from the server.
Expand All @@ -127,7 +135,7 @@ def notice(self, source, target, message):
print("-%s- %s" % (source[0], message))

def message(self, source, target, message):
"""Message Event
"""message Event
This event is triggered by the ``IRC`` Protocol Component for each
message we receieve from the server.
Expand All @@ -140,7 +148,7 @@ def message(self, source, target, message):

@handler("read", channel="stdin")
def stdin_read(self, data):
"""Read Event (on channel ``stdin``)
"""read Event (on channel ``stdin``)
This is the event handler for ``read`` events specifically from the
``stdin`` channel. This is triggered each time stdin has data that
Expand Down

0 comments on commit 82c6735

Please sign in to comment.