Advertisement
Guest User

Untitled

a guest
Oct 16th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.10 KB | None | 0 0
  1. import time
  2. import socket
  3. import string
  4. import sys
  5. import threading
  6. import json # for loading json's for emoticons
  7. import urllib.request # more for loadings jsons from urls
  8. import collections # for deque
  9. from decimal import *
  10. import operator # for sorting dictionary by value
  11. from random import choice
  12. import os # to allow directory exists checking etc.
  13. import requests
  14. import pymysql
  15.  
  16.  
  17. AdminUserName = "xereborn"                          # This username will be able to use admin commands and bypass some limits.
  18. nick = 'xereborn'                                       #alter this value with the username used to connect to IRC eg: "xcomreborn".
  19. channel = '#xereborn'                                   #alter this value with the channel name for your channel eg: "#xcomreborn".
  20. password = "oauth:zzzzzzzzzzzzzzzzzzz"      #alter this value with the password used to connect to IRC from the username above.
  21. server = 'irc.twitch.tv'
  22. port = 6667
  23.  
  24. #create IRC socket
  25. irc = socket.socket()
  26.  
  27. #irc send message buffer
  28. ircMessageBuffer = collections.deque()
  29.  
  30.  
  31. irc.connect((server, port))
  32.  
  33. #sends variables for connection to twitch chat
  34. irc.send(('PASS ' + password + '\r\n').encode("utf8"))
  35. irc.send(('USER ' + nick + '\r\n').encode("utf8"))
  36. irc.send(('NICK ' + nick + '\r\n').encode("utf8"))
  37. irc.send(('JOIN ' + channel + '\r\n').encode("utf8"))
  38.  
  39. #create readbuffer to hold strings from IRC
  40. readbuffer = ""
  41.  
  42. #SendPrivateMessageToIRC("/mod xcoinbetbot")
  43.  
  44. # This is the main loop
  45. while 1:
  46.     readbuffer= readbuffer+irc.recv(1024).decode("utf-8")
  47.     #temp=str.split(readbuffer, "\n")
  48.     #readbuffer=temp.pop( )
  49.    
  50.     for line in temp:
  51.         line=str.rstrip(line)
  52.         line=str.split(line)
  53.         print (str(line).encode('utf8'))
  54.        
  55.         if (len(line) >= 4) and ("PRIVMSG" == line[1]) and not ("jtv" in line[0]):
  56.             #call function to handle user message
  57.             UserMessage(line)
  58.         if (len(line) >= 3) and ("JOIN" == line[1]):
  59.             pass
  60.             # call function to handle join messages
  61.             #UserJoined(line)
  62.         if (len(line) >= 5) aso nd ("MODE" == line[1]):
  63.             pass
  64.             # call function to assign and remove OPs
  65.             #AssignOPs(line)
  66.         if(line[0]=="PING"):
  67.             irc.send(("PONG %s\r\n" % line[0]).encode("utf8"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement