Guest User

Twitch Bot

a guest
Jan 31st, 2016
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. import socket #imports module allowing connection to IRC
  2. import threading #imports module allowing timing functions
  3.  
  4. #sets variables for connection to twitch chat
  5. bot_owner = 'DevinP6576'
  6. nick = 'devin6576_bot'
  7. channel = 'DevinP6576'
  8. server = 'irc.twitch.tv'
  9. password = 'oauth:8y8u6m85ksyzhcchfrdym4o475idor'
  10.  
  11. queue = 13 #sets variable for anti-spam queue functionality
  12.  
  13. irc = socket.socket()
  14. irc.connect((server, 6667)) #connects to the server
  15.  
  16. #sends variables for connection to twitch chat
  17. irc.send('PASS ' + password + '\r\n')
  18. irc.send('USER ' + nick + ' 0 * :' + bot_owner + '\r\n')
  19. irc.send('NICK ' + nick + '\r\n')
  20. irc.send('JOIN ' + channel + '\r\n')
  21.  
  22.  
  23. while True:
  24. babadata = irc.recv(1204) #gets output from IRC server
  25. babauser = babadata.split(':')[1]
  26. babauser = babauser.split('!')[0] #determines the sender of the messages
  27. print (babadata)
  28.  
  29. if babadata.find('PING') != -1:
  30. irc.send(babadata.replace('PING', 'PONG')) #responds to PINGS from the server
  31.  
  32.  
  33. user = getUser(line)
  34. message = getMessage(line)
  35. print (user) + " typed :" + message
  36. if "hi" in message:
  37. sendMessage(s, "Hi!")
  38. break
Add Comment
Please, Sign In to add comment