twitch-stream
v0.3.1
Published
Stream Twitch chat
Downloads
3
Readme
twitch-stream :boom:
Stream Twitch chat in node js.
npm install --save twitch-stream
const twitchStream = require( 'twitch-stream' );
twitchStream.connect({
user : 'username',
pass : 'oauth:abc123',
channel :
[
'#user1',
'#user2'
],
data : function( msg )
{
console.log( msg );
},
error : function( err )
{
console.log( err );
},
done : function( client )
{
client.part( '#user1' );
client.join( '#user3' );
}
});
Parameters
user
(required)
Username of Twitch account to use.
pass
(required)
Password for the account. Passwords for Twitch chat can be generated here.
channel
(optional)
Array of channels to initialise the stream with. Note that channels have to be prepended with '#'.
data
(optional)
Called every time a message is posted in one of the connected channels.
Is passed an object with attributes 'user', 'message' and 'channel'.
done
(optional)
Called when a connection has been made. Is passed a slate-irc client object. The stream can be manipulated through this object e.g. joining channels, leaving channels etc.
The interface this object presents is the same as the slate-irc client, however all slate-irc client functions that do not have a callback now have an optional callback as the last parameter.
This is because the client object enforces the rate limit; commands sent through the client that are over the rate limit are queued (first in, first out) and executed at a later point in time. When the command is executed, the callback is fired.
error
(optional)
Called when an error occurs. Is passed the error as the first parameter. The close event will occur directly after this event.
close
(optional)
Called when the connection has closed.
License
MIT