Introducing BotGroupCommand property.

This commit is contained in:
Florian Zevedei 2024-05-27 21:39:36 +02:00
parent 7a86ecdf32
commit 801c0b77f8

View File

@ -62,6 +62,11 @@ public class MessageResult : ResultBase
/// </summary> /// </summary>
public bool IsBotCommand => MessageText.StartsWith("/"); public bool IsBotCommand => MessageText.StartsWith("/");
/// <summary>
/// Is this a bot command sent from a group via @BotId ?
/// </summary>
public bool IsBotGroupCommand => IsBotCommand && MessageText.Contains("@");
/// <summary> /// <summary>
/// Returns a List of all parameters which has been sent with the command itself (i.e. /start 123 456 789 => /// Returns a List of all parameters which has been sent with the command itself (i.e. /start 123 456 789 =>
/// 123,456,789) /// 123,456,789)
@ -87,12 +92,17 @@ public class MessageResult : ResultBase
{ {
get get
{ {
if (!IsBotCommand) if (IsBotGroupCommand)
{ {
return null; return MessageText.Substring(0, MessageText.LastIndexOf('@')).Split(' ')[0];
} }
return MessageText.Split(' ')[0]; if (IsBotCommand)
{
return MessageText.Split(' ')[0];
}
return null;
} }
} }