Function twitch_api2::pubsub::listen_command [−][src]
pub fn listen_command<'t, O>(
topics: &'t [Topics],
auth_token: &'t str,
nonce: O
) -> Result<String, Error> where
O: Into<Option<&'t str>>,
This is supported on crate feature
pubsub
only.Create a listen command.
Example
Create a listen message for moderator actions
// We want to subscribe to moderator actions on channel with id 1234 // as if we were a user with id 4321 that is moderator on the channel. let chat_mod_actions = pubsub::moderation::ChatModeratorActions { user_id: 4321, channel_id: 1234, }.into_topic(); // Listen to follows as well let follows = pubsub::following::Following { channel_id: 1234, }.into_topic(); // Create the topic command to send to twitch let command = pubsub::listen_command( &[chat_mod_actions, follows], "authtoken", "super se3re7 random string", ) .expect("serializing failed"); // Send the message with your favorite websocket client send_command(command).unwrap(); // To parse the websocket messages, use pubsub::Response::parse