IRC Bots

Pages: 12
Anyone know of a irc bot that works with quakenet? A customizable one? I tried building a small one but it failed.

My small one code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/python
import socket
import string
tuple = 'webchat.quakenet.org'
nick = 'Maria'
ident = 'Maria'
realname = 'Maria'
irc_sock = socket.socket()
irc_sock.connect(tuple)
irc_sock.send('NICK ' + nick + '\r\n')
irc_sock.send('#cplusplus')
while 1:
    read = irc_sock.recv(500)
    if read =='Maria add to':
        thing = irc_sock.recv(500)
        listinquestion = irc_sock.recv(500)

I tried supybot but it failed.
Last edited on
I'm already connected to that. I want a bot that I can send stuff to and be added to a list on my computer.
Did you even look at my code? It is supposed to automatically read for that certain phrase.
That's not how IRC works.
You should read the RFC.
http://tools.ietf.org/search/rfc2812
Maybe look at the source of some IRC client, too.
Words like 'stuff' and 'thing' aren't very descriptive.
The thing variable is in this case. It means thing to add to list. I thought that was understandable, sorry. How does it work then? The rfc is wicked long. I am just looking for the code fix people.
closed account (3qX21hU5)
I am just looking for the code fix people.


SGH gave you more then enough to get your started on it and simple google search of "Python irc bot tutorial" gives plenty of hits that fit your copy and paste criteria ;p
So I tried:
http://travismccrea.com/2010/02/write-a-basic-python-irc-bot/

And now have the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python

import sys
import socket
import string

HOST="webchat.quakenet.org"
PORT=6667
NICK="TOADBOT"
IDENT="TOADBOT"
REALNAME="toad1359BOT"
CHAN="#cplusplus"
readbuffer=""

s=socket.socket( )
s.connect((HOST, PORT))
s.send("NICK %s\r\n" % NICK)
s.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME))
s.send("JOIN :%s\r\n" % CHAN)
s.send("PRIVMSG %s :%s\r\n" % (CHAN, "Hello There!"))
s.send("PRIVMSG %s :%s\r\n" % (CHAN, "I am a bot"))
34
while 1:
    readbuffer=readbuffer+s.recv(1024)
    temp=string.split(readbuffer, "\n")
    readbuffer=temp.pop( )

for line in temp:
    line=string.rstrip(line)
    line=string.split(line)

if(line[0]=="PING"):
    s.send("PONG %s\r\n" % line[1])


And my error is:
1
2
3
4
5
6
raceback (most recent call last):
  File "C:/Documents and Settings/omitted/Desktop/testbot", line 16, in <module>
    s.connect((HOST, PORT))
  File "C:\Python27\lib\socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond


Again, I am trying to connect to a quakenet server.

Thank you SGH for the links
closed account (Dy7SLyTq)
its irc.quakenet.org
I am now using hexchat scripts and got hello world to print. How do I say in python code, using hexchat,
[code idea]
if (this text line == printed by someone)
{
texttoadd = nextline
listinquestion = nextline }
[/code idea]

EDIT: My code is example code from docs and is
[code]
__module_name__ = "helloworld"
__module_version__ = "1.0"
__module_description__ = "Python module example"

print("Hello world!")
[/code]

but my code doesn't actually send the text just prints it to console so it looks like it sended but actually just was printed to the console.
Last edited on
Just for POC imagine making a Python IRC bot with malicious intent with DDOS functionality and stuff. It would be sick and infecting large servers all in all making a Malware Booter.

I personally never coded Python so if someone else could try it. It would be awesome.
closed account (S6k9GNh0)
Go away.
Definitely not rude at all... :|
@OrionMaster: All major IRC servers have antispam and DoS protections.
@toad: How do you think printf() also sends your messages to an IRC server?
How are they connected in ANY way?

If you'd be reading the example:

s.send("PRIVMSG %s :%s\r\n" % (CHAN, "I am a bot"))

Which means you are sending a:

PRIVMSG #cplusplus :I am a bot\r\n

(Mind the ending newline)
Last edited on
OP said:
... The rfc is wicked long. ...

This kind of statement worries me mostly because the document you are referring to is only about 62 pages long. What was the last book you read? If you've never read one of these before then someone should tell you that a good portion of it will be white space, tables, sample exchanges and error code definitions. So you could probably have a functional understanding of this protocol by reading less then 50 pages. Does it still seem like too much to bother reading?

closed account (Dy7SLyTq)
only 62 pages? when i was trying to build a mail client i remember the protocol guides were like three times that size
In fact you'll be only reading pages about:

How to connect
How to send messages
How to receive messages
How to /me
How to reply to a ping
How to handle a kick/ban
How to know if an error happened
How to know when somebody joins/leaves
How to disconnect

There are plenty of other messages there, like those to retrieve the list of channels, editing modes, sending files, topic changes, invites, motd, whispers and so on.
@EssGeEich

Thanks! for the info but what I meant was use the IRC channel as C&C server in other words use it to stream our commands to all the programmed bots just like the usual IRC botnets out there.

Pages: 12