Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import time
- network = 'irc.geekshed.net'
- port = 6667
- irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
- irc.connect ( ( network, port ) )
- print irc.recv ( 4096 )
- irc.send ( 'NICK trollestiabot\r\n' )
- irc.send ( 'USER trollestiabot trollestiabot trollestiabot :Python IRC\r\n' )
- irc.send ( 'JOIN #trollestiatest\r\n' )
- time.sleep(6)
- irc.send ( 'PRIVMSG #trollestiatest :Hello World.\r\n' )#sends hello world
- while True:
- data = irc.recv ( 6667 )
- if data.find ( 'PING' ) != -1: #looks for ping
- irc.send ( 'PRIVMSG #trollestiatest :PONG.\r\n')#sends pong
- print data
- ##results
- * trollestiabot (~trollesti@D4C0A099.76B44D0.614F4AC8.IP) has joined #trollestiatest
- <trollestiabot> Hello World.
- <trollestiabot> PONG.
- <trollestiabot> PONG.#about a minlater
- <trollestiabot> PONG.#another min later
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement