Python, custom twitch chat bot with commands

Hello guys. I want add custom command into my python file which maked to twitch custom chat bot. I didn’t want how I can add new command. Can you help me? I attach my python file.
From :czech_republic:

import socket, string

HOST = “irc.twitch.tv
NICK = “Dispecer”
PORT = 6667
PASS = “oauth:CENSORED”
readbuffer = “”
MODT = False

s = socket.socket()
s.connect((HOST, PORT))
s.send("PASS " + PASS + “\r\n”)
s.send("NICK " + NICK + “\r\n”)
s.send(“JOIN #cztomzz \r\n”)

def Send_message(message):
s.send(“PRIVMSG #cztomzz :” + message + “\r\n”)

while True:
readbuffer = readbuffer + s.recv(1024)
temp = string.split(readbuffer, “\n”)
readbuffer = temp.pop()

for line in temp:
    if (line[0] == "PING"):
        s.send("PONG %s\r\n" % line[1])
    else:
        parts = string.split(line, ":")

        if "QUIT" not in parts[1] and "JOIN" not in parts[1] and "PART" not in parts[1]:
            try:
                message = parts[2][:len(parts[2]) - 1]
            except:
                message = ""
            usernamesplit = string.split(parts[1], "!")
            username = usernamesplit[0]

            if MODT:
                print username + ": " + message
               
                if message == "cau":
					Send_message (username + " Vitej na streamu ")

            for l in parts:
                if "End of /NAMES list" in l:
                    MODT = True

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.