private void Connect()
    {
        //Set up connection
        ConnectionCredentials connectionCredentials = new ConnectionCredentials("botty_120", SecretGetter.Api_Token);

        client = new Client();
        pubSub = new PubSub();
        api.Settings.ClientId    = SecretGetter.Client_id;
        api.Settings.AccessToken = SecretGetter.Api_Token;
        client.Initialize(connectionCredentials, channel_name, '!', '!', true);
        client.OverrideBeingHostedCheck = true;
        pubSub.Connect();

        //Bot Subscriptions
        client.OnChatCommandReceived += Client_OnChatCommandReceived;
        client.OnConnected           += Client_OnConnected;
        client.OnDisconnected        += Client_OnDisconnected;

        client.OnBeingHosted    += Client_OnBeingHosted;
        client.OnHostingStopped += Client_OnHostingStopped;

        SubscribeToPubSub();

        client.Connect(); //Connect
        Debug.Log("Connecting!");
    }
예제 #2
0
 public void EscutaEventos()
 {
     if (_pubSub == null)
     {
         _pubSub = new PubSub();
         _pubSub.OnRewardRedeemed         += _pubSub_OnRewardRedeemed;
         _pubSub.OnPubSubServiceConnected += _pubSub_OnPubSubServiceConnected;;
         _pubSub.Connect();
         StartTwitchGame();
     }
 }
예제 #3
0
        private void Start()
        {
            // To keep the Unity application active in the background, you can enable "Run In Background" in the player settings:
            // Unity Editor --> Edit --> Project Settings --> Player --> Resolution and Presentation --> Resolution --> Run In Background
            // This option seems to be enabled by default in more recent versions of Unity. An aditional, less recommended option is to set it in code:
            // Application.runInBackground = true;

            // Create new instance of PubSub Client
            _pubSub = new PubSub();

            // Subscribe to Events
            _pubSub.OnWhisper += OnWhisper;
            _pubSub.OnPubSubServiceConnected += OnPubSubServiceConnected;

            // Connect
            _pubSub.Connect();
        }
예제 #4
0
        public static void Start()
        {
            Client.Initialize(Credentials);

            Client.OnConnected     += Client_OnConnected;
            Client.OnDisconnected  += Client_OnDisconnected;
            Client.OnJoinedChannel += Client_OnJoinedChannel;
            Client.OnLeftChannel   += Client_OnLeftChannel;

            Client.OnMessageReceived    += Client_OnMessageReceived;
            Client.OnWhisperReceived    += Client_OnWhisperReceived;
            Client.OnModeratorsReceived += Client_OnModeratorsReceived;

            PubSub.OnPubSubServiceConnected += Pubsub_OnPubSubServiceConnected;
            PubSub.OnListenResponse         += PubSub_OnListenResponse;
            PubSub.OnStreamUp   += PubSub_OnStreamUp;
            PubSub.OnStreamDown += PubSub_OnStreamDown;
            PubSub.ListenToVideoPlayback("maerictv");

            Client.OnHostingStarted   += Client_OnHostingStarted;
            Client.OnHostingStopped   += Client_OnHostingStopped;
            Client.OnBeingHosted      += Client_OnBeingHosted;
            Client.OnRaidNotification += Client_OnRaidNotification;

            Client.OnNewSubscriber         += Client_OnNewSubscriber;
            Client.OnReSubscriber          += Client_OnReSubscriber;
            Client.OnCommunitySubscription += Client_OnCommunitySubscription;
            Client.OnGiftedSubscription    += Client_OnGiftedSubscription;

            for (int i = 0; i < 99; i++)
            {
                try
                {
                    Client.Connect();
                    PubSub.Connect();
                }
                catch (Exception e)
                {
                    BotTools.LogToSessionLogFile(e.ToString());
                }
            }

            StreamStatus = GetStreamOnline() ? StreamState.Online : StreamState.Offline;
        }
예제 #5
0
        static void Main(string[] args)
        {
            if (Configs.CheckSetup() == false)
            {
                Configs.FirstTimeSetup();
            }

            TwitchChatBot bot    = new TwitchChatBot();
            PubSub        pubSub = new PubSub(ref bot);

            bot.Connect();
            pubSub.Connect();

            do
            {
                var input = Console.ReadLine();
                if (input.ToLowerInvariant() == "exit")
                {
                    bot.Disconnect();
                    pubSub.Disconnect();
                    Environment.Exit(0);
                }
                else
                {
                    if (input.StartsWith("/w"))
                    {
                        string[] substrings = input.Split();
                        string   receiver   = substrings[1];
                        string   message    = "";
                        int      target     = substrings.Length;

                        for (int i = 2; i < target; i++)
                        {
                            message += $"{substrings[i]} ";
                        }
                        bot.ManualWhisper(receiver, message);
                    }
                    else
                    {
                        bot.ManualMessage(input);   // Dev testing to send messages to chat, remove when unnecessary
                    }
                }
            } while (GlobalOptions.IsConnected == true);
        }
 private void Start()
 {
     // Connect
     _pubSub.Connect();
 }