-
Notifications
You must be signed in to change notification settings - Fork 0
Commands Creating
Назар edited this page Sep 11, 2018
·
5 revisions
public enum TypeOfCommand {
Standart,
Query,
InlineQuery,
AllwaysInWebHook,
Service,
Photo
}
public enum TypeOfAccess{
Public,
Hide,
Admin,
Named
}
This is command that provide you with trigger of simple text message to bot or in chat with bot. Standart command creates with Action<Message, IBot, List> parameter.
As a message message but it contains Image
This is command that calls when bot reacive Query from buttons and etc. Query command creates with Action<CallbackQuery, IBot> parameter.
This command calls when reacive Query from inline buttons and etc. InlineQuery command creates with Action<InlineQuery, IBot> parameter.
This type of command uses allways when any Update entere in WebHook. AllwaysInWebHook command creates with Action<Update, IBot, List> parameter.
This type of command uses for Service Messages from Telegram. Service command creates with Action<Update, IBot> parameter.
- Common Synk Command
- Query Synk Command for Inline Messages
- Query Synk Command for Buttons
- Allways in WebHook
- Service Synk Command U can see it in SynkCommand.cs
public SynkCommand(
Action<Telegram.Bot.Types.Message, IBot, List<ArgC>> act, //Action of command
List<string> cm, //Command names, that will be /command, but u can write just "command"
TypeOfAccess access = TypeOfAccess.Public, //Acces to command
string commandName = null, //String name of command for alternative input
string descr = null, //Description of command
bool clearcommand = true) //Clear command after input or nope
Bot.SynkCommands.Add(new SynkCommand(new WebmModule().WebmFuncForBot, new List<string>()
{
"/sendrandwebm"
}, commandName:"картика", descr:"Webm с личной колекции."));
Or
Bot.SynkCommands.Add(Bot.GetModule<FunFunc>()._ChtoEto);
Bot.SynkCommands.Add(new SynkCommand((Telegram.Bot.Types.Message ms, IBot parent, List<ArgC> args)=> {
parent.Client.SendTextMessageAsync(ms.Chat.Id,"Слушаюсь, уже сплю...");
Bot.GetModule<SaveLoadModule>().saveIt();
Bot.Dispose();
Application.Exit();
}, new List<string>()
{
"_"
},commandName:"спать", access:TypeOfAccess.Named, descr: "Бот ложиться спать."));
public class Help : SynkCommand
{
public BotBase Parent { get; set; }
public Help(BotBase bot) : base(Act, new List<string>() { "/help" },descr:"List of commands.") { Parent = bot; }
public static void Act(Message re, IBot Parent, List<ArgC> args)
{
Parent.Client.SendTextMessageAsync(re.Chat.Id,$"This bot[{Parent.Name}] was created with pes7's Bot Creator.");
string coms = "";
foreach(SynkCommand sn in Parent.SynkCommands.Where(fn=>fn.Type==TypeOfCommand.Standart && fn.CommandLine.First() != "Default"))
{
if(sn.Description != null)
coms += $"\n{sn.CommandLine.First()} - {sn.Description}";
else
coms += $"\n{sn.CommandLine.First()}";
}
Parent.Client.SendTextMessageAsync(re.Chat.Id, $"Commands: {coms}");
}
}