public TwitchChannelLink(ITwitchEventProxy eventProxy, string userName, string accessToken, string channel) { _eventProxy = eventProxy; Client = new TwitchClient(); Client.OnConnected += Client_OnConnected; Client.OnBeingHosted += Client_OnBeingHosted; Client.OnChannelStateChanged += Client_OnChannelStateChanged; Client.OnChatCleared += Client_OnChatCleared; Client.OnChatColorChanged += Client_OnChatColorChanged; Client.OnChatCommandReceived += Client_OnChatCommandReceived; Client.OnConnectionError += Client_OnConnectionError; Client.OnDisconnected += Client_OnDisconnected; Client.OnExistingUsersDetected += Client_OnExistingUsersDetected; Client.OnGiftedSubscription += Client_OnGiftedSubscription; Client.OnHostingStarted += Client_OnHostingStarted; Client.OnHostingStopped += Client_OnHostingStopped; Client.OnHostLeft += Client_OnHostLeft; Client.OnIncorrectLogin += Client_OnIncorrectLogin; Client.OnJoinedChannel += Client_OnJoinedChannel; Client.OnLeftChannel += Client_OnLeftChannel; Client.OnLog += Client_OnLog; Client.OnMessageSent += Client_OnMessageSent; Client.OnMessageThrottled += Client_OnMessageThrottled; Client.OnMessageReceived += Client_OnMessageReceived; Client.OnWhisperReceived += Client_OnWhisperReceived; Client.OnNewSubscriber += Client_OnNewSubscriber; Client.OnError += Client_OnError; // Token by https://github.com/swiftyspiffy/twitch-token-generator ConnectionCredentials credentials = new ConnectionCredentials(userName, accessToken); Client.Initialize(credentials, channel); }
public TwitchChannelLinkProvider(ITwitchEventProxy eventProxy, IOptions <TwitchConfiguration> twitchOptions, IServiceProvider services) { TwitchConfiguration config = twitchOptions.Value; foreach (string channel in config.Channels) { // we need an own scope for each link IServiceScope scope = services.CreateScope(); ITwitchChannelLink channelLink = new TwitchChannelLink(eventProxy, config.UserName, config.AcessToken, channel); _links.Add(channelLink, scope); } }