/// <summary> /// Sends command to start a commercial of variable length. /// </summary> /// <param name="client">Client reference used to identify extension.</param> /// <param name="channel">JoinedChannel representation of the channel to send the ad to.</param> /// <param name="length">Enum representing the length of advertisement should be.</param> /// <exception cref="ArgumentOutOfRangeException">length - null</exception> public static void StartCommercial(this ITwitchClient client, JoinedChannel channel, Enums.CommercialLength length) { switch (length) { case Enums.CommercialLength.Seconds30: client.SendMessage(channel, ".commercial 30"); break; case Enums.CommercialLength.Seconds60: client.SendMessage(channel, ".commercial 60"); break; case Enums.CommercialLength.Seconds90: client.SendMessage(channel, ".commercial 90"); break; case Enums.CommercialLength.Seconds120: client.SendMessage(channel, ".commercial 120"); break; case Enums.CommercialLength.Seconds150: client.SendMessage(channel, ".commercial 150"); break; case Enums.CommercialLength.Seconds180: client.SendMessage(channel, ".commercial 180"); break; default: throw new ArgumentOutOfRangeException(nameof(length), length, null); } }
/// <summary> /// Sends command to start a commercial of variable length. /// </summary> /// <param name="channel">JoinedChannel representation of the channel to send the ad to.</param> /// <param name="length">Enum representing the length of advertisement should be.</param> /// <param name="client">Client reference used to identify extension.</param> public static void StartCommercial(this TwitchClient client, JoinedChannel channel, Enums.CommercialLength length) { switch (length) { case Enums.CommercialLength.Seconds30: client.SendMessage(channel, ".commercial 30"); break; case Enums.CommercialLength.Seconds60: client.SendMessage(channel, ".commercial 60"); break; case Enums.CommercialLength.Seconds90: client.SendMessage(channel, ".commercial 90"); break; case Enums.CommercialLength.Seconds120: client.SendMessage(channel, ".commercial 120"); break; case Enums.CommercialLength.Seconds150: client.SendMessage(channel, ".commercial 150"); break; case Enums.CommercialLength.Seconds180: client.SendMessage(channel, ".commercial 180"); break; } }
public async void Process(TwitchClient client, string username, string commandText, bool isMod, JoinedChannel joinedChannel) { var promoteSongResponse = await _playlistApiClient.PromoteSong(new PromoteSongRequest { Username = username }); switch (promoteSongResponse.PromoteRequestResult) { case PromoteRequestResult.NotYourRequest: client.SendMessage(joinedChannel, $"Hey @{username}, I'm sorry but that request doesn't seem to belong to you. Please check your requests with !myrequests"); return; case PromoteRequestResult.UnSuccessful: client.SendMessage(joinedChannel, $"Hey @{username}, sorry I can't promote your request right now, please try again in a sec"); return; case PromoteRequestResult.NoVipAvailable: client.SendMessage(joinedChannel, $"Hey @{username}, sorry but you don't have a VIP to promote this request"); return; case PromoteRequestResult.Successful: client.SendMessage(joinedChannel, $"Hey @{username}, I have promoted your request to #{promoteSongResponse.PlaylistIndex} for you!"); return; } }
public TwitchChannel(JoinedChannel chan, ChatModuleManager manager) { this.m_ModuleManager = manager; this.Channel = chan.Channel; var channelstate = chan.ChannelState; if (channelstate != null) { Language = channelstate.BroadcasterLanguage; if (channelstate.EmoteOnly != null && channelstate.EmoteOnly.GetValueOrDefault() == true) { this.EmoteOnlyChat = true; } if (channelstate.SubOnly != null && channelstate.SubOnly.GetValueOrDefault() == true) { this.SubOnlyChat = true; } this.Murcury = channelstate.Mercury; this.R9K = channelstate.R9K; this.Rituals = channelstate.Rituals; this.Id = chan.ChannelState.RoomId; } }
public void Setup() { twitchClient = FindObjectOfType <TwitchClient>(); chatClient = twitchClient.client; chatJoinedChannel = twitchClient.joinedChannel; botJoinedChannel = twitchClient.botChannel; }
bool ICommandes.Action( JoinedChannel joinedChannel, TextBox prefixe, TwitchClient client, TwitchBotForm me, OnMessageReceivedArgs e ) { if (e.ChatMessage.UserType == TwitchLib.Client.Enums.UserType.Viewer) { client.SendMessage(joinedChannel, $"Sorry only moderator can do that."); } else { if (me.songRequests.Rows.Count <= 1) { client.SendMessage(joinedChannel, "No More song to remove"); return(true); } me.RemoveLastPlayerSong(); client.SendMessage(joinedChannel, "Song removed"); var sog = me.songRequests?.Rows[0]?.Cells["Song"]?.Value?.ToString() ?? null; client.SendMessage(joinedChannel, sog != null ? $"Next song : {sog} " : "End of the queue"); } return(true); }
private void Client_OnJoinedChannel(object sender, OnJoinedChannelArgs e) { //client.SendMessage(e.Channel, "Discord Integration Connected: " + e.Channel); //PubSub.ListenToFollows(GetUserId(e.Channel)); //PubSub.ListenToBitsEvents(GetUserId(e.Channel)); Channel = new JoinedChannel(e.Channel); joinedChannels.Add(Channel); }
/// <summary> /// Sends a request to get channel moderators. You MUST listen to OnModeratorsReceived event./>. /// </summary> /// <param name="channel">JoinedChannel object to designate which channel to send request to.</param> public void GetChannelModerators(JoinedChannel channel) { if (OnModeratorsReceived == null) { throw new EventNotHandled("OnModeratorsReceived"); } SendMessage(channel, "/mods"); }
/// <summary> /// TImesout a user in chat using a JoinedChannel object. /// </summary> /// <param name="channel">Channel object to send timeout to</param> /// <param name="viewer">Viewer name to timeout</param> /// <param name="duration">Duration of the timeout via TimeSpan object</param> /// <param name="message">Message to accompany the timeout and show the user.</param> /// <param name="dryRun">Indicates a dryrun (will not sened if true)</param> /// <param name="client">Client reference used to identify extension.</param> public static void TimeoutUser(this ITwitchClient client, JoinedChannel channel, string viewer, TimeSpan duration, string message = "", bool dryRun = false) { if (duration < TimeSpan.FromSeconds(1)) { throw new Exceptions.InvalidParameterException("timeout duration must be longer than 1 second", client.TwitchUsername); } client.SendMessage(channel, $".timeout {viewer} {duration.Days}d{duration.Hours}h{duration.Minutes}m{duration.Seconds}s {message}", dryRun); }
/// <summary> /// Timesout a user in chat using a string for the channel. /// </summary> /// <param name="client">Client reference used to identify extension.</param> /// <param name="channel">Channel in string form to send timeout to</param> /// <param name="viewer">Viewer name to timeout</param> /// <param name="duration">Duration of the timeout via TimeSpan object</param> /// <param name="message">Message to accompany the timeout and show the user.</param> /// <param name="dryRun">Indicates a dryrun (will not sened if true)</param> public static void TimeoutUser(this ITwitchClient client, string channel, string viewer, TimeSpan duration, string message = "", bool dryRun = false) { JoinedChannel joinedChannel = client.GetJoinedChannel(channel); if (joinedChannel != null) { TimeoutUser(client, joinedChannel, viewer, duration, message, dryRun); } }
/// <summary> /// Bans a user in chat using a string for the channel /// </summary> /// <param name="client">Client reference used to identify extension.</param> /// <param name="channel">Channel in string form to send ban to</param> /// <param name="viewer">Viewer name to ban</param> /// <param name="message">Message to accompany the ban and show the user.</param> /// <param name="dryRun">Indicates a dryrun (will not send if true)</param> public static void BanUser(this ITwitchClient client, string channel, string viewer, string message = "", bool dryRun = false) { JoinedChannel joinedChannel = client.GetJoinedChannel(channel); if (joinedChannel != null) { BanUser(client, joinedChannel, viewer, message, dryRun); } }
/// <summary> /// Enables slow mode. messageCooldown must be less than 1 day. /// </summary> /// <param name="messageCooldown">TimeSpan object representing how long message cooldowns should be. May not exceed 1 day total.</param> /// <param name="channel">JoinedChannel representation of which channel to send the slow command to.</param> /// <param name="client">Client reference used to identify extension.</param> public static void SlowModeOn(this TwitchClient client, JoinedChannel channel, TimeSpan messageCooldown) { if (messageCooldown > TimeSpan.FromDays(1)) { throw new Exceptions.Client.InvalidParameterException("The message cooldown time supplied exceeded the maximum allowed by Twitch, which is 1 day.", client.TwitchUsername); } client.SendMessage(channel, $".slow {messageCooldown.TotalSeconds}"); }
public TwitchChatClient(TwitchClientSettings settings) { _settings = settings; _joinedChannel = new JoinedChannel(_settings.TwitchChannel); var credentials = new ConnectionCredentials(_settings.TwitchUsername, _settings.TwitchBotOAuth); _twitchClient = new TwitchClient(); _twitchClient.Initialize(credentials, _joinedChannel.Channel); }
private void OnJoinedChannel(object sender, OnJoinedChannelArgs e) { LabelChange($@"Status: Connected to {e.Channel}"); mainChannel = twitchClient.JoinedChannels[0]; twitchClient.SendMessage(e.Channel, userSettings.Default.requestConnected.Parse(channel: mainChannel.Channel)); }
public async void Process(TwitchClient client, string username, string commandText, bool isMod, JoinedChannel joinedChannel) { if (string.IsNullOrWhiteSpace(commandText)) { client.SendMessage(joinedChannel, $"Hey @{username}, looks like you haven't included a request there!"); return; } var addSongResult = await _playlistApiClient.AddSong(new AddSongRequest { Username = username, CommandText = commandText, IsVipRequest = true }); if (addSongResult != null) { switch (addSongResult.Result) { case AddRequestResult.Success: var playlistPosition = addSongResult.PlaylistPosition; client.SendMessage(joinedChannel, $"Hey @{username}, I have queued {commandText} for you, you're #{playlistPosition} in the queue!"); return; case AddRequestResult.PlaylistVeryClosed: client.SendMessage(joinedChannel, $"Hey @{username}, the playlist is currently closed. No Requests allowed."); return; case AddRequestResult.NoRequestEntered: client.SendMessage(joinedChannel, $"Hey @{username}, looks like you haven't included a request there!"); return; case AddRequestResult.NotEnoughVips: client.SendMessage(joinedChannel, $"Hey @{username}, sorry but you don't have a VIP token."); return; case AddRequestResult.UnSuccessful: client.SendMessage(joinedChannel, $"Hey @{username}, I can't queue your VIP request right now, please try again in a sec"); return; } } else { client.SendMessage(joinedChannel, $"Hey @{username}, it looks like you don't have any remaining VIP requests. Please use the standard !request command."); } }
public JoinedChannel JoinChannel(string chatID) { JoinedChannel channel = new JoinedChannel(youTubeAPI, chatID, ChatUpdateDelay.Normal); channel.StartListening(); channel.OnReceiveSuperChatEvent += Channel_OnReceiveSuperChatEvent; channel.OnReceiveMessageEvent += Channel_OnReceiveMessageEvent; JoinedChannels.Add(channel); return(channel); }
private void Client_OnJoinedChannel(object sender, OnJoinedChannelArgs e) { this.currentChannel = new JoinedChannel(e.Channel); this.OnConnected?.Invoke(sender, null); // Send connected greeting message if any if (!string.IsNullOrWhiteSpace(this.TwitchOptions.GreetingMessage)) { QTChatManager.Instance.SendInstantMessage(this.TwitchOptions.GreetingMessage); } }
private void JoinChannel(string command) { // Extracts first word starting with '#' string channel = command.Substring(command.IndexOf('#'), command.Substring(command.IndexOf('#')).IndexOf(' ')); users.Sort(); JoinedChannel?.Invoke(this, new NewChannelEventArgs(channel, users)); users = null; }
bool ICommandes.Action( JoinedChannel joinedChannel, TextBox prefixe, TwitchClient client, TwitchBotForm me, OnMessageReceivedArgs e ) { client.SendMessage(joinedChannel, $"I'm version {Assembly.GetExecutingAssembly().GetName().Version}"); return(true); }
/// <summary> /// Enables follower only chat, requires a TimeSpan object to indicate how long a viewer must have been following to chat. Maximum time is 90 days (3 months). /// </summary> /// <param name="channel">JoinedChannel object representing which channel to send command to.</param> /// <param name="requiredFollowTime">Amount of time required to pass before a viewer can chat. Maximum is 3 months (90 days).</param> /// <param name="client">Client reference used to identify extension.</param> public static void FollowersOnlyOn(this TwitchClient client, JoinedChannel channel, TimeSpan requiredFollowTime) { if (requiredFollowTime > TimeSpan.FromDays(MaximumDurationAllowedDays)) { throw new Exceptions.Client.InvalidParameterException("The amount of time required to chat exceeded the maximum allowed by Twitch, which is 3 months.", client.TwitchUsername); } var duration = $"{requiredFollowTime.Days}d {requiredFollowTime.Hours}h {requiredFollowTime.Minutes}m"; client.SendMessage(channel, $".followers {duration}"); }
/// <summary> /// Leaves (PART) the Twitch IRC chat of <paramref name="channel"/>. /// </summary> /// <param name="channel">The channel to leave.</param> /// <returns>True is returned if the passed channel was found, false if channel not found.</returns> public void LeaveChannel(string channel) { // Channel MUST be lower case channel = channel.ToLower(); log($"Leaving channel: {channel}"); JoinedChannel joinedChannel = JoinedChannels.FirstOrDefault(x => x.Channel.ToLower() == channel.ToLower()); if (joinedChannel != null) { _client.Send(Rfc2812.Part($"#{channel}")); } }
public async void Process(TwitchClient client, string username, string commandText, bool isMod, JoinedChannel joinedChannel) { // Check there is a request given if (string.IsNullOrWhiteSpace(commandText)) { client.SendMessage(joinedChannel, $"Hey @{username}, I'm sorry but it looks like you haven't included a request! !svip <artistname> - <songname> - (guitar or bass)"); return; } var addSuperResponse = await _playlistApiClient.AddSuperVip(new AddSuperVipRequest { Username = username, CommandText = commandText }); if (addSuperResponse != null) { switch (addSuperResponse.Result) { case AddRequestResult.PlaylistVeryClosed: client.SendMessage(joinedChannel, $"Hey @{username}, the playlist is currently very closed. No Requests allowed."); return; case AddRequestResult.OnlyOneSuper: client.SendMessage(joinedChannel, $"Hey @{username}, sorry but there can only be one SuperVIP in the queue at a time!"); return; case AddRequestResult.NotEnoughVips: client.SendMessage(joinedChannel, $"Hey @{username}, it looks like you don't have enough VIP tokens :( You need at least {_configService.Get<string>("SuperVipCost")} tokens to request a SuperVIP"); return; case AddRequestResult.Success: client.SendMessage(joinedChannel, $"Hey @{username}, I have queued {commandText} for you, your request will be played next!"); return; case AddRequestResult.UnSuccessful: client.SendMessage(joinedChannel, $"Hey @{username}, something went wrong. Please try again in a minute"); return; } } else { client.SendMessage(joinedChannel, $"Hey @{username}, something went wrong. Please try again in a minute"); } }
bool ICommandes.Action( JoinedChannel joinedChannel, TextBox prefixe, TwitchClient client, TwitchBotForm me, OnMessageReceivedArgs e ) { client.SendMessage(joinedChannel, string.Format(Resources.Command_Base_Action_Message, joinedChannel.Channel)); return(true); }
private void TwitchClient_OnJoinedChannel(object sender, OnJoinedChannelArgs e) { LoggingManager.Log.Info($"Joined channel {e.Channel}."); OnChangingChannel(new OnChangingChannel(ChangingChannelState.Finished, e.Channel)); _JoinedChannel = _TwitchClient.JoinedChannels.First(x => x.Channel.Equals(e.Channel, StringComparison.OrdinalIgnoreCase)); _TwitchClient.GetChannelModerators(_JoinedChannel); GetBetterTTVEmotes(); GetFrankerFaceZEmotes(); }
private void queueingJoinCheck() { if (joinChannelQueue.Count > 0) { currentlyJoiningChannels = true; JoinedChannel channelToJoin = joinChannelQueue.Dequeue(); log($"Joining channel: {channelToJoin.Channel}"); _client.Send(Rfc2812.Join($"#{channelToJoin.Channel}")); JoinedChannels.Add(new JoinedChannel(channelToJoin.Channel)); } else { log("Finished channel joining queue."); } }
private static Task LeaveChannel(ITwitchClient client, JoinedChannel channel) { var source = new TaskCompletionSource <bool>(); void OnLeftChannel(object a, OnLeftChannelArgs args) { if (args.Channel == channel.Channel) { client.OnLeftChannel -= OnLeftChannel; source.SetResult(true); } } client.OnLeftChannel += OnLeftChannel; client.LeaveChannel(channel); return(source.Task); }
/// <summary> /// Sends a formatted Twitch channel chat message. /// </summary> /// <param name="message">The message to be sent.</param> /// <param name="dryRun">If set to true, the message will not actually be sent for testing purposes.</param> /// <param name="channel">Channel to send message to.</param> public void SendMessage(JoinedChannel channel, string message, bool dryRun = false) { if (channel == null || message == null || dryRun) { return; } if (ChatThrottler != null && !ChatThrottler.MessagePermitted(message)) { return; } string twitchMessage = $":{_credentials.TwitchUsername}!{_credentials.TwitchUsername}@{_credentials.TwitchUsername}" + $".tmi.twitch.tv PRIVMSG #{channel.Channel} :{message}"; _lastMessageSent = message; // This is a makeshift hack to encode it with accomodations for at least cyrillic characters, and possibly others _client.Send(twitchMessage); }
private static bool Prefix(string message) { if (message.NullOrEmpty()) { return(false); } message = message.Replace("@", ""); JoinedChannel channel = TwitchWrapper.Client.GetJoinedChannel(ToolkitCoreSettings.channel_username); foreach (string segment in SplitMessages(message)) { TwitchWrapper.Client.SendMessage(channel, segment); } return(false); }
bool ICommandes.Action( JoinedChannel joinedChannel, TextBox prefixe, TwitchClient client, TwitchBotForm me, OnMessageReceivedArgs e ) { var song = me.songRequests?.Rows[0]?.Cells["Song"]?.Value?.ToString() ?? null; if (song != null) { client.SendMessage(joinedChannel, $"Next song : {song} "); } else { client.SendMessage(joinedChannel, "End of the queue"); } return(true); }
bool ICommandes.Action( JoinedChannel joinedChannel, TextBox prefixe, TwitchClient client, TwitchBotForm me, OnMessageReceivedArgs e ) { try { me.RemoveSongByRequester(e.ChatMessage.Username); client.SendMessage(joinedChannel, $"{Resources.Command_Cancel_Action_Canceled}"); } catch (Exception) { client.SendMessage(joinedChannel, Resources.Command_Cancel_Action_NoSongToCancel); } return(true); }