Exemplo n.º 1
0
        private static void HandleIPN(WebAPIContext context)
        {
            var test = context.Request.Queries["test"] != null || Insensitive.Contains(context.Request.Data, "test_ipn=1");

            var endpoint = test ? "ipnpb.sandbox." : "ipnpb.";

            var paypal = String.Format("https://{0}paypal.com/cgi-bin/webscr", endpoint);

            WebAPI.BeginRequest(paypal, "cmd=_notify-validate&" + context.Request.Data, BeginVerification, EndVerification);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public static void RequestVersion()
        {
            if (_Timeout != null && _Timeout.Running)
            {
                CSOptions.ToConsole("Previous request has not been handled yet.");
                return;
            }

            CSOptions.ToConsole("Requesting remote version...");

            _Timeout = Timer.DelayCall(
                TimeSpan.FromMilliseconds(CSOptions.Timeout.TotalMilliseconds + 1000),
                () =>
            {
                CSOptions.ToConsole("Request timed-out.");

                NotifyStaff("Update request failed, the connection timed-out.", true, 1.0, 10.0);
            });

            WebAPI.BeginRequest(URL != null ? URL.ToString() : DefaultURL, null, OnSend, OnReceive);
        }