Exemplo n.º 1
0
        public static async void OnBC(ServerBroadcastEventArgs args)
        {
            try
            {
                string msg  = args.Message.ToString();
                var    chat = await Discord.DiscordBot.GetChannelAsync(Discord.Config.ChatID);

                try
                {
                    Regex           regex   = new Regex(@"\[i:(\S*)]");
                    MatchCollection matches = regex.Matches(msg);

                    if (matches.Count > 0)
                    {
                        msg = regex.Replace(msg, "");
                    }

                    Regex isPlayer = new Regex(@".*:");
                    Regex regex1   = new Regex(@".* was .*kicked for '.*'");
                    Regex regex2   = new Regex(@".* .*kicked .* for '.*'");

                    if (msg.Contains("(Server Broadcast)") || regex1.IsMatch(msg) || regex2.IsMatch(msg))
                    {
                        await Discord.DiscordBot.SendMessageAsync(chat, $"*{msg}*");
                    }
                }
                catch (Exception a)
                {
                    TShock.Log.ConsoleError("DiscordBridge error when sending message to discord: {0}", a.Message);
                }
            }
            catch (RateLimitException ex) { }

            return;
        }
        private void OnServerBroadcast(ServerBroadcastEventArgs args)
        {
            var literalText = Language.GetText(args.Message._text).Value;

            if (args.Message._substitutions?.Length > 0)
            {
                literalText = string.Format(literalText, args.Message._substitutions);
            }

            if (
                literalText.EndsWith(" has joined.") ||              // User joined
                literalText.EndsWith(" has left.") ||                // User left
                literalText.EndsWith(" has awoken!")                 //|| // Boss Spawn
                //Regex.IsMatch(literalText, @".*?:\s+.*") // Chat
                )
            {
                return;
            }

            var CheckChat = ChatHolder.Where(x => literalText.Contains(x.Player.Name) && literalText.Contains(x.Text));

            if (CheckChat.Count() > 0)
            {
                ChatHolder.Remove(ChatHolder.First());
                return;
            }

            Core.RaiseTerrariaMessageReceived(this, TCRPlayer.Server, literalText);
        }
Exemplo n.º 3
0
 private void OnBroadcast(ServerBroadcastEventArgs e)
 {
     foreach (EventListener el in Plugins)
     {
         ServerListener sl = (ServerListener)el.Listener;
         if (el.Event == Event.ServerBroadcast)
         {
             sl.OnBroadcast(e);
         }
     }
 }
Exemplo n.º 4
0
        private void OnServerBroadcast(ServerBroadcastEventArgs args)
        {
            string message = args.Message.ToString();

            Console.WriteLine(args.Message._text);
            if (args.Message._text.StartsWith("DeathText"))
            {
                message = string.Format("(死掉了){0}", message);
            }

            PostMessageToDiscord(message);
        }
Exemplo n.º 5
0
        private void OnServerBroadcast(ServerBroadcastEventArgs args)
        {
            if (botInfo.EnableAnnouncer == false)
            {
                return;
            }

            if ((args.Color.R == 50 && args.Color.G == 255 && args.Color.B == 130) || (args.Color.R == 175 && args.Color.G == 75 && args.Color.B == 255))
            {
                messageModel.content = $"Server Message: {args.Message}";

                Task.Run(async() => await CreateMessage(messageModel, botInfo.WebhookID, botInfo.WebhookToken));
            }
        }
Exemplo n.º 6
0
        private void OnBroadcast(ServerBroadcastEventArgs args)
        {
            if (Regex.IsMatch(args.Message.ToString(), @"has defeated the \d+th"))
            {
                return;
            }

            if (Regex.IsMatch(args.Message.ToString(), @"has joined the \S+ party"))
            {
                return;
            }

            if (Regex.IsMatch(args.Message.ToString(), @"is no longer on a party"))
            {
                return;
            }

            if (Regex.IsMatch(args.Message.ToString(), @"Looks like .+ (is|are) throwing a party"))
            {
                return;
            }

            if (Regex.IsMatch(args.Message.ToString(), @"Party time's over!"))
            {
                return;
            }

            if (Regex.IsMatch(args.Message.ToString(), @"\S+ the Traveling Merchant has (arrived|departed)!"))
            {
                return;
            }

            if (Regex.IsMatch(args.Message.ToString(), @"^Saving world\.\.\.$"))
            {
                return;
            }

            if (Regex.IsMatch(args.Message.ToString(), @"World saved."))
            {
                return;
            }

            if (Regex.IsMatch(args.Message.ToString(), @"^<[^>]+>( sent a sticker.| sent a document.|: .+)"))
            {
                return;
            }

            SendTelegramMessage(args.Message.ToString());
        }
Exemplo n.º 7
0
 private void OnServerBroadcast(ServerBroadcastEventArgs args)
 {
     if (args != null)
     {
         if (args.Message == null)
         {
             return;
         }
         if (args.Color == null)
         {
             return;
         }
         AsynchronousSocketSender.Send($"ServerBroadcast: {args.Message}\n{args.Color.ToString()}");
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Called when a broadcast message is intercepted
        /// </summary>
        /// <param name="args">event arguments passed by hook</param>
        private void OnBroadcast(ServerBroadcastEventArgs args)
        {
            // Do not relay game broadcasts to Discord if this option is enabled
            if (Config.SilenceBroadcasts)
            {
                return;
            }

            // Filter broadcast messages based on content
            if (Util.FilterBroadcast($"{args.Message}"))
            {
                return;
            }

            Util.Log($"Server broadcast: {args.Message}", Util.Severity.Info);
            discord.Send(Config.BroadcastText.Replace("%m%", args.Message.ToString()));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Called when a broadcast message is intercepted
        /// </summary>
        /// <param name="args">event arguments passed by hook</param>
        private void OnBroadcast(ServerBroadcastEventArgs args)
        {
            // Do not relay game broadcasts to Discord if this option is enabled
            if (Config.SilenceBroadcasts)
            {
                return;
            }

            // Filter broadcast messages based on content
            if (Util.FilterBroadcast($"{args.Message}"))
            {
                return;
            }

            Util.Log($"Server broadcast: {args.Message}", Util.Severity.Info);
            discord.Send($"**:mega: Broadcast:** {args.Message}");
        }
Exemplo n.º 10
0
 public virtual void OnBroadcast(ServerBroadcastEventArgs e)
 {
 }
Exemplo n.º 11
0
 public override void OnBroadcast(ServerBroadcastEventArgs e)
 {
     _plugin.Irc.WriteLine("PRIVMSG {0} :{1}", _plugin.RunningConfiguration.Channel, e.Message.Replace('§', '\x3'));
 }
Exemplo n.º 12
0
        private void OnServerBroadcast(ServerBroadcastEventArgs args)
        {
            var literalText = Language.GetText(args.Message._text).Value;

            EventManager.RaiseTerrariaMessageReceived(this, -1, string.Format(literalText, args.Message._substitutions));
        }