Advertisement
GameNationRDF

Python IRC Bot v0.1

Jan 19th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.01 KB | None | 0 0
  1. import socket
  2. import sys
  3. import random
  4. import time
  5.  
  6. server = "irc.freenode.net"      
  7. channel = "#OREServerChat"
  8. botnick = "WrytXBot"
  9. owner = "WrytXander"
  10. info = "Python 3.3, WrytXBot v0.1"
  11.  
  12. var_1 = str("NICK "+ botnick +"\n")
  13. var_2 = str("USER "+ botnick +" "+ botnick +" "+ botnick +" : IRC Bot by WrytXander\n")
  14. var_3 = str("PRIVMSG nickserv : /say\r\n")
  15. var_4 = str("JOIN "+ channel +"\n")
  16.  
  17. irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  18. irc.connect((server, 6667))
  19. irc.send(bytes(var_1,"utf-8"))
  20. irc.send(bytes(var_2,"utf-8"))                      
  21. irc.send(bytes(var_3,"utf-8"))  
  22. irc.send(bytes(var_4,"utf-8"))
  23.  
  24. while True:
  25.  
  26.     ran=str(random.randint(0,10000))
  27.    
  28.    
  29.     text=irc.recv(2040)  
  30.     print (text)  
  31.  
  32.     new_text = text.decode("utf-8")
  33.     var_5 = str("PONG\r\n")
  34.  
  35.     if text.find(bytes("PING","utf-8")) != -1:                          
  36.       irc.send(bytes(var_5,"utf-8"))
  37.  
  38.     if text.find(bytes(">info","utf-8")) != -1:
  39.         irc.send(bytes(("PRIVMSG "+channel+" : "+info+"\r\n"),"utf-8"))
  40.  
  41.     if text.find(bytes(">random","utf-8")) != -1:
  42.         irc.send(bytes(("PRIVMSG "+channel+" : "+ran+"\r\n"),"utf-8"))
  43.  
  44.     #if text.find(bytes(">say","utf-8")) != -1:
  45.         #li = text.split(bytes(">say ","utf-8"))
  46.         #st = li[1].strip()
  47.         #if st == ("") or st == (" ") or st == ("."):
  48.             #irc.send(bytes(("PRIVMSG"+channel+" : Imma not say that nigg' !\r\n"),"utf-8"))
  49.         #else:
  50.             #irc.send(bytes(("PRIVMSG"+channel+st+"\r\n"),"utf-8"))
  51.            
  52.        
  53.         irc.send(bytes("","utf-8"))
  54.  
  55.     if text.find(bytes((owner+": >quit"),"utf-8")) != -1:
  56.         irc.send(bytes(("PRIVMSG "+channel+" : WrytXBot will leave in a moment..\r\n"),"utf-8"))
  57.         time.sleep(1)
  58.         irc.send(bytes("QUIT\r\n","utf-8"))
  59.         sys.exit("User command quit, authentication succesful..")
  60.  
  61.     if text.find(bytes(">crash","utf-8")) != -1:
  62.         irc.send(bytes(("PRIVMSG "+channel+" : NO! /tnt /kick /ban !\r\n"),"utf-8"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement