All pages
Powered by GitBook
1 of 5

Loading...

Loading...

Loading...

Loading...

Loading...

Email

To store and send email via an SMTP address, register the server at startup and use the AlertManager.Email() call anywhere in code later.

Code

PerigeeApplication.ApplicationNoInit("Email",  (c) => {

    //Register once
    AlertManager.RegisterSMTPServer("MyName", "MyPassword", "smtp.gmail.com", 587, true);

    var em = new System.Net.Mail.MailMessage();
    em.To.Add("[email protected]");
    em.Body = "Hello!";
    em.Subject = "Test Email";
    AlertManager.Email(em);

});

SMS

Perigee currently supports two different SMS clients right out of the box. It's easy to register them and use them from anywhere within your application.

  1. At the start of your Perigee application, register the related alert managers.

  2. Anywhere from the code later on, call AlertManager.SMS() and supply the

    • Name (The name of the account you registered)

    • ToNumber (Who it is going to, if within the US, start with the digit 1)

    • Message Body (The SMS body content)

Code

PerigeeApplication.ApplicationNoInit("SMS",  (c) => {

    //Register once
    AlertManager.RegisterSMS_Vonage("Vonage", "11231234567", "key", "secret");
    AlertManager.RegisterSMS_Twilio("Twilio", "11231234567", "accountkey", "apikey", "apisecret");

    //Alert from anywhere in the application later
    var rsp = AlertManager.SMS("Twilio", "19998887777", "Sending a message via twilio");

});

Alert Managers

Discord

To use the embedded discord client. Register the hook URI at start, then call anywhere else

Code

PerigeeApplication.ApplicationNoInit("Discord",  (c) => {

    //Register once
    AlertManager.RegisterDiscordWebhook("bot", "WEBHOOKURI");

    //Call anywhere else
    int IssueCount = 0;
    AlertManager.Webhook_Discord("bot", new DiscordMessage()
    {
        Embeds = new List<DiscordEmbed>() {
            new DiscordEmbed() {
                Title = $"My awesome discord enabled app {(IssueCount > 0 ? "failed" : "completed")}",
                Description = IssueCount > 0 ? "Issues exist, please check log." : "Everything completed as expected",
                Color = IssueCount > 0 ? System.Drawing.Color.Yellow : System.Drawing.Color.Green,
                Fields = new List<EmbedField> {

                    new EmbedField() { InLine = true, Name = "Server", Value = "MyServer"},
                    new EmbedField() { InLine = true, Name = "Issue Count", Value =  IssueCount.ToString() },
                    new EmbedField() { InLine = false, Name = "Location", Value = Directory.GetCurrentDirectory() },
                }
            }
        }
    });

});

There's also a builder method is you're creating the same information, it makes the creation a bit more compact and without having to remember the nested syntax:

AlertManager.Webhook_Discord("bot", DiscordMessage.Builder(
        $"My awesome discord enabled app {(IssueCount > 0 ? "failed" : "completed")}",
        IssueCount > 0 ? "Issues exist, please check log." : "Everything completed as expected", null,
        IssueCount > 0 ? System.Drawing.Color.Yellow : System.Drawing.Color.Green,
        EmbedField.Builder("Server", "MyServer"),
        EmbedField.Builder("Issue Count", IssueCount.ToString()),
        EmbedField.Builder("Location", Directory.GetCurrentDirectory())));

Teams

Teams requires a third party library and card content.

DEMO coming soon: