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