Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1.  
  2. import socket
  3. server = "redoasis.com"
  4. channel = "#mr.nose"
  5. botnick = "goquin"
  6. pongmessage = ""#thismessage is only seen by the server
  7. def ping():
  8. ircsock.send("PONG :"+ pongmessage +"\n")
  9. def sendmsg(chan , msg):
  10. ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n")
  11. def joinchan(chan):
  12. ircsock.send("JOIN "+ chan +"\n")
  13. def hello():
  14. ircsock.send("PRIVMSG "+ channel +" :Yo\n")
  15.  
  16. ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  17. ircsock.connect((server, 6667))
  18. ircsock.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :goquin.\n")
  19. ircsock.send("NICK "+ botnick +"\n")
  20.  
  21. joinchan(channel)
  22. while 1: # Be careful with these! it might send you to an infinite loop
  23. ircmsg = ircsock.recv(2048)
  24. ircmsg = ircmsg.strip('\n\r')
  25.  
  26.  
  27.  
  28.  
  29.  
  30. print(ircmsg)
  31. if ircmsg.find(":Hello "+ botnick) != -1:
  32. hello()
  33. if ircmsg.find("PING :") != -1:
  34. ping()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement