-
Notifications
You must be signed in to change notification settings - Fork 2
OnForward handler
Arius Bronte edited this page Feb 23, 2020
·
3 revisions
Trigerred at the word "ping" and replies with the word "pong".
commands.OnForward("^ping$", "pong");
Trigerred at the word "ping" and sends randomly from the array word.
commands.OnForward("^ping$", new[] {"pong1", "pong2", "pong3"});
*applies to all triggers.
Triggered on all incoming messages or if no command is found. Is not required.
commands.OnForward("command not found");
// or
commands.OnForward("forward command not found", "what?", "use help command!");
You can set regex options.
commands.OnForward(("^pInG$", RegexOptions.IgnoreCase), "pong");
You can configure the logic for a specific conversation.
commands.OnForward((2_000_000_000 + 1, "^ping$"), "pong for 1");
commands.OnForward((2_000_000_000 + 2, "^ping$"), "pong for 2");
commands.OnForward((2_000_000_000 + 3, "^pong$"), "ping");
You can combine all options.
commands.OnForward((2_000_000_000 + 1, "^ping$", RegexOptions.IgnoreCase), "pong");
You can set your own trigger processing logic.
commands.OnForward("^ping$", async (api, message, token) =>
{
await api.Messages.SendAsync(new MessagesSendParams
{
PeerId = message.Message.PeerId.Value,
Message = "pong",
RandomId = random.Next(int.MinValue, int.MaxValue)
});
});
*applies to all triggers.