Exemplo n.º 1
0
        private static void SendMessage(string message, long?userID, VkNet.Model.Keyboard.MessageKeyboard keyboard, string payload)
        {
            try
            {
                api.Authorize(new ApiAuthParams()
                {
                    AccessToken = groupToken
                });
                Random rnd = new Random();

                //One of the parameters specified was missing or invalid: you should specify peer_id, user_id, domain, chat_id or user_ids param
                api.Messages.Send(new MessagesSendParams
                {
                    RandomId = rnd.Next(),
                    UserId   = userID,
                    Message  = message,

                    Payload  = payload,
                    Keyboard = keyboard,
                });
            }
            catch (Exception ex)
            {
                ErrorLogging(ex);
                ReadError();
            }
        }
Exemplo n.º 2
0
        //После успешной отправки возвращает true
        private static bool SendMessage(string message, long?userID, VkNet.Model.Keyboard.MessageKeyboard keyboard, string payload)
        {
            bool isSended;

            try
            {
                api.Authorize(new ApiAuthParams()
                {
                    AccessToken = LPListener.groupToken
                });
                Random rnd = new Random();

                //One of the parameters specified was missing or invalid: you should specify peer_id, user_id, domain, chat_id or user_ids param
                api.Messages.Send(new MessagesSendParams
                {
                    RandomId = rnd.Next(),
                    UserId   = userID,
                    Message  = message,

                    Payload = payload,
                });
                isSended = true;
            }
            catch (Exception ex)
            {
                LPListener.ErrorLogging(ex);
                LPListener.ReadError();
                isSended = false;
            }
            return(isSended);
        }