コード例 #1
0
 public async Task SendTypingAsync(BotChat chat)
 {
     if (!IsConnected)
     {
         return;
     }
     Core.Log.LibVerbose("Sending typing notification. ChatId = {0}", chat?.Id);
     await Transport.SendTypingAsync(chat).ConfigureAwait(false);
 }
コード例 #2
0
 public async Task SendPhotoMessageAsync(BotChat chat, Stream fileStream, string caption = null)
 {
     if (!IsConnected)
     {
         return;
     }
     Core.Log.LibVerbose("Sending photo message. ChatId = {0}, Caption = {1}", chat?.Id, caption);
     await Transport.SendPhotoMessageAsync(chat, fileStream, caption).ConfigureAwait(false);
 }
コード例 #3
0
        public async Task SendTextMessageAsync(BotChat chat, string message, MessageParseMode parseMode = MessageParseMode.Default)
        {
            if (!IsConnected)
            {
                return;
            }
            Core.Log.LibVerbose("Sending text message. ChatId = {0}, Message = {1}", chat?.Id, message);
            await Transport.SendTextMessageAsync(chat, message, parseMode).ConfigureAwait(false);

            Core.Log.LibVerbose("Message sent.");
        }
コード例 #4
0
        public async Task SendPhotoMessageAsync(BotChat chat, string fileName, string caption = null)
        {
            if (!IsConnected)
            {
                return;
            }
            Core.Log.LibVerbose("Sending photo message. ChatId = {0}, FileName = {1}, Caption = {2}", chat?.Id, fileName, caption);
            await Transport.SendPhotoMessageAsync(chat, fileName, caption).ConfigureAwait(false);

            _counterMessagesSent.Increment();
        }
コード例 #5
0
 public bool UnTrackChat(BotChat chat)
 {
     if (chat == null)
     {
         return(false);
     }
     lock (TrackedChats)
     {
         if (!TrackedChats.Contains(chat.Id))
         {
             return(false);
         }
         TrackedChats.Remove(chat.Id);
         Core.Log.LibVerbose("Chat UnTracked");
         OnTrackedChatsChanged?.Invoke(this, EventArgs.Empty);
         return(true);
     }
 }
コード例 #6
0
 public bool TrackChat(BotChat chat)
 {
     if (chat is null)
     {
         return(false);
     }
     lock (TrackedChats)
     {
         if (TrackedChats.Contains(chat.Id))
         {
             return(false);
         }
         TrackedChats.Add(chat);
         Core.Log.LibVerbose("Chat Tracked");
         _counterTrackedChat.Increment();
         OnTrackedChatsChanged?.Invoke(this, EventArgs.Empty);
         return(true);
     }
 }
コード例 #7
0
 public bool IsChatTracked(BotChat chat)
 {
     lock (TrackedChats)
         return(chat != null && TrackedChats.Contains(chat.Id));
 }