Example #1
0
        public static void SendMessage(string message, bool filtered)
        {
            if (!CMOptions.ModuleEnabled || String.IsNullOrWhiteSpace(message))
            {
                return;
            }

            var uri = GetWebhookUri();

            if (uri.Contains("NULL"))
            {
                return;
            }

            message = message.StripHtmlBreaks(true).StripHtml(false);

            if (filtered)
            {
                if (CMOptions.FilterSaves && _SaveMessages.Any(o => Insensitive.Contains(message, o)))
                {
                    return;
                }

                if (CMOptions.FilterRepeat && _LastMessage == message)
                {
                    return;
                }
            }

            _LastMessage = message;

            var d = _Pool.Acquire();

            d["content"]  = message;
            d["username"] = ServerList.ServerName;
            d["file"]     = null;
            d["embeds"]   = null;

            WebAPI.BeginRequest(
                uri,
                d,
                (req, o) =>
            {
                req.Method      = "POST";
                req.ContentType = FileMime.Lookup("json");
                req.SetContent(Json.Encode(o));

                _Pool.Free(o);
            },
                null);
        }
 public void Recycle()
 {
     DictionaryPool <KeyType, ObjectType, PoolIdentifier> .Free(this);
 }