How to announce subs/gifted subs from twitch chat

Hey everyone, I am wondering how I can make my twitch bot notice that there is a sub/gifted sub and send a message to the user saying “thanks for the sub username” any way I can do this is python? Please lmk asap and if you need more info to help just reply what you need thanks!

You’ll need to enable Commands and Tags capabilities

And consume the relevant USERNOTICE’s

You may need to modify or obtain a IRCv3 compatible python library for IRC

WOW! thanks for the fast response! How do I add these capabilities and tags into python? you also mentioned I may have to obtain a new IRCv3? What is that? How do I obtain it?

HERE'S MY CODE:

from future import print_function
import random
import socket, string

Set all the variables necessary to connect to Twitch IRC

HOST = “irc.twitch.tv
NICK = “your twitch id”
PORT = 6667
PASS = “your oauth code”
readbuffer = “”
MODT = False

Connecting to Twitch IRC by passing credentials and joining a certain channel

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

Method for sending a message

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

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

for line in temp:
    # Checks whether the message is PING because its a method of Twitch to check if you're afk
    if (line[0] == "PING :tmi.twitch.tv"):
        s.send(bytes("PONG :tmi.twitch.tv\r\n", "UTF-8"))
        print("PONG SENT")
    else:
        # Splits the given string so we can work with it better
        parts = string.split(line, ":")

        if "QUIT" not in parts[1] and "JOIN" not in parts[1] and "PART" not in parts[1]:
            try:
                # Sets the message variable to the actual message sent
                message = parts[2][:len(parts[2]) - 1]
            except:
                message = ""
            # Sets the username variable to the actual username
            usernamesplit = string.split(parts[1], "!")
            username = usernamesplit[0]
           
            # Only works after twitch is done announcing stuff (MODT = Message of the day)
            if MODT:
                print (username + ": " + message)
               
                # You can add all your plain commands here
 
			
					

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

USING PYTHON: Python 2.7.13 |Enthought, Inc. (x86_64)| (default, Mar 2 2017, 16:05:12) [MSC v.1500 64 bit (AMD64)]
Type “copyright”, “credits” or “license” for more information.

IPython 5.3.0 – An enhanced Interactive Python.
? -> Introduction and overview of IPython’s features.
%quickref -> Quick reference.
help -> Python’s own help system.
object? -> Details about ‘object’, use ‘object??’ for extra details.

The code formatting got messed up while pasting it here dont know why but starts after “HERE’S MY CODE”

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