IRC Bot

By F*U*R*B*Y* on Mar 21, 2007

you can run it on Windows by downloading http://www.python.org/ftp/python/2.5/python-2.5.msi install that

when you want to edit it, right click on the file and hit Edit with IDLE

if you want to run it just double click on it.

It simply makes the bot join the server in this case, irc.snm.co.nz it then joins #paul, when its join privmsg's #paul and yeah

import socket

network = 'irc.snm.co.nz'
port = 6667
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
irc.connect ( ( network, port ) )
print irc.recv ( 4096 )
irc.send ( 'NICK botty\r\n' )
irc.send ( 'USER botty botty botty :Python IRC\r\n' )
irc.send ( 'JOIN #paul\r\n' )
irc.send ( 'PRIVMSG #Paul :Hello World.\r\n' )
while True:
   data = irc.recv ( 4096 )
   if data.find ( 'PING' ) != -1:
      irc.send ( 'PONG ' + data.split() [ 1 ] + '\r\n' )
   if data.find ( '!botty quit' ) != -1:
      irc.send ( 'PRIVMSG #paul :Fine, if you don't want me\r\n' )
      irc.send ( 'QUIT\r\n' )
   if data.find ( 'hi botty' ) != -1:
      irc.send ( 'PRIVMSG #paul :I already said hi...\r\n' )
   if data.find ( 'hello botty' ) != -1:
      irc.send ( 'PRIVMSG #paul :I already said hi...\r\n' )
   if data.find ( 'KICK' ) != -1:
      irc.send ( 'JOIN #paul\r\n' )
   if data.find ( 'cheese' ) != -1:
      irc.send ( 'PRIVMSG #paul :WHERE!!!!!!\r\n' )
   if data.find ( 'slaps botty' ) != -1:
      irc.send ( 'PRIVMSG #paul :This is the Trout Protection Agency. Please put the Trout Down and walk away with your hands in the air.\r\n' )
   print data

Comments

Sign in to comment.
Fike   -  Jul 15, 2011

The person who wrote this didn't test the code by the looks of it. Line:

irc.send ( 'PRIVMSG #paul :Fine, if you don't want me\r\n' )

should be

irc.send ( 'PRIVMSG #paul :Fine, if you don\'t want me\r\n' )

or

irc.send ( "PRIVMSG #paul :Fine, if you don't want me\r\n" )

Also what's with all the spaces everywhere?

 Respond  
AnaBotNowYourGone   -  Jun 05, 2010

I like it. ;) Very good in my opinion. But sometimes this makes my Python freeze... o.o

 Respond  
RJosh   -  Dec 08, 2009

By interpreter i hope you mean python.exe which is the COMMAND LINE for python.

The interpreter that comes with it (IE: IDLE) is a piece of garbage. running things through the command line is much cleaner and easier.

 Respond  
PurplesurgeMirc   -  Nov 26, 2009

@Vesperia
This isn't mircscript, this is python. To run python scripts, you need to download the interpreter.

 Respond  
Vesperia   -  Oct 10, 2009

This makes no sense to me whatsoever. How am I supposed to use it. And why have us download something from another website?

 Respond  
GlobalAnomaly   -  Sep 05, 2009

Oh nice. Helps me understand some concepts used in Python for IRC-based things.

 Respond  
PATX   -  Jul 22, 2009

it is Cazz! its also faster and more useful. u should learn it! it makes programing and devel sooooo much easier!

 Respond  
Cazz   -  Jul 21, 2009

Hmm...python looks mighty easier than PHP :P

 Respond  
PATX   -  Apr 26, 2009

suggestions: dont use raw protical. i recommend circuits or irclib. raw protical times out etc...

helpful links:
http://trac.softcircuit.com.au/circuits
http://python-irclib.sourceforge.net/

 Respond  
PATX   -  Mar 16, 2009

then right click and select open or run

 Respond  
bone282   -  Mar 16, 2009

if you want to run it just double click on it.

not everyone has computer set to execute on double click. 90% or more have it set to open the file on double click

 Respond  
PATX   -  Mar 16, 2009

its works fine.gets a 9

 Respond  
F*U*R*B*Y*   -  Dec 11, 2008

edited to fix the rn to \r\n problem. :)

 Respond  
Hawkee   -  Dec 07, 2008

The \r\n was likely removed inadvertently. This was posted when we had a bug in our system that resulted in the loss of the \'s. This has been corrected now, but the snippet needs to be updated.

 Respond  
Monie   -  Dec 07, 2008

Did it remove the \r\n\ before or is that how it is suppose to be in python?

 Respond  
AdrianF   -  Jun 06, 2008

Can You Add Me Too MSN And Help?
snooopylove@hotmail.com

 Respond  
F*U*R*B*Y*   -  Jun 06, 2008

shrugs works for me.......

 Respond  
AdrianF   -  Jun 06, 2008

i did. nothin happened

 Respond  
F*U*R*B*Y*   -  Jun 06, 2008

filename.py

 Respond  
AdrianF   -  Jun 06, 2008

I Did. Like What Type Of File It Gotta be? I Double click it. nthin happens
wer i putit? help!!!

 Respond  
F*U*R*B*Y*   -  Jun 06, 2008

double click the file.........

 Respond  
AdrianF   -  Jun 06, 2008

i edited it so it would go on my server. BUT how do i run it?

 Respond  
AdrianF   -  Jun 06, 2008

How The Hell Do I Run This SCript In Python?

 Respond  
Viper01   -  May 06, 2008

from what i gather its a Python-coded irc bot .-.

 Respond  
ScoopSiteAddict   -  Feb 16, 2008

Yep pls Describe what it does in your introduction..... :P

 Respond  
Cazz   -  Sep 22, 2007

I don\'t understand what this is for...

 Respond  
Hawkee   -  Mar 21, 2007

Please describe what it does in your Introduction.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.