Exemple #1
0
        static void Main(string[] args)
        {
            //  Get the settings defaults
            string appKey = ConfigurationManager.AppSettings["appKey"];
            string userGroupKey = ConfigurationManager.AppSettings["userGroupKey"];

            //  Get the command line options
            Options options = new Options();
            if(CommandLine.Parser.Default.ParseArguments(args, options))
            {
                //  If we didn't get the app key passed in, use the default:
                if(string.IsNullOrEmpty(options.From))
                {
                    options.From = appKey;
                }

                //  If we didn't get the user key passed in, use the default:
                if(string.IsNullOrEmpty(options.User))
                {
                    options.User = userGroupKey;
                }

                //  Make sure we have our required items:
                if(OptionsValid(options))
                {
                    //  Send the message
                    Pushover pclient = new Pushover(options.From);
                    PushResponse response = pclient.Push(options.Title, options.Message, options.User);
                }
                else
                    Console.WriteLine(options.GetUsage());

            }
        }
        private void PushoverMessageClient_MessageReceived(object sender, MessageQueues.MessageReceivedEventArgs e)
        {
            List <Func <MessageBase, string> > funcs;

            if (transforms.TryGetValue(e.MessageEnevelope.Message.GetType(), out funcs))
            {
                foreach (var func in funcs)
                {
                    string result = func(e.MessageEnevelope.Message);

                    if (!string.IsNullOrEmpty(result))
                    {
                        pushoverClient.Push("", result, pushoverUserKey);
                    }
                }
            }

            e.Response = MessageQueues.MessageResponse.Ack;
        }