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.
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
#!/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.
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.
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.
@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"))
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?
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.
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.