Skip to content

PubSub not registering any events incoming from Twitch #62

@NanoSNAkeR

Description

@NanoSNAkeR

I Started having problems with the PubSub service all of a sudden, It's not getting any input from twitch events. The strange thing is it used to work without a problem right before I started a stream, now it just says that everything connects successfully but it doesn't register any events incoming from Twitch, like channel points redeems, whispers or follows... I don't know what else to do...

Here's my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TwitchLib.Unity;
using TwitchLib.PubSub;
using TwitchLib.PubSub.Events;

public class TwitchPubSubTest : MonoBehaviour
{
    private PubSub _pubSub;

    //public string currentReward = "";
    //public string latestFollower = "";

    // Start is called before the first frame update
    void Start()
    {
        Application.runInBackground = true;

        _pubSub = new PubSub();

        _pubSub.OnChannelPointsRewardRedeemed += OnChannelPointsRewardRedeemed;
        //_pubSub.OnFollow += _pubSub_OnFollow;
        _pubSub.OnWhisper += OnWhisper;
        _pubSub.OnListenResponse += OnListenResponse;
        _pubSub.OnPubSubServiceConnected += OnPubSubServiceConnected;

        _pubSub.Connect();
    }

    

    private void OnPubSubServiceConnected(object sender, System.EventArgs e)
    {
        Debug.Log("PubSubServiceConnected!");

        // CHANNEL_ID is the streamer channel ID the one that is like 12345678.
        // CHANNEL_ACCESS_TOKEN is the channel oauth token, which is validated for everything.

        _pubSub.ListenToWhispers(Secrets.CHANNEL_ID);
        _pubSub.ListenToChannelPoints(Secrets.CHANNEL_ID);
        //_pubSub.ListenToFollows(Secrets.CHANNEL_ID);
        _pubSub.SendTopics(Secrets.CHANNEL_ACCESS_TOKEN);
    }

    private void OnListenResponse(object sender, OnListenResponseArgs e)
    {
        if (e.Successful)
        {
            Debug.Log($"Successfully verified listening to topic: {e.Topic}");
        }
        else
        {
            Debug.Log($"Failed to listen! Error: {e.Response.Error}");
        }
    }

    //private void _pubSub_OnFollow(object sender, OnFollowArgs e)
    //{
    //    Debug.Log($"{e.Username}" + " Has followed!");
    //    latestFollower = $"{e.Username}";
    //    FollowThanks.instance.StartAction(latestFollower);
    //}

    private void OnChannelPointsRewardRedeemed(object sender, OnChannelPointsRewardRedeemedArgs e)
    {
        Debug.Log("A channel reward has been redeemed! " + $"{e.RewardRedeemed.Redemption.Reward.Title}");
        //currentReward = $"{e.RewardRedeemed.Redemption.Reward.Title}";
    }

    private void OnWhisper(object sender, OnWhisperArgs e)
    {
        Debug.Log($"{e.Whisper.Data}");
    }
}

And here's the console log for the script... as you can see it verifies everything successfully...

response

Also the other services, such as the Client and the API work correctly without any errors, bot reads chat, reads viewers, can answer to callouts etc...

If anyone can help I would appreciate it a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions