/// <summary>This event is raised when client receives and parses any message type.</summary> private static async void OnMessageReceived(object sender, WolfMessageEventArgs e) { if (e.Message is ChatMessage msg) { // reply only to private text messages that start with "hello" if (msg.IsPrivateMessage && msg.IsText && msg.Text.StartsWith("hello", StringComparison.OrdinalIgnoreCase)) { await _client.ReplyTextAsync(msg, "Hello there!"); } } }
private async void OnChatMessage(ChatMessage message) { if (message.IsPrivateMessage && message.IsText && message.Text.StartsWith("hello", StringComparison.OrdinalIgnoreCase)) { await _client.ReplyTextAsync(message, "Hello there! What should I call you?").ConfigureAwait(false); // example of using Wolfringo.Utilities.Interactive package ChatMessage userResponse = await _client.AwaitNextPrivateByUserAsync(message.SenderID.Value, TimeSpan.FromMinutes(2)); if (userResponse == null || !userResponse.IsText) { await _client.ReplyTextAsync(message, "Okay, goodbye... :("); } else { await _client.ReplyTextAsync(userResponse, $"{userResponse.Text}? That's a great name!"); } } }
public static Task SendGroupMembersBugNoticeAsync(this IWolfClient client, ChatMessage message, CancellationToken cancellationToken = default) { return(client.ReplyTextAsync(message, "/alert WOLF servers are broken and refused to let me check if you're an admin in this group.\n" + "Please tell WOLF server developers to fix this already. :(", cancellationToken)); }