Created
March 12, 2025 06:53
-
-
Save donma/8be3bd7961aaa099f8ec164228b00c8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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