Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import socket
- import string
- import sys
- import threading
- import json # for loading json's for emoticons
- import urllib.request # more for loadings jsons from urls
- import collections # for deque
- from decimal import *
- import operator # for sorting dictionary by value
- from random import choice
- import os # to allow directory exists checking etc.
- import requests
- import pymysql
- AdminUserName = "xereborn" # This username will be able to use admin commands and bypass some limits.
- nick = 'xereborn' #alter this value with the username used to connect to IRC eg: "xcomreborn".
- channel = '#xereborn' #alter this value with the channel name for your channel eg: "#xcomreborn".
- password = "oauth:zzzzzzzzzzzzzzzzzzz" #alter this value with the password used to connect to IRC from the username above.
- server = 'irc.twitch.tv'
- port = 6667
- #create IRC socket
- irc = socket.socket()
- #irc send message buffer
- ircMessageBuffer = collections.deque()
- irc.connect((server, port))
- #sends variables for connection to twitch chat
- irc.send(('PASS ' + password + '\r\n').encode("utf8"))
- irc.send(('USER ' + nick + '\r\n').encode("utf8"))
- irc.send(('NICK ' + nick + '\r\n').encode("utf8"))
- irc.send(('JOIN ' + channel + '\r\n').encode("utf8"))
- #create readbuffer to hold strings from IRC
- readbuffer = ""
- #SendPrivateMessageToIRC("/mod xcoinbetbot")
- # This is the main loop
- while 1:
- readbuffer= readbuffer+irc.recv(1024).decode("utf-8")
- #temp=str.split(readbuffer, "\n")
- #readbuffer=temp.pop( )
- for line in temp:
- line=str.rstrip(line)
- line=str.split(line)
- print (str(line).encode('utf8'))
- if (len(line) >= 4) and ("PRIVMSG" == line[1]) and not ("jtv" in line[0]):
- #call function to handle user message
- UserMessage(line)
- if (len(line) >= 3) and ("JOIN" == line[1]):
- pass
- # call function to handle join messages
- #UserJoined(line)
- if (len(line) >= 5) aso nd ("MODE" == line[1]):
- pass
- # call function to assign and remove OPs
- #AssignOPs(line)
- if(line[0]=="PING"):
- irc.send(("PONG %s\r\n" % line[0]).encode("utf8"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement