From d99bb7984966949085889293904ed2c715c3b674 Mon Sep 17 00:00:00 2001 From: FlorianDahn Date: Mon, 16 May 2022 14:34:05 +0200 Subject: [PATCH] Shrinking methods to Lambda functions --- TelegramBotBase/Commands/Extensions.cs | 101 ++++++++----------------- 1 file changed, 30 insertions(+), 71 deletions(-) diff --git a/TelegramBotBase/Commands/Extensions.cs b/TelegramBotBase/Commands/Extensions.cs index c98903c..8237d4f 100644 --- a/TelegramBotBase/Commands/Extensions.cs +++ b/TelegramBotBase/Commands/Extensions.cs @@ -9,40 +9,6 @@ namespace TelegramBotBase.Commands { public static class Extensions { - /// - /// Adding the default /start command with a description. - /// - /// - /// - public static void Start(this Dictionary> cmds, String description) - { - Add(cmds, "start", description, null); - } - - /// - /// Adding the default /help command with a description. - /// - /// - /// - - public static void Help(this Dictionary> cmds, String description) - { - Add(cmds, "help", description, null); - } - - /// - /// Adding the default /settings command with a description. - /// - /// - /// - - - public static void Settings(this Dictionary> cmds, String description) - { - Add(cmds, "settings", description, null); - } - - /// /// Adding the command with a description. /// @@ -93,24 +59,38 @@ namespace TelegramBotBase.Commands } } + /// + /// Adding the default /start command with a description. + /// + /// + /// + public static void Start(this Dictionary> cmds, String description) => Add(cmds, "start", description, null); + + /// + /// Adding the default /help command with a description. + /// + /// + /// + public static void Help(this Dictionary> cmds, String description) => Add(cmds, "help", description, null); + + /// + /// Adding the default /settings command with a description. + /// + /// + /// + public static void Settings(this Dictionary> cmds, String description) => Add(cmds, "settings", description, null); + /// /// Clears all default commands. /// /// - public static void ClearDefaultCommands(this Dictionary> cmds) - { - Clear(cmds, null); - } - + public static void ClearDefaultCommands(this Dictionary> cmds) => Clear(cmds, null); /// /// Clears all commands of a specific device. /// /// - public static void ClearChatCommands(this Dictionary> cmds, long DeviceId) - { - Clear(cmds, new BotCommandScopeChat() { ChatId = DeviceId }); - } + public static void ClearChatCommands(this Dictionary> cmds, long DeviceId) => Clear(cmds, new BotCommandScopeChat() { ChatId = DeviceId }); /// /// Adding a chat command with a description. @@ -118,10 +98,7 @@ namespace TelegramBotBase.Commands /// /// /// - public static void AddChatCommand(this Dictionary> cmds, long DeviceId, String command, String description) - { - Add(cmds, command, description, new BotCommandScopeChat() { ChatId = DeviceId }); - } + public static void AddChatCommand(this Dictionary> cmds, long DeviceId, String command, String description) => Add(cmds, command, description, new BotCommandScopeChat() { ChatId = DeviceId }); /// /// Adding a group command with a description. @@ -129,19 +106,13 @@ namespace TelegramBotBase.Commands /// /// /// - public static void AddGroupCommand(this Dictionary> cmds, String command, String description) - { - Add(cmds, command, description, new BotCommandScopeAllGroupChats()); - } + public static void AddGroupCommand(this Dictionary> cmds, String command, String description) => Add(cmds, command, description, new BotCommandScopeAllGroupChats()); /// /// Clears all group commands. /// /// - public static void ClearGroupCommands(this Dictionary> cmds) - { - Clear(cmds, new BotCommandScopeAllGroupChats()); - } + public static void ClearGroupCommands(this Dictionary> cmds) => Clear(cmds, new BotCommandScopeAllGroupChats()); /// /// Adding group admin command with a description. @@ -149,19 +120,13 @@ namespace TelegramBotBase.Commands /// /// /// - public static void AddGroupAdminCommand(this Dictionary> cmds, String command, String description) - { - Add(cmds, command, description, new BotCommandScopeAllChatAdministrators()); - } + public static void AddGroupAdminCommand(this Dictionary> cmds, String command, String description) => Add(cmds, command, description, new BotCommandScopeAllChatAdministrators()); /// /// Clears all group admin commands. /// /// - public static void ClearGroupAdminCommand(this Dictionary> cmds) - { - Clear(cmds, new BotCommandScopeAllChatAdministrators()); - } + public static void ClearGroupAdminCommand(this Dictionary> cmds) => Clear(cmds, new BotCommandScopeAllChatAdministrators()); /// /// Adding a privat command with a description. @@ -169,18 +134,12 @@ namespace TelegramBotBase.Commands /// /// /// - public static void AddPrivateChatCommand(this Dictionary> cmds, String command, String description) - { - Add(cmds, command, description, new BotCommandScopeAllPrivateChats()); - } + public static void AddPrivateChatCommand(this Dictionary> cmds, String command, String description) => Add(cmds, command, description, new BotCommandScopeAllPrivateChats()); /// /// Clears all private commands. /// /// - public static void ClearPrivateChatCommand(this Dictionary> cmds) - { - Clear(cmds, new BotCommandScopeAllPrivateChats()); - } + public static void ClearPrivateChatCommand(this Dictionary> cmds) => Clear(cmds, new BotCommandScopeAllPrivateChats()); } }