Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import socket
  2. import time
  3. network = 'irc.geekshed.net'
  4. port = 6667
  5. irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
  6. irc.connect ( ( network, port ) )
  7. print irc.recv ( 4096 )
  8. irc.send ( 'NICK trollestiabot\r\n' )
  9. irc.send ( 'USER trollestiabot trollestiabot trollestiabot :Python IRC\r\n' )
  10. irc.send ( 'JOIN #trollestiatest\r\n' )
  11. time.sleep(6)
  12. irc.send ( 'PRIVMSG #trollestiatest :Hello World.\r\n' )#sends hello world
  13. while True:
  14. data = irc.recv ( 6667 )
  15. if data.find ( 'PING' ) != -1: #looks for ping
  16. irc.send ( 'PRIVMSG #trollestiatest :PONG.\r\n')#sends pong
  17. print data
  18. ##results
  19.  
  20. * trollestiabot (~trollesti@D4C0A099.76B44D0.614F4AC8.IP) has joined #trollestiatest
  21. <trollestiabot> Hello World.
  22. <trollestiabot> PONG.
  23. <trollestiabot> PONG.#about a minlater
  24. <trollestiabot> PONG.#another min later
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement