Exemplo n.º 1
0
        public TwitchBot(string _channelName)
        {
            //Init Client
            twitchClient = new TwitchClient();
            twitchPubSub = new TwitchPubSub();

            //Init Database
            this.db = new AppDbContextFactory().Create();

            //Init access
            accessService = new AccessService();

            //Init Twitch API
            api = new TwitchAPI();
            api.Settings.ClientId    = accessService.GetTwitchClientID();
            api.Settings.AccessToken = accessService.GetTwitchAccessToken();

            //Init services
            this.achievementService = new AchievementService(db);
            this.settingsService    = new SettingsService(db);
            this.pokemonService     = new PokemonService(db);

            userService = new UserService(db, api);

            chatOutputService = new ChatOutputService(twitchClient, _channelName);
            bossService       = new BossService(userService, pokemonService, chatOutputService, settingsService);
            userfightService  = new UserfightService(userService, chatOutputService);


            chatService            = new ChatInputService(userService, chatOutputService, bossService, userfightService, achievementService);
            destinationChannelName = _channelName;

            Connect();
        }
        /// <summary>
        /// Class constructor. Preps the <see cref="TwitchPubSub"/> class.
        /// </summary>
        private TwitchLibPubSub()
        {
            this._twitchPubSub = new TwitchPubSub();

            this.SetListeners();

            this._twitchPubSub.OnPubSubServiceClosed    += this.TwitchPubSub_OnPubSubServiceClosed;
            this._twitchPubSub.OnPubSubServiceConnected += this.TwitchPubSub_OnPubSubServiceConnected;
            this._twitchPubSub.OnPubSubServiceError     += this.TwitchPubSub_OnPubSubServiceError;
            this._twitchPubSub.OnListenResponse         += this.TwitchPubSub_OnListenResponse;
            this._twitchPubSub.OnTimeout                 += this.TwitchPubSub_OnTimeout;
            this._twitchPubSub.OnBan                     += this.TwitchPubSub_OnBan;
            this._twitchPubSub.OnMessageDeleted          += this.TwitchPubSub_OnMessageDeleted;
            this._twitchPubSub.OnUnban                   += this.TwitchPubSub_OnUnban;
            this._twitchPubSub.OnUntimeout               += this.TwitchPubSub_OnUntimeout;
            this._twitchPubSub.OnHost                    += this.TwitchPubSub_OnHost;
            this._twitchPubSub.OnSubscribersOnly         += this.TwitchPubSub_OnSubscribersOnly;
            this._twitchPubSub.OnSubscribersOnlyOff      += this.TwitchPubSub_OnSubscribersOnlyOff;
            this._twitchPubSub.OnClear                   += this.TwitchPubSub_OnClear;
            this._twitchPubSub.OnEmoteOnly               += this.TwitchPubSub_OnEmoteOnly;
            this._twitchPubSub.OnEmoteOnlyOff            += this.TwitchPubSub_OnEmoteOnlyOff;
            this._twitchPubSub.OnR9kBeta                 += this.TwitchPubSub_OnR9kBeta;
            this._twitchPubSub.OnR9kBetaOff              += this.TwitchPubSub_OnR9kBetaOff;
            this._twitchPubSub.OnBitsReceived            += this.TwitchPubSub_OnBitsReceived;
            this._twitchPubSub.OnChannelCommerceReceived += this.TwitchPubSub_OnChannelCommerceReceived;
            this._twitchPubSub.OnStreamUp                += this.TwitchPubSub_OnStreamUp;
            this._twitchPubSub.OnStreamDown              += this.TwitchPubSub_OnStreamDown;
            this._twitchPubSub.OnViewCount               += this.TwitchPubSub_OnViewCount;
            this._twitchPubSub.OnWhisper                 += this.TwitchPubSub_OnWhisper;
            this._twitchPubSub.OnChannelSubscription     += this.TwitchPubSub_OnChannelSubscription;
            this._twitchPubSub.OnFollow                  += this.TwitchPubSub_OnFollow;
            this._twitchPubSub.OnLog                     += this.TwitchPubSub_OnLog;
        }
Exemplo n.º 3
0
        public TwitchPubSubService(
            TwitchAPI twitchApiClient,
            IOptions <TwitchConfig> config,
            ILoggerFactory loggerFactory)
        {
            _logger      = loggerFactory.CreateLogger <TwitchPubSubService>();
            _config      = config.Value;
            PubSubClient = new TwitchPubSub();
            var user = twitchApiClient.Helix.Users.GetUsersAsync(logins: new List <string> {
                "vic10usx"
            }).Result.Users.First();

            PubSubClient.OnPubSubServiceConnected += OnPubSubServiceConnected;
            PubSubClient.ListenToRewards(user.Id);
            // PubSubClient.ListenToChannelPoints(user.Id);
            PubSubClient.OnPubSubServiceClosed += (sender, args) =>
            {
                _logger.LogWarning("The service has closed it's connection... :(", args);
            };
            PubSubClient.OnPubSubServiceError += (sender, args) =>
            {
                _logger.LogError("The service encountered a critical error... :(", args);
            };
            PubSubClient.OnChannelSubscription += (sender, args) =>
            {
            };

            PubSubClient.Connect();
        }
Exemplo n.º 4
0
        public ChatbotService(CommandHelper commandHelper, TwitchClient client, TwitchAPI api, TwitchPubSub pubsub, FollowerService followerService, VipHelper vipHelper, BytesHelper bytesHelper)
        {
            this.commandHelper   = commandHelper;
            this.client          = client;
            this.api             = api;
            this.pubsub          = pubsub;
            this.followerService = followerService;
            this.vipHelper       = vipHelper;
            this.bytesHelper     = bytesHelper;

            this.commandHelper.Init();

            client.OnJoinedChannel       += onJoinedChannel;
            client.OnChatCommandReceived += onCommandReceived;
            client.OnNewSubscriber       += onNewSub;
            client.OnReSubscriber        += onReSub;
            client.Connect();

            pubsub.OnPubSubServiceConnected += onPubSubConnected;
            pubsub.OnListenResponse         += onListenResponse;

            // followerService.OnNewFollowersDetected += onNewFollowers;

            pubsub.Connect();
        }
Exemplo n.º 5
0
        public async Task TwitchAPIandPubSub_setup()
        {
            try
            {
                clientPubSub             = new TwitchPubSub();
                api                      = new TwitchAPI();
                api.Settings.ClientId    = config.BroadCaster_ClientID;
                api.Settings.AccessToken = config.BroadCaster_AccessToken;

                var respons = await api.Helix.Users.GetUsersAsync(null, new List <string>() { config.ChannelName });

                channel_id = respons.Users[0].Id;

                clientPubSub.OnPubSubServiceConnected      += ClientPubSub_OnPubSubServiceConnected;
                clientPubSub.OnChannelPointsRewardRedeemed += ClientPubSub_OnChannelPointsRewardRedeemed;
                clientPubSub.OnBitsReceivedV2      += ClientPubSub_OnBitsReceivedV2;
                clientPubSub.OnStreamUp            += ClientPubSub_OnStreamUp;
                clientPubSub.OnStreamDown          += ClientPubSub_OnStreamDown;
                clientPubSub.OnListenResponse      += ClientPubSub_OnListenResponse;
                clientPubSub.OnPubSubServiceClosed += ClientPubSub_OnPubSubServiceClosed;

                clientPubSub.ListenToBitsEventsV2(channel_id);
                clientPubSub.ListenToChannelPoints(channel_id);
                clientPubSub.ListenToVideoPlayback(channel_id);

                clientPubSub.Connect();
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                Console.WriteLine(e.Message);
                Dispose();
            }
        }
Exemplo n.º 6
0
        // Connect the PubSub client.
        public async void ConnectPubSubClient()
        {
            PubSubClient = new TwitchPubSub();

            string channelId = await GetChannelId(ChannelName);

            // Listen to events.
            PubSubClient.OnPubSubServiceConnected += Client_OnPubSubServiceConnected;
            PubSubClient.OnListenResponse         += Client_OnListenResponse;

            if (Alerts[0])
            {
                // Follow alert.
                PubSubClient.ListenToFollows(channelId);
                PubSubClient.OnFollow += Client_OnFollow;
            }

            if (Alerts[1])
            {
                // Sub alert.
                PubSubClient.ListenToSubscriptions(channelId);
                PubSubClient.OnChannelSubscription += Client_OnChannelSubscription;
            }

            if (Alerts[2])
            {
                // Bits alert.
                PubSubClient.ListenToBitsEvents(channelId);
                PubSubClient.OnBitsReceived += Client_OnBitsReceived;
            }

            PubSubClient.Connect();
        }
Exemplo n.º 7
0
        public async Task InitBot(string[] args)
        {
            try
            {
                Cts     = new CancellationTokenSource();
                _config = Program.BotConfig;

                Console.WriteLine("[Twitch] Creating Twitch client");
                _twitch = new TwitchClient();
                _twitch.Initialize(new ConnectionCredentials(
                                       _config.GetValue <string>("twitch:Username"),
                                       _config.GetValue <string>("twitch:WebSocketURL")));

                _twitchPubSub = new TwitchPubSub();
                _twitchApi    = new TwitchAPI();
                _twitchApi.Settings.ClientId = _config.GetValue <string>("twitch:ClientID");
                _twitchApi.Settings.Secret   = _config.GetValue <string>("twitch:ClientSecret");

                await RunAsync(args);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.ToString());
            }
        }
    // Use this for initialization
    void Start()
    {
        ServicePointManager.ServerCertificateValidationCallback = CertificateValidationMonoFix;

        string userName    = "******";
        string clientId    = "zoi7zdedp2vgz803lhx6kx1zjicsrc";
        string accessToken = "wkd8zv8y79ise32sylpjk1c14nrrme";
        string channel     = "cerealkiller1918";
        //string channel = "timthetatman";



        ConnectionCredentials credentials = new ConnectionCredentials(userName, accessToken);

        TwitchAPI.Settings.ClientId    = clientId;
        TwitchAPI.Settings.AccessToken = accessToken;

        TwitchClient client = new TwitchClient(credentials, channel);
        TwitchPubSub pub    = new TwitchPubSub();

        client.OnJoinedChannel   += Client_OnJoinChannel;
        client.OnMessageReceived += Client_OnMessageReceived;
        pub.OnEmoteOnly          += Pub_OnEmoteOnly;


        client.Connect();
    }
Exemplo n.º 9
0
        public void Initialize()
        {
            if (global != null && !global.PubsubNotifications)
            {
                Logger.Instance.LogMessage(TracingLevel.INFO, $"PubSub Initialize called but PubSub notifications are disabled");
                return;
            }

            if (pubsub != null)
            {
                return;
            }

            isConnected   = false;
            connectCalled = false;
            pubsub        = new TwitchPubSub(new PSLogger <TwitchPubSub>());

            TwitchTokenManager.Instance.TokensChanged += Instance_TokensChanged;
            pubsub.OnPubSubServiceConnected           += Pubsub_OnPubSubServiceConnected;
            pubsub.OnListenResponse      += Pubsub_OnListenResponse;
            pubsub.OnStreamDown          += Pubsub_OnStreamDown;
            pubsub.OnStreamUp            += Pubsub_OnStreamUp;
            pubsub.OnBitsReceived        += Pubsub_OnBitsReceived;
            pubsub.OnChannelSubscription += Pubsub_OnChannelSubscription;
            pubsub.OnRewardRedeemed      += Pubsub_OnRewardRedeemed;
            pubsub.OnFollow       += Pubsub_OnFollow;
            pubsub.OnHost         += Pubsub_OnHost;
            pubsub.OnRaidUpdateV2 += Pubsub_OnRaidUpdateV2;
            pubsub.OnRaidGo       += Pubsub_OnRaidGo;

            ConnectPubSub();
        }
Exemplo n.º 10
0
        public void Disconnect()
        {
            if (pubsub == null)
            {
                return;
            }

            Logger.Instance.LogMessage(TracingLevel.INFO, "PubSub Disconnecting");
            TwitchTokenManager.Instance.TokensChanged -= Instance_TokensChanged;
            pubsub.OnPubSubServiceConnected           -= Pubsub_OnPubSubServiceConnected;
            pubsub.OnListenResponse      -= Pubsub_OnListenResponse;
            pubsub.OnStreamDown          -= Pubsub_OnStreamDown;
            pubsub.OnStreamUp            -= Pubsub_OnStreamUp;
            pubsub.OnBitsReceived        -= Pubsub_OnBitsReceived;
            pubsub.OnChannelSubscription -= Pubsub_OnChannelSubscription;
            pubsub.OnRewardRedeemed      -= Pubsub_OnRewardRedeemed;
            pubsub.OnFollow       -= Pubsub_OnFollow;
            pubsub.OnHost         -= Pubsub_OnHost;
            pubsub.OnRaidUpdateV2 -= Pubsub_OnRaidUpdateV2;
            pubsub.OnRaidGo       -= Pubsub_OnRaidGo;

            try
            {
                pubsub.Disconnect();
            }
            catch (Exception ex)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, $"PubSub Disconnect Exception: {ex}");
            }
            isConnected = false;
            pubsub      = null;
        }
