-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBotManager.Text.cs
More file actions
53 lines (51 loc) · 1.96 KB
/
BotManager.Text.cs
File metadata and controls
53 lines (51 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using Telegram.Bot;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups;
namespace BotProject
{
internal partial class BotManager
{
public async Task MessageTextAsync(ITelegramBotClient botClient, Update update, CancellationToken cancellationToken)
{
string message = update.Message.Text;
if(message == "/start")
{
await OnSendStartMessageAsync(botClient, update, cancellationToken);
}
else if(update.Message.Type is MessageType.Text)
{
await RegisterUserAsync(botClient, update, cancellationToken);
}
}
public async Task OnSendStartMessageAsync(ITelegramBotClient botClient, Update update, CancellationToken cancellationToken)
{
if(WorkingWithFile.ReadFromFile().Result.Find(user => user.Id == update.Message.MessageId) is null)
{
string message = "Ro'yxatdan o'tish uchun Leetcode usernameni kiriting";
botClient.SendTextMessageAsync(
chatId: update.Message.Chat.Id,
text: message,
cancellationToken: cancellationToken);
}
else
{
string sendMessage = "1";
ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup(
new KeyboardButton[][]
{
new KeyboardButton[]
{
"Leetcodega o'tish",
"Natijalar"
}
});
Message returnMessage = await botClient.SendTextMessageAsync(
chatId: update.Message.Chat.Id,
replyMarkup: replyKeyboardMarkup,
cancellationToken: cancellationToken,
text: sendMessage);
}
}
}
}