Shrinking methods to Lambda functions
This commit is contained in:
parent
3386db0f66
commit
d99bb79849
@ -9,40 +9,6 @@ namespace TelegramBotBase.Commands
|
|||||||
{
|
{
|
||||||
public static class Extensions
|
public static class Extensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Adding the default /start command with a description.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="cmds"></param>
|
|
||||||
/// <param name="description"></param>
|
|
||||||
public static void Start(this Dictionary<BotCommandScope, List<BotCommand>> cmds, String description)
|
|
||||||
{
|
|
||||||
Add(cmds, "start", description, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adding the default /help command with a description.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="cmds"></param>
|
|
||||||
/// <param name="description"></param>
|
|
||||||
|
|
||||||
public static void Help(this Dictionary<BotCommandScope, List<BotCommand>> cmds, String description)
|
|
||||||
{
|
|
||||||
Add(cmds, "help", description, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adding the default /settings command with a description.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="cmds"></param>
|
|
||||||
/// <param name="description"></param>
|
|
||||||
|
|
||||||
|
|
||||||
public static void Settings(this Dictionary<BotCommandScope, List<BotCommand>> cmds, String description)
|
|
||||||
{
|
|
||||||
Add(cmds, "settings", description, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adding the command with a description.
|
/// Adding the command with a description.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -93,24 +59,38 @@ namespace TelegramBotBase.Commands
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adding the default /start command with a description.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cmds"></param>
|
||||||
|
/// <param name="description"></param>
|
||||||
|
public static void Start(this Dictionary<BotCommandScope, List<BotCommand>> cmds, String description) => Add(cmds, "start", description, null);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adding the default /help command with a description.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cmds"></param>
|
||||||
|
/// <param name="description"></param>
|
||||||
|
public static void Help(this Dictionary<BotCommandScope, List<BotCommand>> cmds, String description) => Add(cmds, "help", description, null);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adding the default /settings command with a description.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cmds"></param>
|
||||||
|
/// <param name="description"></param>
|
||||||
|
public static void Settings(this Dictionary<BotCommandScope, List<BotCommand>> cmds, String description) => Add(cmds, "settings", description, null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clears all default commands.
|
/// Clears all default commands.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cmds"></param>
|
/// <param name="cmds"></param>
|
||||||
public static void ClearDefaultCommands(this Dictionary<BotCommandScope, List<BotCommand>> cmds)
|
public static void ClearDefaultCommands(this Dictionary<BotCommandScope, List<BotCommand>> cmds) => Clear(cmds, null);
|
||||||
{
|
|
||||||
Clear(cmds, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clears all commands of a specific device.
|
/// Clears all commands of a specific device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cmds"></param>
|
/// <param name="cmds"></param>
|
||||||
public static void ClearChatCommands(this Dictionary<BotCommandScope, List<BotCommand>> cmds, long DeviceId)
|
public static void ClearChatCommands(this Dictionary<BotCommandScope, List<BotCommand>> cmds, long DeviceId) => Clear(cmds, new BotCommandScopeChat() { ChatId = DeviceId });
|
||||||
{
|
|
||||||
Clear(cmds, new BotCommandScopeChat() { ChatId = DeviceId });
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adding a chat command with a description.
|
/// Adding a chat command with a description.
|
||||||
@ -118,10 +98,7 @@ namespace TelegramBotBase.Commands
|
|||||||
/// <param name="cmds"></param>
|
/// <param name="cmds"></param>
|
||||||
/// <param name="command"></param>
|
/// <param name="command"></param>
|
||||||
/// <param name="description"></param>
|
/// <param name="description"></param>
|
||||||
public static void AddChatCommand(this Dictionary<BotCommandScope, List<BotCommand>> cmds, long DeviceId, String command, String description)
|
public static void AddChatCommand(this Dictionary<BotCommandScope, List<BotCommand>> cmds, long DeviceId, String command, String description) => Add(cmds, command, description, new BotCommandScopeChat() { ChatId = DeviceId });
|
||||||
{
|
|
||||||
Add(cmds, command, description, new BotCommandScopeChat() { ChatId = DeviceId });
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adding a group command with a description.
|
/// Adding a group command with a description.
|
||||||
@ -129,19 +106,13 @@ namespace TelegramBotBase.Commands
|
|||||||
/// <param name="cmds"></param>
|
/// <param name="cmds"></param>
|
||||||
/// <param name="command"></param>
|
/// <param name="command"></param>
|
||||||
/// <param name="description"></param>
|
/// <param name="description"></param>
|
||||||
public static void AddGroupCommand(this Dictionary<BotCommandScope, List<BotCommand>> cmds, String command, String description)
|
public static void AddGroupCommand(this Dictionary<BotCommandScope, List<BotCommand>> cmds, String command, String description) => Add(cmds, command, description, new BotCommandScopeAllGroupChats());
|
||||||
{
|
|
||||||
Add(cmds, command, description, new BotCommandScopeAllGroupChats());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clears all group commands.
|
/// Clears all group commands.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cmds"></param>
|
/// <param name="cmds"></param>
|
||||||
public static void ClearGroupCommands(this Dictionary<BotCommandScope, List<BotCommand>> cmds)
|
public static void ClearGroupCommands(this Dictionary<BotCommandScope, List<BotCommand>> cmds) => Clear(cmds, new BotCommandScopeAllGroupChats());
|
||||||
{
|
|
||||||
Clear(cmds, new BotCommandScopeAllGroupChats());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adding group admin command with a description.
|
/// Adding group admin command with a description.
|
||||||
@ -149,19 +120,13 @@ namespace TelegramBotBase.Commands
|
|||||||
/// <param name="cmds"></param>
|
/// <param name="cmds"></param>
|
||||||
/// <param name="command"></param>
|
/// <param name="command"></param>
|
||||||
/// <param name="description"></param>
|
/// <param name="description"></param>
|
||||||
public static void AddGroupAdminCommand(this Dictionary<BotCommandScope, List<BotCommand>> cmds, String command, String description)
|
public static void AddGroupAdminCommand(this Dictionary<BotCommandScope, List<BotCommand>> cmds, String command, String description) => Add(cmds, command, description, new BotCommandScopeAllChatAdministrators());
|
||||||
{
|
|
||||||
Add(cmds, command, description, new BotCommandScopeAllChatAdministrators());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clears all group admin commands.
|
/// Clears all group admin commands.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cmds"></param>
|
/// <param name="cmds"></param>
|
||||||
public static void ClearGroupAdminCommand(this Dictionary<BotCommandScope, List<BotCommand>> cmds)
|
public static void ClearGroupAdminCommand(this Dictionary<BotCommandScope, List<BotCommand>> cmds) => Clear(cmds, new BotCommandScopeAllChatAdministrators());
|
||||||
{
|
|
||||||
Clear(cmds, new BotCommandScopeAllChatAdministrators());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adding a privat command with a description.
|
/// Adding a privat command with a description.
|
||||||
@ -169,18 +134,12 @@ namespace TelegramBotBase.Commands
|
|||||||
/// <param name="cmds"></param>
|
/// <param name="cmds"></param>
|
||||||
/// <param name="command"></param>
|
/// <param name="command"></param>
|
||||||
/// <param name="description"></param>
|
/// <param name="description"></param>
|
||||||
public static void AddPrivateChatCommand(this Dictionary<BotCommandScope, List<BotCommand>> cmds, String command, String description)
|
public static void AddPrivateChatCommand(this Dictionary<BotCommandScope, List<BotCommand>> cmds, String command, String description) => Add(cmds, command, description, new BotCommandScopeAllPrivateChats());
|
||||||
{
|
|
||||||
Add(cmds, command, description, new BotCommandScopeAllPrivateChats());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clears all private commands.
|
/// Clears all private commands.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cmds"></param>
|
/// <param name="cmds"></param>
|
||||||
public static void ClearPrivateChatCommand(this Dictionary<BotCommandScope, List<BotCommand>> cmds)
|
public static void ClearPrivateChatCommand(this Dictionary<BotCommandScope, List<BotCommand>> cmds) => Clear(cmds, new BotCommandScopeAllPrivateChats());
|
||||||
{
|
|
||||||
Clear(cmds, new BotCommandScopeAllPrivateChats());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user