示例#1
0
        public async Task <bool> SendMessageEventAnswerAsync(EventId eventId, long userId, long peerId, EventData eventData)
        {
            try
            {
                string _eventId;
                lock (eventId)
                {
                    if (string.IsNullOrEmpty(eventId))
                    {
                        return(false);
                    }

                    _eventId = eventId;
                    eventId.Clear();
                }

                return(await VkApi.Messages.SendMessageEventAnswerAsync(_eventId, userId, peerId, eventData));
            }
            catch (ConversationAccessDeniedException e)
            {
                if (!BaseChat.IsUserConversation(peerId))
                {
                    VkApi.GetChat <Chat>(peerId).OnKick(null);
                    return(false);
                }
                throw e;
            }
        }
示例#2
0
 public async Task SendMessageAsync(MessagesSendParams message)
 {
     try
     {
         await VkApi.Messages.SendAsync(message);
     }
     catch (Exception e)
     {
         long peerId = message.PeerId.Value;
         if (!BaseChat.IsUserConversation(peerId))
         {
             VkApi.GetChat <Chat>(peerId).OnKick(null);
         }
         throw e;
     }
 }
示例#3
0
 public void SendMessage(MessagesSendParams message)
 {
     try
     {
         VkApi.Messages.Send(message);
     }
     catch (ConversationAccessDeniedException e)
     {
         long peerId = message.PeerId.Value;
         if (!BaseChat.IsUserConversation(peerId))
         {
             VkApi.GetChat <Chat>(peerId).OnKick(null);
             return;
         }
         throw e;
     }
 }
示例#4
0
 public async Task <bool> EditAsync(long peerId, long messageId, string message, Keyboard keyboard = null)
 {
     try
     {
         return(await VkApi.Messages.EditAsync(new MessageEditParams()
         {
             PeerId = peerId,
             ConversationMessageId = messageId,
             Message = message,
             Keyboard = keyboard.GetKeyboard(VkApi.GroupId)
         }));
     }
     catch (ConversationAccessDeniedException e)
     {
         if (!BaseChat.IsUserConversation(peerId))
         {
             VkApi.GetChat <Chat>(peerId).OnKick(null);
             return(false);
         }
         throw e;
     }
 }