public void Addmessage(tgMessage msg)
 {
     if (!chats.Contains(new tgChat(msg.ChatId)))
     {
         chats.Add(new tgChat(msg.ChatId, msg.From));
     }
     chats[chats.IndexOf(new tgChat(msg.ChatId))].messages.Add(msg);
 }
Example #2
0
        private async void AnswerStickerAsync(Message message)
        {
            Message answer = await tgbotClient.SendStickerAsync(message.Chat.Id, message.Sticker.FileId);

            tgMessage tgMessage = await tgMessagefromMessageAsync(answer);

            w.Dispatcher.Invoke(() =>
            {
                newMessage?.Invoke(tgMessage);
            });
        }
Example #3
0
        private async void AnswerTextAsync(Chat chat, string text)
        {
            Message answer = await tgbotClient.SendTextMessageAsync(chat.Id, text);

            tgMessage tgMessage = await tgMessagefromMessageAsync(answer);

            w.Dispatcher.Invoke(() =>
            {
                newMessage?.Invoke(tgMessage);
            });
        }
Example #4
0
        private async void MessageListenerAsync(object sender, Telegram.Bot.Args.MessageEventArgs e)
        {
            tgMessage tgMessage = await tgMessagefromMessageAsync(e.Message);

            w.Dispatcher.Invoke(() =>
            {
                newMessage?.Invoke(tgMessage);
            });
            switch (e.Message.Type)
            {
            case Telegram.Bot.Types.Enums.MessageType.Text: getTextMeesageAsync(e.Message); break;

            case Telegram.Bot.Types.Enums.MessageType.Sticker: AnswerStickerAsync(e.Message);  break;

            //case Telegram.Bot.Types.Enums.MessageType.Text: break;
            default: break;
            }
        }