Base commit
This commit is contained in:
31
TelegramBot/Program.cs
Normal file
31
TelegramBot/Program.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
|
||||
using var cts = new CancellationTokenSource();
|
||||
var bot = new TelegramBotClient(Environment.GetEnvironmentVariable("TELEGRAM_BOT_TOKEN"), cancellationToken:cts.Token);
|
||||
var me = bot.GetMe();
|
||||
bot.OnMessage += OnMessage;
|
||||
Console.ReadLine();
|
||||
cts.Cancel();
|
||||
|
||||
async Task OnMessage(Message msg, UpdateType type)
|
||||
{
|
||||
//Discard any message that is not a text message
|
||||
if (msg.Type != MessageType.Text) return;
|
||||
//Check if the message contains the bot's username
|
||||
if (msg.Text!.Contains(me.Result.Username!, StringComparison.OrdinalIgnoreCase))
|
||||
await bot.SendMessage(msg.Chat, "You mentioned me!");
|
||||
//Check if the message is a reply to a message sent by the bot
|
||||
else if(msg.ReplyToMessage != null && msg.ReplyToMessage.From!.Id == me.Result.Id){
|
||||
await bot.SendMessage(msg.Chat, "You replied to a message!");
|
||||
}
|
||||
//We can safely return otherwise
|
||||
}
|
||||
|
||||
HttpClient AiClient = new HttpClient();
|
||||
|
||||
string getNemesisMsg() {
|
||||
//AiClient.GetAsync()
|
||||
return "";
|
||||
}
|
||||
Reference in New Issue
Block a user