Exemplo n.º 1
0
        internal async void Connect()
        {
            /*
             * Метод подключения бота к каналу
             */
            Console.WriteLine("Connected");



            /*
             * TwitchInfo.ChannelName - ChannelName это канал на твиче, к которому подключается бот
             */
            client = new TwitchClient();
            client.Initialize(credentials, TwitchInfo.ChannelName, autoReListenOnExceptions: false);
            api = new TwitchAPI();

            /*
             * allowedMessage - разрешенное число сообщений
             * time - время бездействия
             */
            int allowedMessage;
            int time;

            Console.WriteLine("Enter allowed messages:");
            allowedMessage = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Add Time:");
            time = Convert.ToInt32(Console.ReadLine());


            client.ChatThrottler = new MessageThrottler(client, allowedMessage, TimeSpan.FromSeconds(time));

            await client.ChatThrottler.StartQueue();


            await api.InitializeAsync(TwitchInfo.ClientId, TwitchInfo.AccessToken);


            /*
             * Инициализация методов функций бота
             */

            client.OnLog                 += Client_OnLog;
            client.OnConnectionError     += Client_OnConnectionError;
            client.OnMessageReceived     += Client_OnMessageReceivedAsync;
            client.OnMessageReceived     += TwitchClient_OnMessageReceived;
            client.OnMessageReceived     += File_OnMessageReceived;
            client.OnChatCommandReceived += Client_OnChatCommandReceived;

            client.AddChatCommandIdentifier('!');
            // TwitchLib.Services.FollowerService follows = new TwitchLib.Services.FollowerService(api, 5, 3);



            client.Connect();
        }
Exemplo n.º 2
0
        public async Task Connect()
        {
            await api.InitializeAsync(config.AppToken, config.BotToken);

            client.Connect();
        }