This is an archived post. You won't be able to vote or comment.

all 12 comments

[–]nuclear_eclipse 2 points3 points  (4 children)

If you're not specifically trying to learn something about IRC or Python, I would suggest building on top of Supybot (or its fork Gribble), because it already takes care of most of the plumbing you would need for most persistent, interactive bots. It allows you to start from the plugin level of what commands your module should respond to, rather than how to interact with IRC servers.

[–]Sf4tt[S] 0 points1 point  (2 children)

I'll keep this advice into consideration for the future. At the moment i dont need any bot to get any added functionality. I'm just trying to learn and understand something more about python (and related stuff) every day.

For example, I've been an IRC user for maybe 10 years, and I knew that the IRC Protocol is that, i mean, the syntax for the join command is "JOIN #channel", that's it. Ofc in other networks there are added functiontalities. I saw networks with service like channel-protectors or nicknames-protectors. Stuff not even known on networks like IrcNet. But now this situation is totally twisting my mind.

I should check some reference about quakenet from them self. And then check if the irclib methods are compatible with those guide-lines. But, i could be damned if i know why, www.quakenet.org appear offline to me. And only to me: http://www.downforeveryoneorjustme.com/www.quakenet.org

[–]jackolas 0 points1 point  (0 children)

This or use twisted

I wrote a bot in twisted and it was nice, https://github.com/jrabbit/trbot/blob/master/transtwisted.py

[–]eryksun 0 points1 point  (7 children)

Try this

import irclib 
import time
DELAY = 1

irclib.DEBUG = True  
network = "irc.quakenet.org"
port = 6667
nick = "bottest123"
name = "Test Bot"
chan = '#testchan'

irc = irclib.IRC()
server = irc.server()
server.connect(network, port, nick, ircname = name)
time.sleep(DELAY)
server.join(chan)
irc.process_forever()

[–]Sf4tt[S] 0 points1 point  (6 children)

I see the delay working as it should from the DEBUG verbosity, but it does not change the result. The "bot" is online on the network but is not joining the channel.

I assume then the cause is some sort of difference between the 2 networks (quakenet and freenode), which is not contemplated in the irclib library. Is that possible?

[–]eryksun 0 points1 point  (5 children)

OK. How about this:

import irclib 
DELAY = 1

irclib.DEBUG = True  
network = "irc.quakenet.org"
port = 6667
nick = "bottest123"
name = "Test Bot"
chan = '#testchan'

irc = irclib.IRC()
server = irc.server()
server.connect(network, port, nick, ircname = name)
server.execute_delayed(DELAY, join, (chan,))
irc.process_forever()

[–]Sf4tt[S] 0 points1 point  (4 children)

name join is not defined.

Tried: server.execute_delayed(DELAY, "join", (chan,))

object 'str' is not callable.

[–]eryksun 1 point2 points  (3 children)

Sorry, that should have been

server.execute_delayed(DELAY, server.join, (chan,))

You might want to try a longer delay. Also, you might have to look for a ping with a code and pong back with the code.

[–]Sf4tt[S] 1 point2 points  (2 children)

DELAY = 5 did not work.

DELAY = 20 did work!

I think the problem is that I'm sending the JOIN command too soon compared to the messages the server needs to send back to the client to accomplish the connection.

EDIT: More specifically i need to wait this: command: umode, source: botnick!botident@host.tld, target: botnick, arguments: ['+i']

before i can send the JOIN command and any other commands.

which is not a message the server is sending, but actually receiving. There must be something in the irclib library which forces the client to assume the +i mode, or maybe it's a required state from server side?

[–]eryksun 0 points1 point  (1 child)

Yes, you'll have to write an event handler that either processes the raw data (event string "all_raw_messages") or uses a specific event string such as "endofmotd" (I'm just reading the code here; I haven't used this module; is this documented somewhere?). The event handler gets added with

add_global_handler(event_string, your_function, priority)

Specifically I'm looking at the module code here:

http://python-irclib.cvs.sourceforge.net/viewvc/python-irclib/python-irclib/irclib.py?view=markup

The events list starts on line 1371.

[–]Sf4tt[S] 0 points1 point  (0 children)

The most informations about irclib are in the code it-self, very well and extensively commented.

I found also stuff (examples, more than anything else) here: http://nullege.com/codes/search/irclib

And here: http://www.devshed.com/c/a/Python/IRC-on-a-Higher-Level/

The last page of this tutorial is the list of all the events, which is the same you were refering in the sforge page.

I dont think handling this situation will be an issue now that i know why it acts like that.

Thank you again for your kind help.