Advertisement
GameNationRDF

Python IRC Bot v0.2

Jan 19th, 2014
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.58 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.2"
  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.     text=irc.recv(2040)  
  29.     print (text)  
  30.  
  31.     new_text = text.decode("utf-8")
  32.     var_5 = str("PONG\r\n")
  33.  
  34.     if text.find(bytes("PING","utf-8")) != -1:                          
  35.       irc.send(bytes(var_5,"utf-8"))
  36.  
  37.     if text.find(bytes(">info","utf-8")) != -1:
  38.         irc.send(bytes(("PRIVMSG "+channel+" : "+info+"\r\n"),"utf-8"))
  39.  
  40.     if text.find(bytes(">random","utf-8")) != -1:
  41.         irc.send(bytes(("PRIVMSG "+channel+" : "+ran+"\r\n"),"utf-8"))
  42.  
  43.     if text.find(bytes((owner+": >quit"),"utf-8")) != -1:
  44.         irc.send(bytes(("PRIVMSG "+channel+" : WrytXBot will leave in a moment..\r\n"),"utf-8"))
  45.         time.sleep(1)
  46.         irc.send(bytes("QUIT\r\n","utf-8"))
  47.         sys.exit("User command quit, authentication succesful..")
  48.  
  49.     if text.find(bytes(">crash","utf-8")) != -1:
  50.         irc.send(bytes(("PRIVMSG "+channel+" : NO! /tnt /kick /ban !\r\n"),"utf-8"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement