mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Implemented .net 10 support. Updated all affected libraries and the code. Not testes yet.
This commit is contained in:
parent
5488140261
commit
28834e7a86
10 changed files with 107 additions and 94 deletions
|
|
@ -284,7 +284,7 @@ namespace MinecraftClient.ChatBots
|
|||
if (text != null)
|
||||
messageBuilder.WithContent(text);
|
||||
|
||||
messageBuilder.WithFiles(new Dictionary<string, Stream>() { { $"attachment://{filePath}", fs } });
|
||||
messageBuilder.AddFiles(new Dictionary<string, Stream>() { { filePath, fs } });
|
||||
|
||||
discordBotClient!.SendMessageAsync(discordChannel, messageBuilder).Wait(Config.Message_Send_Timeout * 1000);
|
||||
}
|
||||
|
|
@ -301,7 +301,7 @@ namespace MinecraftClient.ChatBots
|
|||
if (!CanSendMessages())
|
||||
return;
|
||||
|
||||
SendMessage(new DiscordMessageBuilder().WithFile(fileStream));
|
||||
SendMessage(new DiscordMessageBuilder().AddFile(fileStream));
|
||||
}
|
||||
|
||||
private bool CanSendMessages()
|
||||
|
|
|
|||
|
|
@ -259,7 +259,8 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
using (var image = new MagickImage(fileName))
|
||||
{
|
||||
var size = new MagickGeometry(Config.Resize_To, Config.Resize_To);
|
||||
uint resizeTo = (uint)Math.Max(Config.Resize_To, 1);
|
||||
var size = new MagickGeometry(resizeTo, resizeTo);
|
||||
size.IgnoreAspectRatio = true;
|
||||
|
||||
image.Resize(size);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ using Telegram.Bot.Exceptions;
|
|||
using Telegram.Bot.Polling;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
using Telegram.Bot.Types.InputFiles;
|
||||
using Tomlet.Attributes;
|
||||
using File = System.IO.File;
|
||||
|
||||
|
|
@ -205,7 +204,7 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
try
|
||||
{
|
||||
botClient!.SendTextMessageAsync(Config.ChannelId.Trim(), message, ParseMode.Markdown).Wait(Config.Message_Send_Timeout);
|
||||
botClient!.SendMessage(Config.ChannelId.Trim(), message, parseMode: ParseMode.Markdown).Wait(Config.Message_Send_Timeout);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -224,9 +223,9 @@ namespace MinecraftClient.ChatBots
|
|||
string fileName = filePath[(filePath.IndexOf(Path.DirectorySeparatorChar) + 1)..];
|
||||
|
||||
Stream stream = File.OpenRead(filePath);
|
||||
botClient!.SendDocumentAsync(
|
||||
botClient!.SendDocument(
|
||||
Config.ChannelId.Trim(),
|
||||
document: new InputOnlineFile(content: stream, fileName),
|
||||
document: InputFile.FromStream(stream, fileName),
|
||||
caption: text,
|
||||
parseMode: ParseMode.Markdown).Wait(Config.Message_Send_Timeout * 1000);
|
||||
}
|
||||
|
|
@ -260,14 +259,14 @@ namespace MinecraftClient.ChatBots
|
|||
cancellationToken = new CancellationTokenSource();
|
||||
|
||||
botClient.StartReceiving(
|
||||
updateHandler: HandleUpdateAsync,
|
||||
pollingErrorHandler: HandlePollingErrorAsync,
|
||||
receiverOptions: new ReceiverOptions
|
||||
HandleUpdateAsync,
|
||||
HandlePollingErrorAsync,
|
||||
new ReceiverOptions
|
||||
{
|
||||
// receive all update types
|
||||
AllowedUpdates = Array.Empty<UpdateType>()
|
||||
},
|
||||
cancellationToken: cancellationToken.Token
|
||||
cancellationToken.Token
|
||||
);
|
||||
|
||||
IsConnected = true;
|
||||
|
|
@ -313,9 +312,9 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
if (text.ToLower().Contains(".chatid"))
|
||||
{
|
||||
await botClient.SendTextMessageAsync(chatId: chatId,
|
||||
replyToMessageId: message.MessageId,
|
||||
await botClient.SendMessage(chatId: chatId,
|
||||
text: $"Chat ID: {chatId}",
|
||||
replyParameters: message.MessageId,
|
||||
cancellationToken: _cancellationToken,
|
||||
parseMode: ParseMode.Markdown);
|
||||
return;
|
||||
|
|
@ -324,10 +323,10 @@ namespace MinecraftClient.ChatBots
|
|||
if (Config.Authorized_Chat_Ids.Length > 0 && !Config.Authorized_Chat_Ids.Contains(chatId))
|
||||
{
|
||||
LogDebugToConsole($"Unauthorized message '{messageText}' received in a chat with with an ID: {chatId} !");
|
||||
await botClient.SendTextMessageAsync(
|
||||
await botClient.SendMessage(
|
||||
chatId: chatId,
|
||||
replyToMessageId: message.MessageId,
|
||||
text: Translations.bot_TelegramBridge_unauthorized,
|
||||
replyParameters: message.MessageId,
|
||||
cancellationToken: _cancellationToken,
|
||||
parseMode: ParseMode.Markdown);
|
||||
return;
|
||||
|
|
@ -347,10 +346,10 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
if (command.ToLower().Contains("quit") || command.ToLower().Contains("exit"))
|
||||
{
|
||||
await botClient.SendTextMessageAsync(
|
||||
await botClient.SendMessage(
|
||||
chatId: chatId,
|
||||
replyToMessageId: message.MessageId,
|
||||
text: $"{Translations.bot_TelegramBridge_quit_disabled}",
|
||||
replyParameters: message.MessageId,
|
||||
cancellationToken: _cancellationToken,
|
||||
parseMode: ParseMode.Markdown);
|
||||
return;;
|
||||
|
|
@ -359,11 +358,10 @@ namespace MinecraftClient.ChatBots
|
|||
CmdResult result = new();
|
||||
PerformInternalCommand(command, ref result);
|
||||
|
||||
await botClient.SendTextMessageAsync(
|
||||
await botClient.SendMessage(
|
||||
chatId: chatId,
|
||||
replyToMessageId:
|
||||
message.MessageId,
|
||||
text: $"{Translations.bot_TelegramBridge_command_executed}:\n\n{result}",
|
||||
replyParameters: message.MessageId,
|
||||
cancellationToken: _cancellationToken,
|
||||
parseMode: ParseMode.Markdown);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue