Skip to content

Commit

Permalink
Fix JS syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
ronnygunawan committed Oct 31, 2023
1 parent a7f43ba commit dcd74c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions BotNet.Services/BotCommands/Exec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace BotNet.Services.BotCommands {
public static class Exec {
private static DateTimeOffset _skipPestoUntil = DateTimeOffset.Now;

public static async Task ExecAsync(ITelegramBotClient botClient, IServiceProvider serviceProvider, Message message, string language, CancellationToken cancellationToken) {
public static async Task ExecAsync(ITelegramBotClient botClient, IServiceProvider serviceProvider, Message message, string language, string highlightLanguage, CancellationToken cancellationToken) {
if (message.Entities?.FirstOrDefault() is { Type: MessageEntityType.BotCommand, Offset: 0, Length: int commandLength }
&& message.Text![commandLength..].Trim() is string commandArgument) {
if (commandArgument.Length > 0) {
Expand Down Expand Up @@ -48,7 +48,7 @@ await botClient.SendTextMessageAsync(
} else {
await botClient.SendTextMessageAsync(
chatId: message.Chat.Id,
text: $"Code:\n```{language}\n{MarkdownV2Sanitizer.Sanitize(commandArgument)}\n```\n\nOutput:\n```\n{MarkdownV2Sanitizer.Sanitize(result.Run.Output)}\n```",
text: $"Code:\n```{highlightLanguage}\n{MarkdownV2Sanitizer.Sanitize(commandArgument)}\n```\nOutput:\n```\n{MarkdownV2Sanitizer.Sanitize(result.Run.Output)}\n```",
parseMode: ParseMode.MarkdownV2,
replyToMessageId: message.MessageId,
cancellationToken: cancellationToken);
Expand Down Expand Up @@ -99,7 +99,7 @@ await botClient.SendTextMessageAsync(
} else {
await botClient.SendTextMessageAsync(
chatId: message.Chat.Id,
text: $"Code:\n```{language}\n{MarkdownV2Sanitizer.Sanitize(repliedToMessage)}\n```\n\nOutput:\n```\n{MarkdownV2Sanitizer.Sanitize(result.Run.Output)}\n```",
text: $"Code:\n```{highlightLanguage}\n{MarkdownV2Sanitizer.Sanitize(repliedToMessage)}\n```\nOutput:\n```\n{MarkdownV2Sanitizer.Sanitize(result.Run.Output)}\n```",
parseMode: ParseMode.MarkdownV2,
replyToMessageId: message.ReplyToMessage.MessageId,
cancellationToken: cancellationToken);
Expand Down
18 changes: 9 additions & 9 deletions BotNet/Bot/UpdateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,31 +211,31 @@ await _clusterClient.GetGrain<ITrackedMessageGrain>(sentMessage.MessageId).Track
case "/scala":
case "/swift":
case "/julia":
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, command.ToLowerInvariant()[1..], cancellationToken);
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, command.ToLowerInvariant()[1..], command.ToLowerInvariant()[1..], cancellationToken);
break;
case "/sqlite3":
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, "SQLite3", cancellationToken);
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, "SQLite3", "sqlite3", cancellationToken);
break;
case "/commonlisp":
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, "CommonLisp", cancellationToken);
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, "CommonLisp", "cl", cancellationToken);
break;
case "/cpp":
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, "C++", cancellationToken);
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, "C++", "cpp", cancellationToken);
break;
case "/cs":
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, "csharp.net", cancellationToken);
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, "csharp.net", "csharp", cancellationToken);
break;
case "/fs":
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, "fsharp.net", cancellationToken);
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, "fsharp.net", "fsharp", cancellationToken);
break;
case "/js":
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, "JavaScript", cancellationToken);
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, "JavaScript", "js", cancellationToken);
break;
case "/ts":
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, "TypeScript", cancellationToken);
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, "TypeScript", "ts", cancellationToken);
break;
case "/vb":
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, "basic.net", cancellationToken);
await Exec.ExecAsync(botClient, _serviceProvider, update.Message, "basic.net", "vbnet", cancellationToken);
break;
case "/pop":
await botClient.SendTextMessageAsync(
Expand Down

0 comments on commit dcd74c8

Please sign in to comment.