Advertisement
Guest User

jokeBot

a guest
Jul 7th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. from random import randint
  2. import socket
  3.  
  4. network = 'irc.shaw.ca'
  5. port = 6667
  6. irc = socket.socket( socket.AF_INET, socket.SOCK_STREAM)
  7. irc.connect((network, port))
  8. mynick = "TVNJoke"
  9. mychan = "#tvn"
  10. data = irc.recv(4096)
  11.  
  12. network = 'irc.shaw.ca'
  13. port = 6667
  14. irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
  15. irc.connect ( ( network, port ) )
  16. print(irc.recv ( 4096 ))
  17. irc.send ('NICK TVNJoke\r\n'.encode() )
  18. irc.send ( 'USER  TVNJoke TVNJoke TVNJoke :Python IRC\r\n'.encode() )
  19. irc.send ( 'JOIN #TVN\r\n'.encode() )
  20. irc.send ( 'PRIVMSG #TVN :Hello World.\r\n'.encode() )
  21.  
  22. with open('C:\\Python34\\jokeBotlist.txt', 'r') as jokeBotlist:
  23.     jokelist = jokeBotlist.read().splitlines()
  24.     joke = jokelist[randint(0,len(jokelist)-1)]
  25.  
  26. while True:
  27.  
  28.  if data.find('PING'.encode()) != -1:
  29.     irc.send ( 'PONG ' + data.split()[1] + '\r\n'.encode())
  30.  
  31.  if data.find('!joke'.encode()) != -1:
  32.     irc.send( 'PRIVMSG #TVN :' + joke + '\r\n'.encode() )
  33.     joke = jokelist[randint(0,len(jokelist)-1)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement