Beispiel #1
0
 private async void button71_Click(object sender, EventArgs e)
 {
     followerService = new TwitchLib.Services.FollowerService(api);
     followerService.SetChannelByChannelId(textBox68.Text);
     followerService.OnNewFollowersDetected += onFollowersDetected;
     await followerService.StartService();
 }
Beispiel #2
0
        public async void SetFollowerService(ITwitchAPI api)
        {
            // FollowerService
            _followerService = new FollowerService(api);
            _followerService.SetChannelByChannelId(AivaClient.Instance.ChannelId);

            _followerService.OnNewFollowersDetected
                += (sender, e)
                   => OnNewFollower?.Invoke(this, e.NewFollowers);

            await _followerService.StartService().ConfigureAwait(false);
        }
        public TwitchFollowerService(ITwitchAPI twitchApi, TwitchClientSettings settings)
        {
            _twitchApi = twitchApi;

            _settings = settings;

            _followerService = new FollowerService(twitchApi);

            _followerService.SetChannelByChannelId(settings.TwitchChannelId);

            _followerService.StartService().Wait();

            _followerService.OnNewFollowersDetected += FollowerServiceOnOnNewFollowersDetected;
        }
Beispiel #4
0
        private async void onPubSubConnected(object sender, object e)
        {
            try
            {
                Console.Out.WriteLine("PubSub Connected!");
                Channel = await api.Channels.v5.GetChannelAsync(config.ChatbotAccessToken);

                followerService.SetChannelByChannelId(Channel.Id);
                await followerService.StartService();

                pubsub.ListenToBitsEvents(Channel.Id);
                pubsub.OnBitsReceived += onBitsReceived;
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(ex.ToString());
            }
        }
Beispiel #5
0
        public void BotStart()
        {
            try
            {
                ConnectionCredentials credentials = new ConnectionCredentials("JustAnyBot", Settings.AuthToken);

                client = new TwitchClient();
                client.Initialize(credentials);
                client.OnConnected += Client_OnConnected;
                client.AddChatCommandIdentifier(char.Parse("#"));
                client.OnConnectionError += Client_ConnectionError;
                client.OnUserTimedout    += Client_TimedOut;
                if (Settings.AnnounceJoin)
                {
                    client.OnUserJoined += Client_UserJoined;
                }
                client.OnChatCommandReceived += Client_ChatCommandReceived;
                if (Settings.AnnounceLeave)
                {
                    client.OnUserLeft += Client_UserLeft;
                }
                if (Settings.ThankSubscribers)
                {
                    client.OnNewSubscriber += Client_Subscribed;
                }

                api = new TwitchAPI();
                api.Settings.ClientId    = Settings.ClientId;
                api.Settings.AccessToken = Settings.AuthToken;

                GetInfo();

                if (Settings.ThankFollowers)
                {
                    follower = new FollowerService(api, 5);
                    follower.SetChannelByChannelId(Settings.ChannelId);
                    follower.OnNewFollowersDetected += Client_Followed;
                    follower.StartService();
                }

                if (Settings.AnnounceBan)
                {
                    client.OnUserBanned += Client_Banned;
                }
                if (Settings.AnnounceNowHosting)
                {
                    client.OnNowHosting += Client_Hosting;
                }

                UserApi = new TwitchLib.Api.Sections.Users.V5Api(api);

                client.Connect();


                window.Dispatcher.Invoke((Action)(() =>
                {
                    window.BotStarting();
                }));
            }
            catch (ThreadAbortException e)
            {
                MessageBox.Show("Erro: A Janela fechou antes de obter o AuthToken");
            }
            catch (Exception e)
            {
                MessageBox.Show($"An exception has occurred: \n\n{e.Message}");
            }
        }