Beispiel #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());

            }
        }
        public PushoverMessageClient(MessageClientIdentity identity, MessageClientIdentity serverIdentity, string rabbitMqServerHostName, string userName, string password, string pushoverAppApiKey, string pushoverUserKey, bool autoDeleteQueuesOnClose, bool queuesAreDurable, int heartbeatInterval, params MessageClientIdentity[] clientIdentities) :
            base(identity, serverIdentity, rabbitMqServerHostName, userName, password, autoDeleteQueuesOnClose, queuesAreDurable, heartbeatInterval, clientIdentities)
        {
            if (string.IsNullOrEmpty(pushoverAppApiKey))
            {
                throw new ArgumentException("A Pushover application API key must be supplied", nameof(pushoverAppApiKey));
            }

            if (string.IsNullOrEmpty(pushoverUserKey))
            {
                throw new ArgumentException("A Pushover user key must be supplied", nameof(pushoverUserKey));
            }

            pushoverClient       = new PushoverClient.Pushover(pushoverAppApiKey);
            this.pushoverUserKey = pushoverUserKey;

            this.MessageReceived += PushoverMessageClient_MessageReceived;
        }