コード例 #1
0
        private bool CheckForBadWordPhonetic(TwitchMessage twitchMessage)
        {
            var words = twitchMessage.Content.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var word in words)
            {
                // skip whitelisted words
                if (_whitelistedWords.Any(w => w.Word.Equals(word, StringComparison.InvariantCultureIgnoreCase)) ||
                    word.Length < 3)
                {
                    continue;
                }

                var messageWordPhonetic = _phonetic.CreateToken(word);
                foreach (var badWord in TwitchSettings.BadWords)
                {
                    var badPhonetic = _phonetic.CreateToken(badWord);
                    if (messageWordPhonetic.StartsWith(badPhonetic, StringComparison.InvariantCultureIgnoreCase))
                    {
                        twitchMessage.CoughtWords.Add(word);
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #2
0
        public void CheckInfoCommands(TwitchMessage message)
        {
            if (message.Content.ToLower().Contains("!gm help"))
            {
                TwitchConnection.Instance.SendChatMessage("Include !gm followed by a command in your message while the streamer has twitch mode on to mess with their game:" +
                                                          " !gm commands to view info commands. Information about how to use the plugin, game commands, and moderator powers can be found in the mod readme: https://github.com/Kylemc1413/GameplayModifiersPlus/blob/master/README.md");
            }
            if (message.Content.ToLower().Contains("!gm chargehelp"))
            {
                if (Plugin.Config.timeForCharges == 0 || Plugin.Config.chargesOverTime == 0)
                {
                    TwitchConnection.Instance.SendChatMessage("Every " + Plugin.Config.bitsPerCharge + " bits sent with a message adds a charge, which are used to activate commands! If you add super at the end of a command, it will cost " + Plugin.Config.chargesForSuperCharge + " Charges but will make the effect last much longer! " + Plugin.Config.chargesPerLevel + " Charges are generated every song with chat mode on.");
                }
                else
                {
                    TwitchConnection.Instance.SendChatMessage("Every " + Plugin.Config.bitsPerCharge + " bits sent with a message adds a charge, which are used to activate commands! If you add super at the end of a command, it will cost " + Plugin.Config.chargesForSuperCharge + " Charges but will make the effect last much longer! " + Plugin.Config.chargesPerLevel + " Charges are generated every song with chat mode on. Every " + Plugin.Config.timeForCharges + " seconds, " + Plugin.Config.chargesOverTime + " are added.");
                }
            }
            if (message.Content.ToLower().Contains("!gm commands"))
            {
                TwitchConnection.Instance.SendChatMessage("Currently supported commands | status: Currrent Status of chat integration | charges: view current charges and costs | chargehelp: Explain charge system");
            }


            if (message.Content.ToLower().Contains("!gm charges"))
            {
                TwitchConnection.Instance.SendChatMessage("Charges: " + Plugin.charges + " | Commands Per Message: " + Plugin.Config.commandsPerMessage + " | " + Plugin.Config.GetChargeCostString());
            }
        }
コード例 #3
0
        public void CheckInfoCommands(TwitchMessage message)
        {
            if (message.Content.ToLower().Contains("!gm help"))
            {
                TwitchConnection.Instance.SendChatMessage("Guides: For Regular Users - http://bit.ly/1413ChatUser | For Streamers - http://bit.ly/1413Readme | For moderators also view http://bit.ly/1413Config");
            }
            if (message.Content.ToLower().Contains("!gm chargehelp"))
            {
                if (Plugin.ChatConfig.timeForCharges == 0 || Plugin.ChatConfig.chargesOverTime == 0)
                {
                    TwitchConnection.Instance.SendChatMessage("Every " + Plugin.ChatConfig.bitsPerCharge + " bits sent with a message adds a charge, which are used to activate commands! If you add super at the end of a command, it will cost " + Plugin.ChatConfig.chargesForSuperCharge + " Charges but will make the effect last much longer! " + Plugin.ChatConfig.chargesPerLevel + " Charges are generated every song with chat mode on.");
                }
                else
                {
                    TwitchConnection.Instance.SendChatMessage("Every " + Plugin.ChatConfig.bitsPerCharge + " bits sent with a message adds a charge, which are used to activate commands! If you add super at the end of a command, it will cost " + Plugin.ChatConfig.chargesForSuperCharge + " Charges but will make the effect last much longer! " + Plugin.ChatConfig.chargesPerLevel + " Charges are generated every song with chat mode on. Every " + Plugin.ChatConfig.timeForCharges + " seconds, " + Plugin.ChatConfig.chargesOverTime + " are added.");
                }
            }
            if (message.Content.ToLower().Contains("!gm commands"))
            {
                TwitchConnection.Instance.SendChatMessage("Currently supported commands | status: Currrent Status of chat integration | charges: view current charges and costs | chargehelp: Explain charge system");
            }


            if (message.Content.ToLower().Contains("!gm charges"))
            {
                TwitchConnection.Instance.SendChatMessage("Charges: " + Plugin.charges + " | Commands Per Message: " + Plugin.ChatConfig.commandsPerMessage + " | " + Plugin.ChatConfig.GetChargeCostString());
            }
        }
コード例 #4
0
        public async Task Handle(ReceiveMessageNotification notification, CancellationToken cancellationToken)
        {
            var message = notification.Message;

            var context = _contextFactory.CreateDbContext();

            // obviously, don't store messages by ignored users
            if (context.IgnoredUsers.Any(i => i.Id == message.UserId && i.ChannelId == message.RoomId))
            {
                return;
            }

            var twitchMsg = new TwitchMessage
            {
                Id         = message.Id,
                ChannelId  = message.RoomId,
                UserId     = message.UserId,
                Message    = message.Message,
                ReceivedOn = DateTime.UtcNow
            };

            context.Messages.Add(twitchMsg);
            await context.SaveChangesAsync(cancellationToken);

            await _chainService.AddMessageAsync(twitchMsg.ChannelId, twitchMsg.Message, cancellationToken);
        }
コード例 #5
0
        private bool CheckForBadWordRegex(TwitchMessage twitchMessage)
        {
            var words = twitchMessage.Content.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var word in words)
            {
                // skip whitelisted words
                if (_whitelistedWords.Any(w => w.Word.Equals(word, StringComparison.InvariantCultureIgnoreCase)))
                {
                    continue;
                }

                foreach (var badword in TwitchSettings.BadWordsRegex)
                {
                    if (!Regex.IsMatch(word, badword, RegexOptions.IgnoreCase))
                    {
                        continue;
                    }

                    twitchMessage.CoughtWords.Add(word);
                    return(true);
                }
            }

            return(false);
        }
コード例 #6
0
        private void TwitchConnection_OnMessageReceived(TwitchConnection arg1, TwitchMessage message)
        {
            Log("Message Recieved, AsyncTwitch currently working");
            //Status check message
            if (charges < 0)
            {
                charges = 0;
            }
            twitchCommands.CheckChargeMessage(message);
            twitchCommands.CheckConfigMessage(message);
            twitchCommands.CheckStatusCommands(message);
            twitchCommands.CheckInfoCommands(message);

            if (Config.allowEveryone || (Config.allowSubs && message.Author.IsSubscriber) || message.Author.IsMod)
            {
                if (GMPUI.chatIntegration && isValidScene && !cooldowns.GetCooldown("Global"))
                {
                    commandsLeftForMessage = Config.commandsPerMessage;
                    twitchCommands.CheckPauseMessage(message);
                    twitchCommands.CheckGameplayCommands(message);
                    twitchCommands.CheckHealthCommands(message);
                    twitchCommands.CheckSizeCommands(message);
                    twitchCommands.CheckSpeedCommands(message);
                    twitchCommands.CheckGlobalCoolDown();
                }
            }
            trySuper        = false;
            sizeActivated   = false;
            healthActivated = false;
        }
コード例 #7
0
        private async Task LogsAsync(TwitchMessage twitchMessage)
        {
            try
            {
                var logs = await _overrustlelogsService.GetUserlogs(twitchMessage.Author, twitchMessage.Channel);

                if (logs == null || string.IsNullOrEmpty(logs))
                {
                    return;
                }
                var logWindow = new LogWindow
                {
                    Log =
                    {
                        Text = logs
                    },
                    Title = $"Logs User: {twitchMessage.Author} Channel: {twitchMessage.Channel}"
                };
                logWindow.Show();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
        }
コード例 #8
0
        private async Task OnReceived(
            string message
            )
        {
            // Internal Keepalive logic
            if (message.StartsWith(
                    "PING"
                    ))
            {
                await _socketWrapper.SendAsync(
                    $"PONG :tmi.twitch.tv"
                    );
            }
            var splitToCommands = message.Split(
                "\r\n",
                StringSplitOptions.RemoveEmptyEntries
                );

            foreach (var command in splitToCommands)
            {
                await _options.OnReceived?.Invoke(
                    TwitchMessage.Parse(
                        command
                        )
                    );
            }
        }
コード例 #9
0
 public SentUserMessage(TwitchMessage TwitchMessage, int PanelBorder, int border, int desiredWidth)
 {
     twitchMessage     = TwitchMessage;
     panelBorder       = PanelBorder;
     this.border       = border;
     this.desiredWidth = desiredWidth;
 }
コード例 #10
0
        private void MessageReceived(TwitchMessage msg)
        {
            string[] msgParts = msg.message.Split(' ').Distinct().ToArray();
            int      count    = 0;

            foreach (var pe in msgParts)
            {
                if (count > 3)
                {
                    break;
                }

                if (AlphaTwitchManager.BTTVEmotePool.ContainsKey(pe))
                {
                    AlphaTwitchManager.BTTVEmotePool.TryGetValue(pe, out Sprite sprite);
                    emotePool.Add(new Emote()
                    {
                        EmoteData = sprite, Type = EmoteType.BTTV, Id = pe
                    });
                    count++;
                }
                else if (AlphaTwitchManager.BTTVAnimatedEmotePool.ContainsKey(pe))
                {
                    AlphaTwitchManager.BTTVAnimatedEmotePool.TryGetValue(pe, out GIFer gif);
                    emotePool.Add(new Emote()
                    {
                        EmoteData = gif, Type = EmoteType.BTTVAnimated, Id = pe
                    });
                    count++;
                }
            }
        }
コード例 #11
0
    public List <TwitchMessage> GetMessages()
    {
        UpdateTwitchIntegration();

        List <TwitchMessage> twitchMessages = new List <TwitchMessage>();

        if (twitchClient.Available > 0)
        {
            var message = streamReader.ReadLine();

            if (message.Contains("PRIVMSG"))
            {
                string username    = message.Substring(0, message.IndexOf("!", 1));
                string chatMessage = message.Substring(message.IndexOf(":", 1) + 1);

                TwitchMessage twitchMessage = new TwitchMessage();
                twitchMessage.message  = chatMessage;
                twitchMessage.username = username;

                twitchMessages.Add(twitchMessage);
            }
        }

        return(twitchMessages);
    }
コード例 #12
0
        public ESCChatMessage(TwitchMessage twitchMessage)
        {
            this.IsSystemMessage = twitchMessage.IsSystemMessage;
            if (twitchMessage.Metadata != null)
            {
                this.Metadata = twitchMessage.Metadata;
            }
            if (twitchMessage.Emotes != null)
            {
                this.Emotes = twitchMessage.Emotes;
            }
            if (this.SystemMessageSetup())
            {
                this.SubMessage = twitchMessage.Message;
            }
            else
            {
                this.Message    = twitchMessage.Message;
                this.SubMessage = "";
            }
            this.Id = twitchMessage.Id;
            this.IsActionMessage = twitchMessage.IsActionMessage;
            this.IsMentioned     = twitchMessage.IsMentioned;
            this.Sender          = twitchMessage.Sender;
            this.Channel         = new ESCChatChannel(twitchMessage.Channel);
#if DEBUG
            Logger.Debug($"{this.Message}");
            Logger.Debug($"{this.SubMessage}");
#endif
        }
コード例 #13
0
        public override void Run(TwitchMessage msg)
        {
            List <Song> songList = StaticData.SongQueue.GetSongList();

            if (songList.Count() >= 1)
            {
                string msgString = "[Current Songs in Queue]: ";
                foreach (Song song in songList)
                {
                    if (msgString.Length + song.songName.Length + 2 > 496)
                    {
                        TwitchConnection.Instance.SendChatMessage(msgString);
                        msgString = "";
                    }
                    msgString += song.songName + ", ";
                }

                if (msgString.Length > 0)
                {
                    TwitchConnection.Instance.SendChatMessage(msgString);
                }
            }
            else
            {
                TwitchConnection.Instance.SendChatMessage("No Songs in Queue Currently");
            }
        }
コード例 #14
0
        public void CheckSpeedCommands(TwitchMessage message)
        {
            if (message.message.ToLower().Contains("!gm faster") && !Plugin.cooldowns.GetCooldown("Speed") && Plugin.commandsLeftForMessage > 0)
            {
                if (!Plugin.practicePluginInstalled)
                {
                    Plugin.TryAsyncMessage("Speed altering commands currently require Practice Plugin to be installed");
                    return;
                }
                if (Plugin.trySuper && Plugin.charges >= ChatConfig.chargesForSuperCharge + ChatConfig.fasterChargeCost)
                {
                    //               Plugin.beepSound.Play();
                    Plugin.twitchPowers.StartCoroutine(TwitchPowers.SpeedChange(Plugin.songAudio.clip.length, ChatConfig.fasterMultiplier));
                    Plugin.twitchPowers.StartCoroutine(TwitchPowers.CoolDown(Plugin.songAudio.clip.length, "Speed", "Fast Time!"));
                    Plugin.trySuper = false;
                    Plugin.charges -= ChatConfig.chargesForSuperCharge + ChatConfig.fasterChargeCost;
                    Plugin.commandsLeftForMessage -= 1;
                    globalActive = true;
                }
                else if (Plugin.charges >= ChatConfig.fasterChargeCost)
                {
                    //                Plugin.beepSound.Play();
                    Plugin.twitchPowers.StartCoroutine(TwitchPowers.SpeedChange(ChatConfig.fasterDuration, ChatConfig.fasterMultiplier));
                    Plugin.twitchPowers.StartCoroutine(TwitchPowers.CoolDown(ChatConfig.fasterCooldown, "Speed", "Temporary faster song speed Active."));
                    Plugin.charges -= ChatConfig.fasterChargeCost;
                    Plugin.commandsLeftForMessage -= 1;
                    globalActive = true;
                }
            }
            if (message.message.ToLower().Contains("!gm slower") && !Plugin.cooldowns.GetCooldown("Speed") && Plugin.commandsLeftForMessage > 0)
            {
                if (!Plugin.practicePluginInstalled)
                {
                    Plugin.TryAsyncMessage("Speed altering commands currently require Practice Plugin to be installed");
                    return;
                }


                if (Plugin.trySuper && Plugin.charges >= ChatConfig.chargesForSuperCharge + ChatConfig.slowerChargeCost)
                {
                    //               Plugin.beepSound.Play();
                    Plugin.twitchPowers.StartCoroutine(TwitchPowers.SpeedChange(Plugin.songAudio.clip.length, ChatConfig.slowerMultiplier));
                    Plugin.twitchPowers.StartCoroutine(TwitchPowers.CoolDown(Plugin.songAudio.clip.length, "Speed", "Weakling Slower Song Time!"));
                    Plugin.trySuper = false;
                    Plugin.charges -= ChatConfig.chargesForSuperCharge + ChatConfig.slowerChargeCost;
                    Plugin.commandsLeftForMessage -= 1;
                    globalActive = true;
                }
                else if (Plugin.charges >= ChatConfig.slowerChargeCost)
                {
                    //                Plugin.beepSound.Play();
                    Plugin.twitchPowers.StartCoroutine(TwitchPowers.SpeedChange(ChatConfig.slowerDuration, ChatConfig.slowerMultiplier));
                    Plugin.twitchPowers.StartCoroutine(TwitchPowers.CoolDown(ChatConfig.slowerCooldown, "Speed", "Temporary slower song speed Active."));
                    Plugin.charges -= ChatConfig.slowerChargeCost;
                    Plugin.commandsLeftForMessage -= 1;
                    globalActive = true;
                }
            }
        }
コード例 #15
0
        public override void Run(TwitchMessage msg)
        {
            if (!msg.Author.IsMod && !msg.Author.IsBroadcaster)
            {
                return;
            }

            string queryString = msg.Content.Remove(0, msg.Content.IndexOf(' ') + 1);

            if (!String.IsNullOrEmpty(queryString))
            {
                for (int i = 0; i < StaticData.SongQueue.GetSongList().Count; i++)
                {
                    Song song = StaticData.SongQueue.SongQueueList[i];
                    if (song.id.Contains(queryString) || song.requestedBy.Equals(queryString))
                    {
                        StaticData.SongQueue.GetSongList().RemoveAt(i);
                        StaticData.SongQueue.GetSongList().Insert(0, song);
                        if (StaticData.Config.AllowTwitchResponses)
                        {
                            TwitchConnection.Instance.SendChatMessage("Moved \"" + song.songName + "\" requested by " + song.requestedBy + " to top of queue.");
                        }
                    }
                }
            }
            else
            {
                if (String.IsNullOrEmpty(queryString) && msg.Author.DisplayName.Equals("QueueBot"))
                {
                    return;
                }
                List <Song> temporaryList   = new List <Song>();
                List <Song> currentSongList = StaticData.SongQueue.GetSongList();

                int j = 0;
                for (int i = 0; i < currentSongList.Count; i++)
                {
                    var song = currentSongList[i];
                    if (!song.requestedBy.Equals(msg.Author.IsBroadcaster))
                    {
                        temporaryList.Insert(j, song);
                        j++;
                    }
                    else
                    {
                        temporaryList.Add(song);
                    }
                }

                StaticData.SongQueue.SongQueueList.Clear();
                StaticData.SongQueue.SongQueueList.AddRange(temporaryList);
                temporaryList.Clear();

                if (StaticData.Config.AllowTwitchResponses)
                {
                    TwitchConnection.Instance.SendChatMessage("Moved all Non-Broadcaster Songs to top of queue.");
                }
            }
        }
コード例 #16
0
 public override void Run(TwitchMessage msg)
 {
     StaticData.SongQueue.SaveSongQueue();
     if (StaticData.Config.AllowTwitchResponses)
     {
         TwitchConnection.Instance.SendChatMessage("Saving Queue.");
     }
 }
コード例 #17
0
 IEnumerator HighlightMessage(TwitchMessage twitchMessage)
 {
     if (twitchMessage == null)
     {
         yield break;                                // twitchMessage could be null if the original message never added any coroutines to the queue.
     }
     StartCoroutine(twitchMessage.DoBackgroundColorChange(twitchMessage.HighlightColor));
 }
コード例 #18
0
        public bool MyChatMessageHandler(TwitchMessage msg)
        {
            string excludefilename = "chatexclude.users";



            return(RequestBot.Instance && RequestBot.listcollection.contains(ref excludefilename, msg.user.displayName.ToLower(), RequestBot.ListFlags.Uncached));
        }
コード例 #19
0
 public void OnLoad()
 {
     initialized            = false;
     _internalTwitchMessage = new TwitchMessage();
     _internalTwitchMessage.Author.IsBroadcaster = true;
     _internalTwitchMessage.Author.IsMod         = true;
     _internalTwitchMessage.Author.DisplayName   = "QueueBot";
     SetupUI();
 }
コード例 #20
0
 public override void Run(TwitchMessage msg)
 {
     if (!StaticData.UserRequestCount.ContainsKey(msg.Author.DisplayName))
     {
         TwitchConnection.Instance.SendChatMessage($"{msg.Author.DisplayName}, you have no songs in the queue.");
         return;
     }
     TwitchConnection.Instance.SendChatMessage($"{msg.Author.DisplayName}, you have {StaticData.UserRequestCount[msg.Author.DisplayName]} songs in queue.");
 }
コード例 #21
0
        public void CheckStatusCommands(TwitchMessage message)
        {
            if (message.Author.IsBroadcaster || message.Author.IsMod)
            {
                if (message.Content.ToLower().Contains("!gm reset"))
                {
                    Plugin.cooldowns.ResetCooldowns();
                    TwitchPowers.ResetPowers(true);
                    Plugin.twitchPowers.StopAllCoroutines();
                    Plugin.charges = Plugin.Config.chargesPerLevel;
                    TwitchConnection.Instance.SendChatMessage("Resetting non Permanent Powers");
                }
            }


            if (message.Content.ToLower().Contains("!gm pp"))
            {
                if (Plugin.currentpp != 0)
                {
                    TwitchConnection.Instance.SendChatMessage("Streamer Rank: #" + Plugin.currentRank + ". Streamer pp: " + Plugin.currentpp + "pp");
                }
                else
                {
                    TwitchConnection.Instance.SendChatMessage("Currently do not have streamer info");
                }
            }
            if (message.Content.ToLower().Contains("!gm status"))
            {
                string scopeMessage = "";
                int    scope        = CheckCommandScope();
                switch (scope)
                {
                case 0:
                    scopeMessage = "Everyone has access to commands";
                    break;

                case 1:
                    scopeMessage = "Subscribers have access to commands";
                    break;

                case 2:
                    scopeMessage = "Moderators have access to commands";
                    break;
                }

                Plugin.beepSound.Play();
                if (GMPUI.chatIntegration)
                {
                    TwitchConnection.Instance.SendChatMessage("Chat Integration Enabled. " + scopeMessage);
                }
                else
                {
                    TwitchConnection.Instance.SendChatMessage("Chat Integration Not Enabled. " + scopeMessage);
                }
            }
        }
コード例 #22
0
 private async Task NotifyMessageObservers(TwitchMessage Message)
 {
     await Task.Run(() => {
         foreach (var observer in _messageObservers)
         {
             observer.Update(Message);
             _logger.LogInformation($"Message observer updated {observer.GetName()}");
         }
     });
 }
コード例 #23
0
 private static void LogMessage(TwitchMessage message)
 {
     if (message.IsChatMessage)
     {
         Console.WriteLine(message.Author.PadRight(30) + " ::: " + message.Content);
     }
     else
     {
         Console.WriteLine("TWITCH_SYSTEM ::: " + message.RawMessage);
     }
 }
コード例 #24
0
        public void CheckHealthCommands(TwitchMessage message)
        {
            if (!Plugin.cooldowns.GetCooldown("Health"))
            {
                if (message.Content.ToLower().Contains("!gm instafail"))
                {
                    if (Plugin.trySuper && Plugin.charges >= Plugin.Config.chargesForSuperCharge + Plugin.Config.instaFailChargeCost)
                    {
                        //      Plugin.beepSound.Play();

                        Plugin.twitchPowers.StartCoroutine(TwitchPowers.TempInstaFail(Plugin.songAudio.clip.length));
                        Plugin.twitchPowers.StartCoroutine(TwitchPowers.CoolDown(Plugin.songAudio.clip.length, "Health", "Super Insta Fail Active."));
                        Plugin.trySuper                = false;
                        Plugin.healthActivated         = true;
                        Plugin.charges                -= Plugin.Config.chargesForSuperCharge + Plugin.Config.instaFailChargeCost;
                        Plugin.commandsLeftForMessage -= 1;
                        globalActive = true;
                    }
                    else if (Plugin.charges >= Plugin.Config.instaFailChargeCost)
                    {
                        //         Plugin.beepSound.Play();
                        Plugin.twitchPowers.StartCoroutine(TwitchPowers.TempInstaFail(Plugin.Config.instaFailDuration));
                        Plugin.twitchPowers.StartCoroutine(TwitchPowers.CoolDown(Plugin.Config.instaFailCooldown, "Health", "Insta Fail Active."));
                        Plugin.healthActivated         = true;
                        Plugin.charges                -= Plugin.Config.instaFailChargeCost;
                        Plugin.commandsLeftForMessage -= 1;
                        globalActive = true;
                    }
                }

                if (message.Content.ToLower().Contains("!gm invincible") && !Plugin.healthActivated && !Plugin.cooldowns.GetCooldown("Health"))
                {
                    if (Plugin.trySuper && Plugin.charges >= Plugin.Config.chargesForSuperCharge + Plugin.Config.invincibleChargeCost)
                    {
                        //         Plugin.beepSound.Play();
                        Plugin.twitchPowers.StartCoroutine(TwitchPowers.TempInvincibility(Plugin.songAudio.clip.length));
                        Plugin.twitchPowers.StartCoroutine(TwitchPowers.CoolDown(Plugin.songAudio.clip.length, "Health", "Super Invincibility Active."));
                        Plugin.trySuper = false;
                        Plugin.charges -= Plugin.Config.chargesForSuperCharge + Plugin.Config.invincibleChargeCost;
                        Plugin.commandsLeftForMessage -= 1;
                        globalActive = true;
                    }
                    else if (Plugin.charges >= Plugin.Config.invincibleChargeCost)
                    {
                        //          Plugin.beepSound.Play();
                        Plugin.twitchPowers.StartCoroutine(TwitchPowers.TempInvincibility(Plugin.Config.invincibleDuration));
                        Plugin.twitchPowers.StartCoroutine(TwitchPowers.CoolDown(Plugin.Config.invincibleCooldown, "Health", "Invincibility Active."));
                        Plugin.charges -= Plugin.Config.invincibleChargeCost;
                        Plugin.commandsLeftForMessage -= 1;
                        globalActive = true;
                    }
                }
            }
        }
コード例 #25
0
 public void TwitchConnectionMulti_OnMessageReceived(TwitchConnection arg1, TwitchMessage message)
 {
     if (multiActive)
     {
         Log("Checking message");
         string messageString = message.Content.ToLower();
         multiCommands.CheckHealthCommands(messageString);
         multiCommands.CheckSizeCommands(messageString);
         multiCommands.CheckGameplayCommands(messageString);
         multiCommands.CheckSpeedCommands(messageString);
     }
 }
コード例 #26
0
 public override void Run(TwitchMessage msg)
 {
     if (!msg.Author.IsMod && !msg.Author.IsBroadcaster)
     {
         return;
     }
     StaticData.UserPickedByRandomize.Clear();
     if (StaticData.Config.AllowTwitchResponses)
     {
         TwitchConnection.Instance.SendChatMessage("All users cleared and can request songs.");
     }
 }
コード例 #27
0
        private void MessageReceived(TwitchMessage msg)
        {
            //User Fetch and Cache
            PersistentSingleton <HMMainThreadDispatcher> .instance.Enqueue(GetTwitchViewerInfo(msg));


            //Emote Cache
            if (msg.emotes != "")
            {
                string[] emotes = msg.emotes.Split('/');

                if (!Settings.EmotePopups.Enable)
                {
                    return;
                }

                int count = 0;
                foreach (var emote in emotes)
                {
                    if (count > 3)
                    {
                        break;
                    }

                    string invemote = emote;
                    int    index    = invemote.IndexOf(":");
                    if (index > 0)
                    {
                        invemote = invemote.Substring(0, index);
                    }

                    if (!TwitchEmotePool.ContainsKey(invemote))
                    {
                        SharedCoroutineStarter.instance.StartCoroutine(LoadScripts.LoadSpriteCoroutine($"https://static-cdn.jtvnw.net/emoticons/v1/{invemote}/3.0", (image) =>
                        {
                            if (!TwitchEmotePool.ContainsKey(invemote))
                            {
                                TwitchEmotePool.Add(invemote, image);
                                EmoteProcessed.Invoke(invemote);
                            }
                        }));
                    }
                    else
                    {
                        EmoteProcessed.Invoke(invemote);
                    }
                    count++;
                }
            }
        }
コード例 #28
0
 public void CheckPauseMessage(TwitchMessage message)
 {
     if (message.Content.ToLower().Contains("!gm pause") && Plugin.commandsLeftForMessage > 0)
     {
         if (Plugin.charges >= Plugin.Config.pauseChargeCost)
         {
             Plugin.beepSound.Play();
             Plugin.twitchPowers.StartCoroutine(TwitchPowers.Pause());
             Plugin.twitchPowers.StartCoroutine(TwitchPowers.CoolDown(Plugin.Config.pauseGlobalCooldown, "Global", "Game Paused :)"));
             Plugin.charges -= Plugin.Config.pauseChargeCost;
             Plugin.commandsLeftForMessage = 0;
         }
     }
 }
コード例 #29
0
        private void OnMessageReceived(TwitchConnection connection, TwitchMessage msg)
        {
            if (!msg.Content.StartsWith(Prefix))
            {
                return;
            }
            string commandString = msg.Content.Split(' ')[0];

            commandString = commandString.Remove(0, Prefix.Length);

            if (_commandDict.ContainsKey(commandString))
            {
                _commandDict[commandString].Run(msg);
            }
        }
コード例 #30
0
 private void SendChatMessage(string message)
 {
     try
     {
         Plugin.Log($"Sending message: \"{message}\"");
         TwitchWebSocketClient.SendMessage($"PRIVMSG #{Config.Instance.TwitchChannelName} :{message}");
         TwitchMessage tmpMessage = new TwitchMessage();
         tmpMessage.user = TwitchWebSocketClient.OurTwitchUser;
         MessageParser.Parse(new ChatMessage(message, tmpMessage));
     }
     catch (Exception e)
     {
         Plugin.Log($"Exception was caught when trying to send bot message. {e.ToString()}");
     }
 }
コード例 #31
0
        private static bool ParseUserMessageCommand(ref TwitchMessage twitchMessage, ref string[] parts)
        {
            if (parts.Length < 3)
                return false;

            if (parts.Length == 3)
            {
                twitchMessage.Command = parts[1];
                twitchMessage.Channel = parts[2].Remove(0, 1);

                if (twitchMessage.Command.Equals("PRIVMSG"))
                    twitchMessage.Type = TwitchMessageType.Common;
                else
                    twitchMessage.Type = TwitchMessageType.Command;

                twitchMessage.Sender = parts[0].Split('!')[0];

                return true;
            }

            if (parts.Length > 3)
            {
                uint commandCode;
                if (uint.TryParse(parts[1], out commandCode))
                    twitchMessage.CommandCode = commandCode;

                twitchMessage.Type = TwitchMessageType.Service;
                twitchMessage.Sender = parts[0].Split('.')[0];
                twitchMessage.Command = "NAMES";

                twitchMessage.Channel = parts[parts.Length - 1].Remove(0, 1);

                return true;
            }

            return false;
        }
コード例 #32
0
        private static bool ParseTwitchServiceCommand(ref TwitchMessage twitchMessage, ref string[] parts)
        {
            if (parts.Length < 3)
                return false;

            twitchMessage.Type = TwitchMessageType.Service;
            twitchMessage.Sender = parts[0];

            uint commandCode;
            if (uint.TryParse(parts[1], out commandCode))
            {
                twitchMessage.CommandCode = commandCode;
                twitchMessage.Channel = parts[2];
            }
            else if (parts[1].Equals("NOTICE"))
            {
                twitchMessage.Command = parts[1];
                twitchMessage.Type = TwitchMessageType.LoginError;
            }
            else if (!parts[1].Equals("CAP"))
                return false;

            if (parts.Length == 4)
            {
                twitchMessage.Command = parts[3];
                twitchMessage.Type = TwitchMessageType.Error;
            }

            return true;
        }