Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 = 'TwitchPlaysFightingGames'
  6. nick = 'MagicalCakeBot'
  7. channel = '#TwitchPlaysFightingGames'
  8. server = 'irc.twitch.tv'
  9. password = 'oauth:~redacted~'
  10.  
  11. irc = socket.socket()
  12. irc.connect((server, 6667)) #connects to the server
  13.  
  14. #sends variables for connection to twitch chat
  15. irc.send('PASS ' + password + '\r\n')
  16. irc.send('USER ' + nick + ' 0 * :' + bot_owner + '\r\n')
  17. irc.send('NICK ' + nick + '\r\n')
  18. irc.send('JOIN ' + channel + '\r\n')
  19.  
  20. def message(msg): #function for sending messages to the IRC chat
  21. irc.send('PRIVMSG ' + channel + ' :' + msg + '\r\n')
  22.  
  23.  
  24.  
  25. while True:
  26. data = irc.recv(1204) #gets output from IRC server
  27. print data
  28.  
  29. if data.find('PING') != -1:
  30. irc.send(data.replace('PING', 'PONG')) #responds to PINGS from the server
  31. if data.find('!test') != -1: #!test command
  32. message('Hi')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement