- Updated system call management
- parameters are now easier available - example project added parameter example
This commit is contained in:
@@ -61,6 +61,46 @@ namespace TelegramBotBase.Base
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is this a system call ? Starts with a slash and command
|
||||
/// </summary>
|
||||
public bool IsSystemCall
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.MessageText.StartsWith("/"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a List of all parameters which has been sent with the command itself (i.e. /start 123 456 789 => 123,456,789)
|
||||
/// </summary>
|
||||
public List<String> SystemCallParameters
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsSystemCall)
|
||||
return new List<string>();
|
||||
|
||||
//Split by empty space and skip first entry (command itself), return as list
|
||||
return this.MessageText.Split(' ').Skip(1).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns just the System call command (i.e. /start 1 2 3 => /start)
|
||||
/// </summary>
|
||||
public String SystemCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsSystemCall)
|
||||
return null;
|
||||
|
||||
return this.MessageText.Split(' ')[0];
|
||||
}
|
||||
}
|
||||
|
||||
public bool Handled { get; set; } = false;
|
||||
|
||||
public String RawData
|
||||
|
||||
@@ -14,9 +14,13 @@ namespace TelegramBotBase.Base
|
||||
{
|
||||
public String Command { get; set; }
|
||||
|
||||
public List<String> Parameters { get; set; }
|
||||
|
||||
public long DeviceId { get; set; }
|
||||
|
||||
public DeviceSession Device {get;set;}
|
||||
public DeviceSession Device { get; set; }
|
||||
|
||||
public bool Handled { get; set; } = false;
|
||||
|
||||
|
||||
public SystemCallEventArgs()
|
||||
@@ -25,9 +29,10 @@ namespace TelegramBotBase.Base
|
||||
|
||||
}
|
||||
|
||||
public SystemCallEventArgs(String Command, long DeviceId, DeviceSession Device)
|
||||
public SystemCallEventArgs(String Command, List<String> Parameters, long DeviceId, DeviceSession Device)
|
||||
{
|
||||
this.Command = Command;
|
||||
this.Parameters = Parameters;
|
||||
this.DeviceId = DeviceId;
|
||||
this.Device = Device;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user