Advertisement
Guest User

Untitled

a guest
Apr 17th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.87 KB | None | 0 0
  1. import socket #imports module allowing connection to IRC
  2. import threading #imports module allowing timing functions
  3. import time
  4. import os
  5.  
  6. #sets variables for connection to twitch chat
  7. bot_owner = 'yosofunny'
  8. nick = 'yosofunny' #Bot Name (Twitch.Tv Bot Name)
  9. channel = '#siractionslacks' #Stream Channel (Twitch.Tv Stream)
  10. server = 'irc.twitch.tv' #IRC Server (Server)
  11. password = 'oauth:pj94mf3ebnb4i9subsh7ny4r5t7t29' #Password (oAuth)
  12. deaths = 240
  13. userarray = 'yosofunny',' t765234','oldraiden','The_dopp','vdles','Buttletdota','Happygilman','Heyjobis','Mindz13','Oldraiden','name_name_name_name','Siractionslacks','nlnj_a','Sheepeater_1701'
  14. irc = socket.socket()
  15. irc.connect((server, 6667)) #connects to the server
  16.  
  17. #sends variables for connection to twitch chat
  18. irc.send('PASS ' + password + '\r\n')
  19. irc.send('USER ' + nick + ' 0 * :' + bot_owner + '\r\n')
  20. irc.send('NICK ' + nick + '\r\n')
  21. irc.send('JOIN ' + channel + '\r\n')
  22.  
  23. def message(msg): #function for sending messages to the IRC chat
  24.     global msgsend
  25.     time.sleep( 2 )
  26.     irc.send('PRIVMSG ' + channel + ' :'+msg+'\r\n')
  27.  
  28. while True:
  29.     data = irc.recv(1204)  # gets output from IRC server
  30.     user = data.split(':')[1]
  31.     user = user.split('!')[0]  # determines the sender of the messages
  32.     print data  ##ON/OFF
  33.  
  34.     if data != '':
  35.         if data.find('PING') != -1:
  36.             irc.send(data.replace('PING', 'PONG'))  # responds to PINGS from the server
  37.         print "Pong"
  38.  
  39.         if data.find(channel + ' :!death') != -1:
  40.             if user in userarray:
  41.                 deaths = deaths + 1
  42.                 dirtmaul = "New death count: %d" % deaths
  43.                 message(dirtmaul)  # Change to input/add !newmmr
  44.  
  45.         if data.find(channel + ' :!count') != -1:
  46.             dirtmaul = "Current death count: %d" % deaths
  47.             message(dirtmaul)  # Change to input/add !newmmr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement