Exemplo n.º 1
0
        public async Task <bool> Send(string to, string template, string[] replacements)
        {
            //Get Predefined email content from a json file
            var emailContent = JsonFileReader.ReadFile <List <EmailContent> >("EmailContent");
            var emailDetails = emailContent.Find(content => content.Template == template);

            var message = emailDetails.Message;

            if (replacements?.Length > 0)
            {
                message = string.Format(emailDetails.Message, replacements);
            }

            //Sends the email using the SendGrid client
            var response = await _sendGridBroker.SendEmail(new EmailAddress(to), new EmailAddress(emailDetails.From), message, emailDetails.Subject);

            return(response);
        }
Exemplo n.º 2
0
        public bool Send(string mobileNumber, string template, string messagePlaceHolders)
        {
            //Get Predefined sms content from a json file
            var smsContent = JsonFileReader.ReadFile <List <SmsContent> >("SmsContent");
            var smsDetails = smsContent.Find(content => content.Template == template);

            var message = smsDetails.Message;

            //Add the place holders in the message
            if (!string.IsNullOrWhiteSpace(messagePlaceHolders))
            {
                message = string.Format(smsDetails.Message, messagePlaceHolders);
            }

            //Sends the SMS using the Nexmo client
            var response = _nexmoBroker.SendSms(mobileNumber, message, smsDetails.Title, smsDetails.From);

            return(response);
        }
Exemplo n.º 3
0
        public InjhinuityInstance()
        {
            //Logging configuration for the local bot instance
            var logConfig     = new LoggingConfiguration();
            var consoleTarget = new ColoredConsoleTarget()
            {
                Layout = @"${date:format=HH\:mm\:ss} ${logger} | ${message}"
            };

            logConfig.AddTarget("Console", consoleTarget);
            logConfig.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, consoleTarget));

            LogManager.Configuration = logConfig;
            _log = LogManager.GetCurrentClassLogger();

            //Creates the bot's loggin credentials for Discord
            BotCredentials = new BotCredentials();

            var fileReader = new JsonFileReader();
            var json       = fileReader.ReadFile(_botConfigPath);

            BotConfig = JsonConvert.DeserializeObject <BotConfig>(json);

            //Creates the client and hooks it up to our events for startup and logging
            Client = new DiscordSocketClient(new DiscordSocketConfig
            {
                MessageCacheSize    = 1000,
                LogLevel            = LogSeverity.Warning,
                ConnectionTimeout   = int.MaxValue,
                AlwaysDownloadUsers = false,
            });

            Client.Ready += OnClientReady;
            Client.Log   += ClientLog;

            //The command service handles the input the bot receives from text channels
            CommandService = new CommandService(new CommandServiceConfig()
            {
                CaseSensitiveCommands = false
            });
        }