Ejemplo n.º 1
0
        internal void Connect()
        {
            Console.WriteLine("Connecting...");

            // Client Connect
            client = new TwitchClient(linkage);
            client.Initialize(botCred, Credentials.ChannelName);
            breakPedal = new Throttlers(linkage, TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(60));

            while (commandSwitch < 0 || commandSwitch > 3)
            {
                commandSwitch = Convert.ToInt16(WBF.gameQuestion());
            }

            masterList = WBF.UserTake(masterList);

            if (commandSwitch == 1 || commandSwitch == 2)
            {
                barracks = WBF.SoldierTake(barracks);
            }
            else if (commandSwitch == 3)
            {
                npc = WBF.NPC_Take(npc);
            }
            else
            {
                ;
            }

            client.OnConnected     += On_Connected;
            client.OnJoinedChannel += On_JoinedChennel;

            client.OnUserJoined += On_UserJoined;
            client.OnUserLeft   += On_UserLeft;

            client.AddChatCommandIdentifier('!');
            client.OnChatCommandReceived += On_CommandReceived;
            client.AddWhisperCommandIdentifier('!');
            client.OnWhisperCommandReceived += On_WhisperCommandReceived;

            client.OnBeingHosted      += On_BeingHosted;
            client.OnRaidNotification += On_BeingRaided;

            client.OnGiftedSubscription += On_GiftedSub;
            client.OnNewSubscriber      += On_NewSub;
            client.OnReSubscriber       += On_ReSub;

            client.OnMessageThrottled += On_MessageThrottle;
            client.OnWhisperThrottled += On_WhisperThrottle;

            client.Connect();

            upTimer();
        }
Ejemplo n.º 2
0
        // Call bot to connect
        internal void Connect()
        {
            consoleMessage[5] = "Initializing Twitch Chat Bot...";
            Program.SendToConsole(consoleMessage);
            client = new TwitchClient(credentials, streamerChannel, logging: false);

            consoleMessage[5] = $"Setting command identifier to {Commands.Commands.CommandPrefix}.";
            Program.SendToConsole(consoleMessage);
            client.AddChatCommandIdentifier(Commands.Commands.CommandPrefix);
            client.AddWhisperCommandIdentifier(Commands.Commands.CommandPrefix);

            // set message throttling
            consoleMessage[5] = "Setting Twitch chat throttle set to 19 messages every 30 seconds.";
            Program.SendToConsole(consoleMessage);
            client.ChatThrottler    = new TwitchLib.Services.MessageThrottler(client, 19, TimeSpan.FromSeconds(30));
            client.WhisperThrottler = new TwitchLib.Services.MessageThrottler(client, 19, TimeSpan.FromSeconds(30));

            consoleMessage[5] = "Registering Twitch chat events...";
            Program.SendToConsole(consoleMessage);

            // Connection events
            client.OnLog             += Client_OnLog;
            client.OnIncorrectLogin  += Client_OnIncorrectLogin;
            client.OnConnectionError += Client_OnConnecitonError;
            client.OnConnected       += Client_OnConnected;
            client.OnDisconnected    += Client_OnDisconnected;

            // Message events
            client.OnMessageReceived     += Client_OnMessageReceived;
            client.OnChatCommandReceived += Client_OnChatCommandReceived;
            client.OnMessageSent         += Client_OnMessageSent;

            // Whisper events
            client.OnWhisperReceived        += Client_OnWhisperReceived;
            client.OnWhisperCommandReceived += Client_OnWhisperCommandReceived;
            client.OnWhisperSent            += Client_OnWhisperSent;

            // User events
            client.OnUserJoined   += Client_OnUserJoined;
            client.OnUserLeft     += Client_OnUserLeft;
            client.OnUserTimedout += Client_OnUserTimedout;

            // Channel events
            client.OnJoinedChannel += Client_OnJoinedChannel;
            client.OnLeftChannel   += Client_OnLeftChannel;

            consoleMessage[5] = "Connecting to Twitch chat...";
            Program.SendToConsole(consoleMessage);
            client.Connect();
        }
Ejemplo n.º 3
0
 private void InitTwitchClient()
 {
     client                        = new TwitchClient(credentials, Credentials.channelToJoin);
     client.OnConnected           += OnConnected;
     client.OnDisconnected        += OnDisconnected;
     client.OnUserJoined          += OnUserJoined;
     client.OnUserLeft            += OnUserLeft;
     client.OnConnectionError     += OnConnectionError;
     client.OnWhisperReceived     += OnWisperReceived;
     client.OnMessageReceived     += OnMessageReceived;
     client.OnChatCommandReceived += OnCommandReceived;
     client.AddChatCommandIdentifier(commandIdentifier);
     client.AddWhisperCommandIdentifier(commandIdentifier);
 }
Ejemplo n.º 4
0
        private void InitializeClient()
        {
            var credentials = new ConnectionCredentials(
                _configuration.GetSection("twitch")["username"],
                _configuration.GetSection("twitch")["password"],
                _configuration.GetSection("twitch")["webSocketUri"],
                _configuration.GetSection("twitch").GetValue <bool>("disableUserNameCheck")
                );

            _client = new TwitchClient();

            _client.Initialize(credentials);

            _client.OnJoinedChannel += OnTwitchJoinChannel;
            _client.OnLeftChannel   += OnTwitchLeftChannel;

            _client.OnMessageReceived += OnTwitchMessage;
            _client.OnWhisperReceived += OnTwitchWhisperMessage;

            _client.OnChatCommandReceived    += OnTwitchCommand;
            _client.OnWhisperCommandReceived += OnTwitchWhisperCommand;

            _client.OnModeratorJoined += OnTwitchModeratorJoined;
            _client.OnModeratorLeft   += OnTwitchModeratorLeft;

            _client.OnUserJoined += OnTwitchUserJoined;
            _client.OnUserLeft   += OnTwitchUserLeft;

            _client.OnConnected += OnTwitchConnected;

            _client.AutoReListenOnException = true;
            _client.RemoveChatCommandIdentifier('!');
            _client.AddChatCommandIdentifier(_configuration.GetSection("twitch").GetSection("commandPrefix").Get <char>());

            _client.RemoveWhisperCommandIdentifier('!');
            _client.AddWhisperCommandIdentifier(_configuration.GetSection("twitch").GetSection("commandPrefix").Get <char>());

            _client.OnError += onTwitchError;
        }