Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket #imports module allowing connection to IRC
- import threading #imports module allowing timing functions
- #sets variables for connection to twitch chat
- bot_owner = 'TwitchPlaysFightingGames'
- nick = 'MagicalCakeBot'
- channel = '#TwitchPlaysFightingGames'
- server = 'irc.twitch.tv'
- password = 'oauth:~redacted~'
- irc = socket.socket()
- irc.connect((server, 6667)) #connects to the server
- #sends variables for connection to twitch chat
- irc.send('PASS ' + password + '\r\n')
- irc.send('USER ' + nick + ' 0 * :' + bot_owner + '\r\n')
- irc.send('NICK ' + nick + '\r\n')
- irc.send('JOIN ' + channel + '\r\n')
- def message(msg): #function for sending messages to the IRC chat
- irc.send('PRIVMSG ' + channel + ' :' + msg + '\r\n')
- while True:
- data = irc.recv(1204) #gets output from IRC server
- print data
- if data.find('PING') != -1:
- irc.send(data.replace('PING', 'PONG')) #responds to PINGS from the server
- if data.find('!test') != -1: #!test command
- message('Hi')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement