this project was created with bun.
Warning
W.I.P Please Do not use in Production.
bun:
bun install MolikoDeveloper/TwitchTS
you can connect to the chat as anonymous, or with your username and twitch Oauth Token
import {IrcClient} from 'twitchts';
const chat = new IrcClient({
channels: ['CHANNEL'],
identity:{
user:{
username: "<YOUR_USERNAME>",
token: "<YOUR TOKEN>",
refreshToken: "<YOUR REFRESH TOKEN IF YOU GENERATE A CODE>.",
code: "<oauth code>"
},
}
debug:true,
profaneFilter: true;
});
chat.on('message', (channel, tags, message, self) => {
if (self) return; //if self == channel.idendity return.
if(message.toLocaleLowerCase().includes("hello")){
chat.say(channel, `hi @${tags['display-name']}`);
}
})
import { EventSub } from 'twitchts';
let client: EventSub = new EventSub({
identity: {
user: {
token: `<YOUR TOKEN HERE, WITHOUT 'Bearer ...'>`,
refreshToken: `<REFRESHTOKEN>`,
code: `<oauth code>`
},
app: {
clientId: `<YOUR CLIENT ID>`,
secret: `<YOUR APP SECRET>`,
redirect_uri: `<URL>`,
events: ['ChannelUpdate','ChannelBan','ChannelFollow', '<other...>'],
actions: ['<WORK IN PROGRESS>'] //send whisper, messages with helix api, raid, poll, predictions, etc...
}
},
channels: ["<CHANNEL USERNAME OR DISPLAY NAME>"],
debug: true, //print debug information, token links for eventsub
testWebsocket: false
});
client.on('ChannelUpdate', (event) => {
console.log('New Title:',event.title);
});
client.on('ChannelBan', (event) => {
console.log(event.user_name, event.reason);
});
client.on('ChannelFollow', (event) => {
console.log(event.user_name, 'is a new follower!');
});
yes, the Options
are compatible with both.
import { EventSub, IrcClient, type Options } from '..';
const option: Options = {
identity: {
user: {
username: '<user_name>', //all without < >
token: `<token>`,
refreshToken: `<refresh_token>`,
code: `<code>`
},
app: {
clientId: `<client_id>`,
secret: `<app_secret>`,
redirect_uri: `<URL>`,
events: ['ChannelFollow'],
actions: []
}
},
channels: ["albertosaurus_ac"],
debug: true,
testWebsocket: false
}
const subs = new EventSub(option);
const chat = new IrcClient(option);
//
subs.on('ChannelFollow', (event) => {
chat.say(event.broadcaster_user_name, `Thanks for your follow @${event.user_name}!`)
chat.say(event.broadcaster_user_name, `BUT NOW YOU ARE BANNED! WAJAJAJA`);
subs.ban(event.broadcaster_user_name,event.broadcaster_user_name);
subs.unban(event.broadcaster_user_name,event.broadcaster_user_name);
chat.say(event.broadcaster_user_name, `im joking, just chill.`);
});
-
IRC Connection
-
Oauth
-
Events
- on message
- on command
- on join
- on notice
- on ban
- on clear chat
- on reconnect
- on roomstate
-
Command Recognition (!command parameters split by space)
-
-
WebSocket EventSub Connection
- Baurer Oauth
- Local Enviroment testing with Twitch CLI
- Subscriptions
use with EventSub.on('ChannelBan', (event) => { })
- Channel.Ban
- Channel.Unban
- Channel.Cheer
- Channel.Raid
- Channel.Follow
- Channel.Update
- Channel.Subscribe
- Channel.Subscription.End
- Channel.Subscription.Gift
- Channel.Subscription.Message
- Channel.Moderator.Add
- Channel.Moderator.Remove
- Channel.Points_Custom_Reward.Add
- Channel.Points_Custom_Reward.Update
- Channel.Points_Custom_Reward.Remove
- Channel.Points_Custom_Reward.Redemption.Add
- Channel.Points_Custom_Reward.Redemption.Update
- Channel.Poll.Begin
- Channel.Poll.Progress
- Channel.Poll.End
- Channel.Prediction.Begin
- Channel.Prediction.Progress
- Channel.Prediction.Lock
- Channel.Prediction.End
- Drop.Entitlement.Grant
- Extension.Bits_Transaction.Create
- Goal.Begin
- Goal.Progress
- Goal.End
- Hype.Train.Begin
- Hype.Train.Progress
- Hype.Train.End
- Stream.Online
- Stream.Offline
- User.Authorization.Grant
- User.Authorization.Revoke
- User.Update
- Channel.Guest.Star.Session.Begin
- Channel.Guest.Star.Session.End
- Channel.Guest.Star.Session.Update
- Channel.Guest.Star.Settings.Update
- Actions
- Ads
- Analytics
> CHECK/REVISAR/IMPORTANTE
- Bits
- Channels
- Channel Points
> Revision Pending
- Charity
- Chat
- Clips
- Conduits
- Entitlements
- Extensions
- Update Drops Entitlements
- Get Extension Configuration Segment
- Set Extension Configuration Segment
- Set Extension Required Configuration
- Send Extension PubSub Message
- Get Extension Live Channels
- Get Extension Secrets
- Create Extension Secret
- Send Extension Chat Message
- Get Extensions
- Get Released Extensions
- Get Extension Bits Products
- Update Extension Bits Product
- EventSub
- Games
- Goals
- Guest Star (beta)
- Get Channel Guest Star Settings
- Update Channel Guest Star Settings
- Get Guest Star Session
- Create Guest Star Session
- End Guest Star Session
- Get Guest Star Invites
- Send Guest Star Invite
- Delete Guest Star Invite
- Assign Guest Star Slot
- Update Guest Star Slot
- Delete Guest Star Slot
- Update Guest Star Slot Settings
- Hype Train
- Moderation
- Check AutoMod Status
- Manage Held AutoMod Messages
- Get AutoMod Settings
- Update AutoMod Settings
- Get Banned Users
- Ban User
- Unban User
- Get Unban Requests
- Resolve Unban Requests
- Get Blocked Terms
- Add Blocked Term
- Remove Blocked Term
- Delete Chat Messages
- Get Moderated Channels
- Get Moderators
- Add Channel Moderator
- Remove Channel Moderator
- Get VIPs
- Add Channel VIP
- Remove Channel VIP
- Update Shield Mode Status
- Get Shield Mode Status
- Polls
- Predictions
- Raids
- Schedule
- Search
- Sreams
- Subscriptions
- Tags
- Teams
- User
- Videos
- Whispers
-
Webhook Connection
- Baurer Oauth
- Subscriptions
- Actions
function GetTokens(client_id, secret, code, redirect_uri){
console.log(Token)
console.log(RefreshToken)
}
start server with:
twitch event websocket start-server
twitch event trigger channel.ban --transport=websocket
@ppauel (twitch-eventsub) and tmijs (tmi.js)