twitchchat
twitchchat
This crate provides a way to interact with Twitch's chat
Along with the messages/commands as Rust types, it provides methods for sending messags/commands.
a simple example
use commands;
use *;
// use an anonymous login (you should probably use your name and your chat oauth token)
let = ANONYMOUS_LOGIN;
// connect with this nick, token
let mut client = connect_easy
.unwrap // this is an error if
// the network connection can't be opened,
// the nick/pass is invalid, etc
// add some filters
. // filter to PrivMsg commands
.; // filter to Join commands
// get a clonable, threadsafe writer
let writer = client.writer;
// for each event from the client (this &mut is only needed if you want to use `wait_for_close`)
for event in &mut client
// wait for the client to close
// this isn't needed, but if you want to synchronize something to it
// this is how you would do it
client.wait_for_close;
with custom capabilities
use commands;
use *;
// use an anonymous login (you should probably use your name and your chat oauth token)
let = ANONYMOUS_LOGIN;
let config = builder
.token // your oauth token
.nick // your nickname
.commands // command capabilites (see: https://dev.twitch.tv/docs/irc/commands/ )
.membership // command capabilites (see: https://dev.twitch.tv/docs/irc/membership/ )
.tags // command capabilites (see: https://dev.twitch.tv/docs/irc/tags/ )
.build // verify the settings
.unwrap;
// connect with the config
let client = connect
.unwrap
.;
let writer = client.writer;
for event in client
by constructing the client manually with your own Read/Write types
use TcpStream;
use commands;
use *;
// or anything that implements std::io::Read + Send + Sync and std::io::Write + Send + Sync
let = connect
.map
.unwrap;
// use an anonymous login (you should probably use your name and your chat oauth token)
let = ANONYMOUS_LOGIN;
let config = builder
.token // your oauth token
.nick // your nickname
.commands // command capabilites (see: https://dev.twitch.tv/docs/irc/commands/ )
.membership // command capabilites (see: https://dev.twitch.tv/docs/irc/membership/ )
.tags // command capabilites (see: https://dev.twitch.tv/docs/irc/tags/ )
.build // verify the settings
.unwrap;
let client = register.unwrap;
let client = client.;
let writer = client.writer;
for event in client
License: 0BSD