-
Notifications
You must be signed in to change notification settings - Fork 2
OnText handler
Arius Bronte edited this page Feb 23, 2020
·
3 revisions
Trigerred at the word "ping" and replies with the word "pong".
commands.OnText("^ping$", "pong");
Trigerred at the word "ping" and sends randomly from the array word.
commands.OnText("^ping$", new[] {"pong1", "pong2", "pong3"});
*applies to all triggers.
Triggered on all incoming messages or if no command is found. Is not required.
commands.OnText("command not found");
// or
commands.OnText(new[] {"command not found", "what?", "use help command!"});
You can set regex options.
commands.OnText(("^pInG$", RegexOptions.IgnoreCase), "pong");
You can configure the logic for a specific conversation.
commands.OnText((2_000_000_000 + 1, "^ping$"), "pong for 1");
commands.OnText((2_000_000_000 + 2, "^ping$"), "pong for 2");
commands.OnText((2_000_000_000 + 3, "^pong$"), "ping");
You can combine all options.
commands.OnText((2_000_000_000 + 1, "^ping$", RegexOptions.IgnoreCase), "pong");
You can set your own trigger processing logic.
commands.OnText("^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.