Exemplo n.º 11
0
        private void TwitchAuthOnTokenSet()
        {
            var userName    = _twitchAuth.UserName;
            var accessToken = _twitchAuth.Token;

            _credentials = new ConnectionCredentials(userName, accessToken);
            var clientOptions = new ClientOptions
            {
                MessagesAllowedInPeriod = 750,
                ThrottlingPeriod        = TimeSpan.FromSeconds(30)
            };
            WebSocketClient customClient = new(clientOptions);

            _client = new TwitchClient(customClient);
            _client.Initialize(_credentials, _twitchAuth.UserName.ToLowerInvariant());
            _client.OnMessageReceived += OnMessageReceived;
            _client.Connect();

            _pubSub = new TwitchPubSub();
            _pubSub.OnChannelPointsRewardRedeemed += OnChannelPointsRewardRedeemed;
            _pubSub.OnPubSubServiceError          += OnPubSubServiceError;
            _pubSub.ListenToChannelPoints(_twitchAuth.UserId);
            _pubSub.Connect();
            _pubSub.SendTopics(accessToken);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Async main method
        /// </summary>
        /// <param name="args">Arguments</param>
        /// <returns>the Task</returns>
        private async Task MainAsync(string[] args)
        {
            var channelId = Settings.GetSection("twitch").GetValue <string>("channelId");

            //set up twitchlib api
            API = new TwitchAPI();
            API.Settings.ClientId = Settings.GetSection("twitch.api").GetValue <string>("client-id");
            API.Settings.Secret   = Settings.GetSection("twitch.api").GetValue <string>("secret");


            //Set up twitchlib pubsub
            PubSub = new TwitchPubSub();
            PubSub.OnListenResponse         += OnListenResponse;
            PubSub.OnPubSubServiceConnected += OnPubSubServiceConnected;
            PubSub.OnPubSubServiceClosed    += OnPubSubServiceClosed;
            PubSub.OnPubSubServiceError     += OnPubSubServiceError;

            //Set up listeners
            ListenToBits(channelId);
            ListenToChatModeratorActions(channelId, channelId);
            ListenToFollows(channelId);
            ListenToLeaderboards(channelId);
            ListenToPredictions(channelId);
            ListenToRaid(channelId);
            ListenToRewards(channelId);
            ListenToSubscriptions(channelId);
            ListenToVideoPlayback(channelId);
            ListenToWhispers(channelId);

            //Connect to pubsub
            PubSub.Connect();

            //Keep the program going
            await Task.Delay(Timeout.Infinite);
        }
Exemplo n.º 13
0
        public static void Init(TwitchClient client, TwitchPubSub pubsubClient, ApplicationSettings appSettings, Account account,
                                CouchDbStore <Viewer> viewerCollection, List <Command> settings)
        {
            _client           = client;
            _account          = account;
            _viewerCollection = viewerCollection;
            _commandSettings  = settings;
            _twitchService    = new TwitchService(appSettings);

            _client.OnJoinedChannel               += OnJoinedChannel;
            _client.OnMessageReceived             += OnMessageReceived;
            _client.OnWhisperReceived             += OnWhisperReceived;
            _client.OnNewSubscriber               += OnNewSubscriber;
            _client.OnLog                         += OnLog;
            _client.OnConnectionError             += OnConnectionError;
            _client.OnChatCommandReceived         += OnChatCommandReceived;
            _client.OnUserTimedout                += OnUserTimedOut;
            _client.OnUserBanned                  += ClientOnUserBanned;
            pubsubClient.OnPubSubServiceConnected += TwitchPubSubOnOnPubSubServiceConnected;
            pubsubClient.OnPubSubServiceClosed    += TwitchPubSubOnOnPubSubServiceClosed;
            pubsubClient.OnChannelSubscription    += TwitchPubSubOnOnChannelSubscription;
            pubsubClient.OnFollow                 += TwitchPubSubOnOnFollow;
            pubsubClient.OnEmoteOnly              += TwitchPubSubOnOnEmoteOnly;
            pubsubClient.OnEmoteOnlyOff           += TwitchPubSubOnOnEmoteOnlyOff;

            pubsubClient.ListenToFollows(appSettings?.Keys.Twitch.ChannelId);
            pubsubClient.ListenToSubscriptions(appSettings?.Keys.Twitch.ChannelId);
            pubsubClient.ListenToChatModeratorActions(_account?.TwitchBotSettings.Username, appSettings?.Keys.Twitch.ChannelId);
        }
Exemplo n.º 14
0
 public SubPointsHandler(BotConfig config, TwitchClient client, TwitchPubSub pubSub, TwitchAPI api, SlothyService slothySvc)
 {
     _config    = config;
     _client    = client;
     _pubSub    = pubSub;
     _api       = api;
     _slothySvc = slothySvc;
 }
Exemplo n.º 15
0
 private void CreateTwitchClient()
 {
     pubsub = new TwitchPubSub();
     client = new TwitchClient(new WebSocketClient(new ClientOptions
     {
         ClientType = ClientType.Chat,
         MessagesAllowedInPeriod = 100
     }));
 }
Exemplo n.º 16
0
        public StretchTimerHandler(BotConfig config, TwitchClient client, TwitchPubSub pubSub)
        {
            _config = config;
            _client = client;
            _pubSub = pubSub;

            _pubSub.OnStreamUp   += OnStreamUp;
            _pubSub.OnStreamDown += OnStreamDown;
        }
 public TwitchPubSubService(
     IOptionsMonitor <TwitchSettings> optionsMonitor,
     IServiceProvider provider,
     ILogger <TwitchPubSubService> logger)
 {
     _provider       = provider;
     _logger         = logger;
     _twitchSettings = optionsMonitor.CurrentValue;
     _pubsub         = new();
 }
Exemplo n.º 18
0
 public PubSubBot()
 {
     client = new TwitchPubSub();
     client.OnPubSubServiceConnected += onPubSubServiceConnected;
     client.OnPubSubServiceClosed    += onPubSubServiceDisconnected;
     client.OnRewardRedeemed         += OnRewardRedeemed;
     client.OnListenResponse         += OnListenResponse;
     client.ListenToRewards("142647519");
     client.Connect();
 }
Exemplo n.º 19
0
        public void SetupPubSubRedemptions()
        {
            DisablePubSubRedemptions();

            _pubSub = new TwitchPubSub();
            _pubSub.OnPubSubServiceConnected += _pubSub_OnPubSubServiceConnected;
            _pubSub.OnListenResponse         += _pubSub_OnListenResponse;
            _pubSub.OnRewardRedeemed         += _pubSub_OnRewardRedeemed;
            _pubSub.Connect();
        }
Exemplo n.º 20
0
        public static IServiceCollection AddTwitchServices(this IServiceCollection services)
        {
            services.AddTwitchFactories();

            var pubsub = new TwitchPubSub();

            services.AddSingleton(pubsub);

            return(services);
        }
Exemplo n.º 21
0
 private void button47_Click(object sender, EventArgs e)
 {
     pubsub = new TwitchPubSub(true);
     pubsub.onListenResponse         += new EventHandler <TwitchPubSub.onListenResponseArgs>(pubsubOnListenResponse);
     pubsub.onPubSubServiceConnected += new EventHandler(pubsubOnConnected);
     pubsub.onPubSubServiceClosed    += new EventHandler(pubsubOnClose);
     pubsub.onTimeout += new EventHandler <TwitchPubSub.onTimeoutArgs>(pubsubOnTimeout);
     pubsub.onBan     += new EventHandler <TwitchPubSub.onBanArgs>(pubsubOnBan);
     pubsub.onUnban   += new EventHandler <TwitchPubSub.onUnbanArgs>(pubsubOnUnban);
     pubsub.Connect();
 }
Exemplo n.º 22
0
        public PubSub()
        {
            client = new TwitchPubSub();

            client.OnPubSubServiceConnected += OnPubSubServiceConnected;
            client.OnListenResponse         += OnListenResponse;
            client.OnStreamUp   += OnStreamUp;
            client.OnStreamDown += OnStreamDown;
            client.ListenToVideoPlayback(TwitchApiController.Channel.Name);
            client.Connect();
        }
Exemplo n.º 23
0
        private readonly string _developmentRoomId = string.Empty; // Only for use in debug mode

        public ChatbotService(ICommandHelper commandHelper,
                              ITwitchClientFactory twitchClientFactory,
                              TwitchPubSub pubsub,
                              ITwitchLiveStreamMonitorFactory twitchLiveStreamMonitorFactory,
                              IVipApiClient vipApiClient,
                              IConfigService configService,
                              IStreamStatusApiClient streamStatusApiClient,
                              ISecretService secretService,
                              ILogger <ChatbotService> logger)
        {
            _commandHelper = commandHelper;
            _pubsub        = pubsub;
            _twitchLiveStreamMonitorFactory = twitchLiveStreamMonitorFactory;
            _vipApiClient          = vipApiClient;
            _configService         = configService;
            _streamStatusApiClient = streamStatusApiClient;
            _secretService         = secretService;
            _logger = logger;

            _streamerChannel    = _configService.Get <string>("StreamerChannel");
            _isDevelopmentBuild = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development" ||
                                  Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Local";

            _client = twitchClientFactory.Get();

            _client.OnJoinedChannel         += OnJoinedChannel;
            _client.OnChatCommandReceived   += OnCommandReceived;
            _client.OnCommunitySubscription += OnSubBomb;
            _client.OnBeingHosted           += OnBeingHosted;
            _client.OnRaidNotification      += OnRaidNotification;
            _client.OnDisconnected          += OnDisconnected;
            _client.OnError           += OnError;
            _client.OnConnectionError += OnConnectionError;
            _client.Connect();

            _liveStreamMonitor = _twitchLiveStreamMonitorFactory.Get();

            _liveStreamMonitor.SetChannelsByName(new List <string> {
                _streamerChannel
            });
            _liveStreamMonitor.OnStreamOnline   += OnStreamOnline;
            _liveStreamMonitor.OnStreamOffline  += OnStreamOffline;
            _liveStreamMonitor.OnServiceStarted += OnStreamMonitorStarted;
            //this.liveStreamMonitor.OnStreamUpdate += OnStreamUpdate;

            _liveStreamMonitor.Start();

            _pubsub.OnPubSubServiceConnected += OnPubSubConnected;
            _pubsub.OnBitsReceived           += OnBitsReceived;
            _pubsub.OnListenResponse         += OnListenResponse;
            _pubsub.OnChannelSubscription    += OnSub;

            _pubsub.Connect();
        }
Exemplo n.º 24
0
 private void button47_Click_1(object sender, EventArgs e)
 {
     pubsub = new TwitchPubSub(true);
     pubsub.OnListenResponse         += new EventHandler <OnListenResponseArgs>(pubsubOnListenResponse);
     pubsub.OnPubSubServiceConnected += new EventHandler(pubsubOnConnected);
     pubsub.OnPubSubServiceClosed    += new EventHandler(pubsubOnClose);
     pubsub.OnTimeout             += new EventHandler <OnTimeoutArgs>(pubsubOnTimeout);
     pubsub.OnBan                 += new EventHandler <OnBanArgs>(pubsubOnBan);
     pubsub.OnUnban               += new EventHandler <OnUnbanArgs>(pubsubOnUnban);
     pubsub.OnWhisper             += new EventHandler <OnWhisperArgs>(onWhisper);
     pubsub.OnChannelSubscription += new EventHandler <OnChannelSubscriptionArgs>(onChannelSubscription);
     pubsub.Connect();
 }
Exemplo n.º 25
0
        public TwitchPubSubConnection(TwitchClientSettings twitchClientSettings)
        {
            pubSubService             = new TwitchPubSub();
            this.twitchClientSettings = twitchClientSettings;

            pubSubService.OnLog += PubSubService_OnLog;

            pubSubService.OnTimeout        += PubSubService_OnTimeout;
            pubSubService.OnBan            += PubSubService_OnBan;
            pubSubService.OnUntimeout      += PubSubService_OnUntimeout;
            pubSubService.OnUnban          += PubSubService_OnUnban;
            pubSubService.OnMessageDeleted += PubSubService_OnMessageDeleted;
        }
Exemplo n.º 26
0
        public Bot()
        {
            ConnectionCredentials credentials = new ConnectionCredentials("justinfan42069", "password");

            client = new TwitchClient();
            client.Initialize(credentials);

            client.OnJoinedChannel   += Client_OnJoinedChannel;
            client.OnLeftChannel     += Client_OnLeftChannel;
            client.OnMessageReceived += Client_OnMessageReceived;

            client.Connect();

            pubsub = new TwitchPubSub();
        }
Exemplo n.º 27
0
        public void Run()
        {
            if (string.IsNullOrEmpty(ApplicationSettings.Default.ChannelId))
            {
                return;
            }

            this.client = new TwitchPubSub();

            this.client.OnPubSubServiceConnected += this.ClientOnOnPubSubServiceConnected;
            this.client.OnRewardRedeemed         += this.ClientOnOnRewardRedeemed;

            this.client.ListenToRewards(ApplicationSettings.Default.ChannelId);
            this.client.Connect();
        }
Exemplo n.º 28
0
        public void DisablePubSubRedemptions()
        {
            if (_pubSub != null)
            {
                try { _pubSub.OnPubSubServiceConnected -= _pubSub_OnPubSubServiceConnected; }
                catch { }
                try { _pubSub.OnListenResponse -= _pubSub_OnListenResponse; }
                catch { }
                try { _pubSub.OnRewardRedeemed -= _pubSub_OnRewardRedeemed; }
                catch { }
                try { _pubSub.Disconnect(); }
                catch { }

                _pubSub = null;
            }
        }
Exemplo n.º 29
0
        public Pubsub(Form1 formIn)
        {
            form   = formIn;
            client = new TwitchPubSub();

            client.OnPubSubServiceConnected += OnPubSubServiceConnected;
            client.OnListenResponse         += OnListenResponse;
            client.OnStreamUp     += OnStreamUp;
            client.OnStreamDown   += OnStreamDown;
            client.OnFollow       += OnFollow;
            client.OnBitsReceived += OnBitsReceived;

            client.ListenToVideoPlayback("itslittany");

            client.Connect();
        }
Exemplo n.º 30
0
        static Twitch()
        {
            //Logging = true;
            CodeRushedClient = new TwitchClient();
            CodeRushedPubSub = new TwitchPubSub();
            CodeRushedPubSub.OnPubSubServiceConnected += CodeRushedPubSub_OnPubSubServiceConnected;
            CodeRushedPubSub.ListenToChannelPoints(STR_CodeRushedChannelId);
            CodeRushedPubSub.Connect();
            DroneCommandsClient = new TwitchClient();
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            configuration = builder.Build();
            InitializeApiClient();
        }