Skip to content

Instantly share code, notes, and snippets.

@donma
Created March 12, 2025 06:53
Show Gist options
  • Save donma/8be3bd7961aaa099f8ec164228b00c8f to your computer and use it in GitHub Desktop.
Save donma/8be3bd7961aaa099f8ec164228b00c8f to your computer and use it in GitHub Desktop.
private static Task _TelegramBotClient_OnMessage(Telegram.Bot.Types.Message message, Telegram.Bot.Types.Enums.UpdateType type)
{
if (message.Text==null)
{
return Task.FromResult<object>(null);
}
if (message.Text.ToLower().StartsWith("/"))
{
if (message.Text.ToLower().StartsWith("/公告:"))
{
var messageId = _TelegramBotClient.SendMessage(message.Chat, message.Text.Replace("/公告:", "")).Result.Id;
_TelegramBotClient.PinChatMessage(message.Chat, messageId);
}
else {
Stream stream = File.OpenRead(AppDomain.CurrentDomain.BaseDirectory + "oooo.jpg");
var res = _TelegramBotClient.SendPhoto(message.Chat, Telegram.Bot.Types.InputFile.FromStream(stream));
}
//command handing.
}
else
{
Console.WriteLine($"純文字:" + message.Text);
_TelegramBotClient.SendMessage(message.Chat, $"Echo: Your Text is {message.Text}", replyMarkup: new ReplyKeyboardRemove());
}
return Task.FromResult<object>(null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment