Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### The only import you need!
- import socket
- import time
- ### Cooldown variables
- min_call_freq = 5
- begintime = 0
- used = {}
- ### Options (Don't edit)
- SERVER = "irc.twitch.tv" # server
- PORT = 6667 # port
- ### Options (Edit this)
- PASS = "oauth:rsxogjf9zuvtqm6q5o7ujxowesw4cn" # 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]
- ### Functions
- def sendMessage(s, message):
- messageTemp = "PRIVMSG #" + CHANNEL + " :" + message
- s.send((messageTemp + "\r\n").encode())
- def getUser(line):
- separate = line.split(":", 2)
- user = separate[1].split("!", 1)[0]
- return user
- def getMessage(line):
- global message
- #try:
- #lined = line.decode('utf-8')
- #print(lined)
- #message = (line.split(":", 2))[2]
- print('test1')
- #except:
- lined = line.decode('utf-8)')
- message = (lined.split(":", 2))[2]
- print('test2')
- return message
- 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_command(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
- ### 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(lineE)
- # 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"
- dancing = "dance"
- twerkrequest = "twerk"
- wtfisthis = "wtf is this"
- extreme = "extreme"
- Nut = " N "
- makeitjingle = "make it jingle"
- console = "!console"
- #if user == OWNER and "!command" in message:
- #sendMessage(s, "This can only be used by the owner")
- #break
- print(type(message))
- if clubquestion and dancing in message and process_command(clubquestion):
- sendMessage(s, "/me If you're asking if Avery goes to clubs, the answer is no")
- if twerkrequest in message and process_command(twerkrequest):
- sendMessage(s, "/me I shall shake my posterior for you human *twerkles*")
- if wtfisthis in message and process_command(wtfisthis):
- sendMessage(s, "@" + user + " " + "This is what we would like to call dancing, it's really fun")
- if extreme in message and process_command(extreme):
- sendMessage(s, "/me Do you want her to die?")
- if Nut in message and process_command(Nut):
- sendMessage(s, "NUT Kreygasm")
- if makeitjingle in message and process_command(makeitjingle):
- sendMessage(s, "@" + user + " " + "Avery can't do that song because it includes twerking and that is against TOS. However I am a bot so I can make twerk")
- if console in message and process_command(console):
- sendMessage(s, "/me If you have a big enough room, Siha recommends using the Xbox with the Kinect (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 and features that other consoles don't have.")
- ############################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement