Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### The only import you need!
- import socket
- import time
- import sys
- import locale
- ### Cooldown variables
- min_call_freq = 10
- threemin = 180
- begintime = 0
- used = {}
- jdnamelst = list()
- jdsongdict = {}
- count = 0
- ### Options (Don't edit)
- SERVER = "irc.twitch.tv" # server
- PORT = 6667 # port
- ### Options (Edit this)
- PASS = "" # bot password can be found on https://twitchapps.com/tmi/
- BOT = "twerkrobot" # Bot's name [NO CAPITALS]
- CHANNEL = "littlesiha" # Channal name [NO CAPITALS]
- OWNER = "criogenesis" # Owner's name [NO CAPITALS]
- MOD = ['criogenesis', 'kompakt', 'dustyn', 'brosephstalin', 'littlesiha', 'unicorn_pudding', 'sammyy']
- # moderator names [NO CAPITALS]
- ################################# Request Features ##################################
- ############ Here is where code goes when concerning song requests ############
- ############################################################################
- import re
- justdancelst = list()
- jdlstcomplete = list()
- justdanceun = 'Just dance unlimited.txt'
- jh = open(justdanceun)
- for line in jh:
- obj = "\'\'\[\[(.*?)\]\]\'\'"
- obj2 = "\[\'(.*?)\'\]"
- parsedata = re.findall(obj, line)
- if len(parsedata) < 1:
- continue
- else:
- justdancelst.append(parsedata)
- justdancelststr = str(justdancelst)[1:-1]
- #print(justdancelststr)
- parsestr = re.findall(obj2, justdancelststr)
- #print(parsestr)
- ### Functions
- def sendMessage(s, message):
- messageTemp = "PRIVMSG #" + CHANNEL + " :" + message
- print(messageTemp)
- s.send((messageTemp + "\r\n").encode())
- def getUser(line):
- separate = line.split(":", 2)
- user = separate[1].split("!", 1)[0]
- return user
- def getMessage(line):
- #print(line)
- global message
- try:
- #lined = line.decode('utf-8')
- #print(lined)
- message = (line.split(":", 2))[2]
- #print('test1')
- except:
- message = ""
- #print('test2')
- return message.lower()
- def joinchat():
- readbuffer_join = "".encode()
- Loading = True
- while Loading:
- readbuffer_join = s.recv(1024)
- readbuffer_join = readbuffer_join.decode()
- temp = readbuffer_join.split("\n")
- readbuffer_join = readbuffer_join.encode()
- readbuffer_join = temp.pop()
- for line in temp:
- Loading = loadingCompleted(line)
- #sendMessage(s, "Chat room joined!")
- print("Bot has joined " + CHANNEL + " Channel!")
- def loadingCompleted(line):
- if ("End of /NAMES list" in line):
- return False
- else:
- return True
- def call_command(command):
- print('Calling command `%s`.' % command)
- def cooldown(command):
- print('You have used command `%s` in the last %u seconds.' % (command, min_call_freq))
- def process_commandfive(command):
- if command not in used:
- used[command] = time.time() - min_call_freq
- if time.time() - used[command] < min_call_freq:
- return False
- else:
- used[command] = time.time()
- return True
- def process_command3min(command):
- if command not in used:
- used[command] = time.time() - threemin
- if time.time() - used[command] < threemin:
- return False
- else:
- used[command] = time.time()
- return True
- def jdusercheck(user):
- if user not in jdnamelst:
- jdnamelst.append(user)
- print('test 1')
- return True
- else:
- return False
- print('test 2')
- def jdsongcheck(song):
- if song in parsestr:
- count = count + 1
- jdsongdict[song] = count
- print('song added')
- print(jdsongdict)
- ### Code runs
- s_prep = socket.socket()
- s_prep.connect((SERVER, PORT))
- s_prep.send(("PASS " + PASS + "\r\n").encode())
- s_prep.send(("NICK " + BOT + "\r\n").encode())
- s_prep.send(("JOIN #" + CHANNEL + "\r\n").encode())
- s = s_prep
- joinchat()
- readbuffer = ""
- def Console(line):
- # gets if it is a user or twitch server
- if "PRIVMSG" in line:
- return False
- else:
- return True
- while True:
- try:
- readbuffer = s.recv(1024)
- readbuffer = readbuffer.decode()
- temp = readbuffer.split("\n")
- readbuffer = readbuffer.encode()
- readbuffer = temp.pop()
- except:
- temp = ""
- for line in temp:
- if line == "":
- break
- # So twitch doesn't timeout the bot.
- if "PING" in line and Console(line):
- msgg = "PONG tmi.twitch.tv\r\n".encode()
- s.send(msgg)
- print(msgg)
- break
- # get user
- user = getUser(line)
- # get message send by user'
- #lineE = line.encode('utf-8')
- message = getMessage(line)
- #print(locale.getpreferredencoding())
- # for you to see the chat from CMD
- #print(user + " > " + message)
- # sends private msg to the user (start line)
- PMSG = "/w " + user + " "
- ################################# Command ##################################
- ############ Here you can add as meny commands as you wish of ! ############
- ############################################################################
- clubquestion = "club"
- tbot = "twerkrobot"
- tbot2 = "twerkbot"
- dancing = "dance"
- twerkrequest = "twerk"
- wtfisthis = "wtf is this"
- dancepls = "dance pls"
- Nut = " n "
- makeitjingle = "make it jingle"
- console = "!console"
- boyfriend = "does she have a boyfriend"
- bf = "does she have a bf"
- sam = "who is sam"
- whatistb = "!whatistbot"
- nosubgift = "!nosubgift"
- nospam = "!nospam"
- petname = "!name"
- requeston = "!requeston"
- requestoff = "!requestoff"
- case = "!case"
- #scheduleformat
- commandlist = ["/me If you're asking if Avery goes to clubs, the answer is no sihaShark","/me sihaButt I shall shake my posterior for you human *twerkles* sihaButt"
- ,"This is what we would like to call dancing, it's really fun sihaGood","Please do not tell her to dance, she will dance when she is ready sihaShark sihaREE","NUT Kreygasm",
- "Avery can't do that song because it includes twerking and she doesn't feel comfortable twerking so stop asking. However I am a bot so I can make twerk sihaShark",
- "/me If you have a big enough room, Siha recommends using the Xbox with the Kinect sihaHype (but keep in mind, the Kinect has been discontinued.) If you don't have a lot of space, the Switch version is great and has bonus choreographies sihaButt and features that other consoles don't have. sihaOmg",
- "/me Yes, Avery has a boyfriend and his name is Sam, his channel is twitch.tv/iamsp00n sihaShark","/me Sam is her boyfriend sihaShark","scheduleformat","Twerkrobot is a handmade bot coded in Python. Criogenesis, one of our mods, made it! sihaHype", "/me Do not ask for a gifted sub even as a joke, you will be timed out as a warning and banned if you ask again sihaShark","/me Do not spam requests in chat, Avery will get to you when she can. If you spam requests we'll time you out as a warning and Ban if you continue","/me Please don't call Avery creepy names of endearment or degrading names. Calling her Littlesiha, Siha, or Avery is okay, but things like 'sexy', 'wife', 'honey', 'babe', etc. will be given a warning purge and timed out after if it continues"
- ,"/me Nancy Drew, you're off the case!","The Just Dance Unlimited request feature has now been started! copy and paste your desired just dance unlimited song (exactly from the wiki) and a vote will be counted to see the top two most requested songs."]
- #if user == OWNER and "!command" in message:
- #sendMessage(s, "This can only be used by the owner")
- #break
- #print(type(message))
- if clubquestion in message and dancing in message and process_commandfive(clubquestion):
- sendMessage(s, commandlist[0])
- break
- if makeitjingle in message and process_commandfive(makeitjingle):
- sendMessage(s, "@" + user + " " + commandlist[5])
- break
- if twerkrequest in message and not tbot in message and not tbot2 in message and process_command3min(twerkrequest):
- sendMessage(s, commandlist[1])
- break
- if wtfisthis in message and process_commandfive(wtfisthis):
- sendMessage(s, "@" + user + " " + commandlist[2])
- break
- if dancepls in message and process_commandfive(dancepls):
- sendMessage(s, "@" + user + " " + commandlist[3])
- break
- #if Nut in message and process_commandfive(Nut):
- #sendMessage(s, commandlist[4])
- if user in MOD and console in message and process_commandfive(console):
- sendMessage(s, commandlist[6])
- break
- if boyfriend in message or bf in message and process_command3min(boyfriend):
- sendMessage(s, commandlist[7])
- break
- if sam in message and process_commandfive(boyfriend):
- sendMessage(s, commandlist[8])
- break
- #if schedule in message and process_command3min(schedule):
- sendMessage(s, commandlist[9])
- if user in MOD and whatistb in message and process_commandfive(whatistb):
- sendMessage(s, commandlist[10])
- break
- if user in MOD and nosubgift in message and process_commandfive(nosubgift):
- sendMessage(s, commandlist[11])
- break
- if user in MOD and nospam in message and process_commandfive(nospam):
- sendMessage(s, commandlist[12])
- break
- if user in MOD and petname in message and process_commandfive(petname):
- sendMessage(s, commandlist[13])
- break
- if user in MOD and requestoff in message and process_commandfive(requestoff):
- jdnamelst = list()
- print('Its off, list cleared')
- print(jdnamelst)
- if jdusercheck(user) and message in parsestr:
- jdsongcheck(message)
- print(jdnamelst)
- continue
- else:
- print('They already requested a song')
- print(jdnamelst)
- break
- while True:
- if user in MOD and case in message and process_commandfive(case):
- count = count + 1
- counts = str(count)
- sendMessage(s, commandlist[14] + " Number of times off the case: " + counts)
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement