public void ParseMessage() { string content = @" { ""mode"": ""test"", ""id"": ""5359569e-0cb0-4287-ac6a-356826cce032"", ""eventDate"": ""2014-10-01T13:48:30Z"", ""eventType"": ""subscription_payment_pending_retry"", ""attemptNumber"": ""1"", ""key"": ""secret"", ""links"": [ { ""url"": ""https://api.neteller.com/v1/subscriptions/234234224/invoices/99102"", ""rel"": ""invoice"", ""method"": ""GET"" } ] }"; var webhook = new WebhookHandler(); WebhookMessage message = webhook.GetMessage(content); Assert.That(message.Mode, Is.EqualTo("test")); Assert.That(message.Id, Is.EqualTo("5359569e-0cb0-4287-ac6a-356826cce032")); Assert.That(message.EventDate, Is.EqualTo(DateTime.Parse("2014-10-01T13:48:30", null, DateTimeStyles.AssumeUniversal))); //don't test - dependent on current thread locale timezone //locale Assert.That(message.EventDate, Is.EqualTo(new DateTime(2014, 10, 1, 13+2, 48, 30))); //utc +2 Assert.That(message.EventType, Is.EqualTo(WebhookEventType.SubscriptionPaymentPendingRetry)); Assert.That(message.AttemptNumber, Is.EqualTo(1)); Assert.That(message.Key, Is.EqualTo("secret")); Assert.That(message.Links, Is.Not.Empty); Assert.That(message.Links[0].url, Is.EqualTo("https://api.neteller.com/v1/subscriptions/234234224/invoices/99102")); }
public void ParseMessage() { string content = @" { ""mode"": ""test"", ""id"": ""5359569e-0cb0-4287-ac6a-356826cce032"", ""eventDate"": ""2014-10-01T13:48:30Z"", ""eventType"": ""subscription_payment_pending_retry"", ""attemptNumber"": ""1"", ""key"": ""secret"", ""links"": [ { ""url"": ""https://api.neteller.com/v1/subscriptions/234234224/invoices/99102"", ""rel"": ""invoice"", ""method"": ""GET"" } ] }" ; var webhook = new WebhookHandler(); WebhookMessage message = webhook.GetMessage(content); Assert.That(message.Mode, Is.EqualTo("test")); Assert.That(message.Id, Is.EqualTo("5359569e-0cb0-4287-ac6a-356826cce032")); Assert.That(message.EventDate, Is.EqualTo(DateTime.Parse("2014-10-01T13:48:30", null, DateTimeStyles.AssumeUniversal))); //don't test - dependent on current thread locale timezone //locale Assert.That(message.EventDate, Is.EqualTo(new DateTime(2014, 10, 1, 13+2, 48, 30))); //utc +2 Assert.That(message.EventType, Is.EqualTo(WebhookEventType.SubscriptionPaymentPendingRetry)); Assert.That(message.AttemptNumber, Is.EqualTo(1)); Assert.That(message.Key, Is.EqualTo("secret")); Assert.That(message.Links, Is.Not.Empty); Assert.That(message.Links[0].url, Is.EqualTo("https://api.neteller.com/v1/subscriptions/234234224/invoices/99102")); }
public void setHandler(string eventName, WebhookHandler callback) { if (!_handlers.ContainsKey(eventName)) { throw new exp.RiminderArgumentException(String.Format("'{0}' is not a valid event name.", eventName)); } _handlers[eventName] = callback; }
public static void OnEnd(RoundEndEvent ev) { WebhookHandler wb = new WebhookHandler(); if (AdminLogs.Instance.Config.RoundEnd) { wb.SendMessage("Round Ended", "Round Results", $"```# of people escaped : {ev.EscapedPlayers}\nForce Ended? : {ev.ForceEnded}```", 12874076); } }
public static void OnStart() { WebhookHandler wb = new WebhookHandler(); if (AdminLogs.Instance.Config.RoundStart) { wb.SendTitle("Round Started", 8569950); } }
public static void OnJoin(PlayerJoinFinalEvent ev) { WebhookHandler wb = new WebhookHandler(); IPlayer player = ev.player; Player api = new Player(player); if (AdminLogs.Instance.Config.PlayerJoin) { wb.SendMessage("Player Joined", "Username", $"```{api.Nickname}```", 8569950); } Log.Info("Player Joined"); }
public static void OnChat(SendingChatMessageEventArgs ev) { WebhookHandler wb = new WebhookHandler(); if (AdminLogs.Instance.Config.OnChat) { if (!ev.Message.StartsWith("/")) { wb.SendMessage("Chat Message", $"User : {ev.Player.Nickname}", ev.Message, 13419610); } } if (AdminLogs.Instance.Config.PlayerCommands) { if (ev.Message.StartsWith("/")) { wb.SendMessage("Player Command", $"User : {ev.Player.Nickname}", ev.Message, 13419610); } } }
public void RestSharpSimpleServerTest() { const Method httpMethod = Method.POST; using (WebhookServer.Create(BASE_URL, WebhookHandler.Generic <RequestBodyCapturer>())) { var client = new RestClient(BASE_URL); var request = new RestRequest(RequestBodyCapturer.RESOURCE, httpMethod); const string contentType = "text/plain"; const string bodyData = "abc123 foo bar baz BING!"; request.AddParameter(contentType, bodyData, ParameterType.RequestBody); var resetEvent = new ManualResetEvent(false); client.ExecuteAsync(request, response => resetEvent.Set()); resetEvent.WaitOne(); AssertHasRequestBody(contentType, bodyData); } }
public static void OnChangeClass(PlayerClassChangeEvent ev) { // In Locally hosted servers, often the chat would be spammed with respawns from host. if (ev.player.PlayerName.Equals("Host")) { return; } WebhookHandler wb = new WebhookHandler(); if (ev.newClassId == 0 && ev.prevClassId == 1) { wb.SendTitle($"{ev.player.PlayerName} has died!", 12874076); } if (ev.newClassId == 1 && ev.prevClassId == 0) { wb.SendTitle($"{ev.player.PlayerName} has respawned!", 12874076); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Following lines can throw if configuration is not correctly set. // This correctly prevents container from starting in error scenario. // Might throw-> var healthCheckModel = new HealthCheckModel() { LivenessCheck = Configuration.GetValue <bool>("livenessCheck"), ReadinessCheck = Configuration.GetValue <bool>("readinessCheck") }; IHealthCheckRepository healthCheckRepository = new HealthCheckRepository(); IWebhookHandler webhookHandler = new WebhookHandler(Configuration["webhook"]); webhookHandler.InvokeAsync(WebhookEvents.AppStarted, healthCheckRepository.Get()).Wait(); // <-Might throw services.AddSingleton(webhookHandler); services.AddSingleton(healthCheckRepository); services.AddSingleton <Microsoft.Extensions.Hosting.IHostedService, BackgroundReportingService>(); services.AddMvc(); }
/// <summary> /// Initializes a new instance of the <see cref="MessengerController"/> class. /// </summary> public MessengerController() { _webHookHandler = new WebhookHandler("channelsis", "79faa9a8710333289b595925e5fb7e72"); _clientMessenger = new ClientMessenger("EAAa2PqNTZABwBAAXOwwbAbZCaUFqU3KTeiZC1LCJjOr2ZAZB32bXx0p9gMqWedLJsse4xW8BXMatyYrbvIp0ICLiDmRVxM8Yp6cHPZATYjDsz0qZCmhhZAHJNeYpkVNMuEKjIw9goQUHgI54YOouZBzJa80fZCYoxtgJaWVYyQEKOhawZDZD"); }