All Projects → kritzware → Twitch Bot

kritzware / Twitch Bot

Licence: mit
🤖 Easily create chat bots for Twitch.tv

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Twitch Bot

twitch-bot-tutorial
Official repo of the "Building a Python Twitch bot (2020)" series.
Stars: ✭ 21 (-81.08%)
Mutual labels:  twitch, irc, chatbot
bot
A Go package for building Twitch.tv IRC chat bots. Previously "twitchbot".
Stars: ✭ 17 (-84.68%)
Mutual labels:  twitch, irc
recent-messages2
Service to provide historical messages to Twitch chat clients
Stars: ✭ 21 (-81.08%)
Mutual labels:  twitch, irc
Matterbridge
bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, twitch, ssh-chat, zulip, whatsapp, keybase, matrix, microsoft teams, nextcloud, mumble, vk and more with REST API (mattermost not required!)
Stars: ✭ 4,452 (+3910.81%)
Mutual labels:  twitch, irc
godot-twicil
Godot TwiCIL – Godot Twitch Chat Interaction Layer
Stars: ✭ 57 (-48.65%)
Mutual labels:  twitch, irc
Firebot
A powerful all-in-one bot for Twitch streamers
Stars: ✭ 162 (+45.95%)
Mutual labels:  twitch, chatbot
Yetibot
🤖 Extreme chatops bot for Slack and IRC 🔧 New contributors welcome 🏗
Stars: ✭ 311 (+180.18%)
Mutual labels:  chatbot, irc
twitch-irc-rs
Twitch IRC library for the Rust programming language
Stars: ✭ 58 (-47.75%)
Mutual labels:  twitch, irc
Java Twirk
Small, basic library for communication via the Twitch chat. Java 8 compatible
Stars: ✭ 36 (-67.57%)
Mutual labels:  twitch, irc
Api
`fdgt` is a mock API for the Twitch. Via `fdgt`, you can simulate events without having to spend a penny!
Stars: ✭ 40 (-63.96%)
Mutual labels:  chatbot, twitch
Devchatterbot
Stars: ✭ 60 (-45.95%)
Mutual labels:  chatbot, twitch
twitch-chatlog
Fetch the chatlog to a twitch VOD from your command line.
Stars: ✭ 78 (-29.73%)
Mutual labels:  twitch, irc
twitchchat
interface to the irc portion of Twitch's chat
Stars: ✭ 80 (-27.93%)
Mutual labels:  twitch, irc
TwitchBot
Custom C# chat bot for Twitch TV
Stars: ✭ 33 (-70.27%)
Mutual labels:  twitch, chatbot
Twitchirc Unity
lightweight IRC client component for use with the Unity Engine.
Stars: ✭ 81 (-27.03%)
Mutual labels:  twitch, irc
Multistreamer
[discontinued] A webapp for publishing video to multiple streaming services at once.
Stars: ✭ 281 (+153.15%)
Mutual labels:  twitch, irc
twitch-chat-bot
No description or website provided.
Stars: ✭ 63 (-43.24%)
Mutual labels:  twitch, irc
TwitchPy
This is a package you can use to connect with the Twitch API, manage a channel, create bots, etc
Stars: ✭ 22 (-80.18%)
Mutual labels:  twitch, irc
Tmi.js
💬 Javascript library for the Twitch Messaging Interface. (Twitch.tv)
Stars: ✭ 938 (+745.05%)
Mutual labels:  chatbot, twitch
Mojo Weixin
使用Perl语言(不会没关系)编写的个人账号微信/weixin/wechat客户端框架(非GUI),可通过插件提供基于HTTP协议的api接口供其他语言或系统调用
Stars: ✭ 1,181 (+963.96%)
Mutual labels:  chatbot, irc

twitch-bot CircleCI

Easily create chat bots for Twitch.tv

Install

Install via NPM

$ npm install twitch-bot

Example

const TwitchBot = require('twitch-bot')

const Bot = new TwitchBot({
  username: 'Kappa_Bot',
  oauth: 'oauth:dwiaj91j1KKona9j9d1420',
  channels: ['twitch']
})

Bot.on('join', channel => {
  console.log(`Joined channel: ${channel}`)
})

Bot.on('error', err => {
  console.log(err)
})

Bot.on('message', chatter => {
  if(chatter.message === '!test') {
    Bot.say('Command executed! PogChamp')
  }
})

Index

Events

connected - ()

This event is emitted when the bot has connected to the IRC server.

Usage

Bot.on('connected', () => ... )

join - ()

This event is emitted when a channel has been joined successfully.

Usage

Bot.on('join', channel => ... )

part - ()

This event is emitted when a channel has been left successfully.

Usage

Bot.on('part', channel => ... )

message - (chatter: Object)

Emitted when a PRIVSMSG event is sent over IRC. Chatter object attributes can be found on the Twitch developers site

Usage

Bot.on('message', chatter => ... )

Example Response

{ color: '#3C78FD',
  display_name: 'kritzware',
  emotes: '88:18-25',
  id: 'c5ee7248-3cea-43f5-ae44-2916d9a1325a',
  mod: true,
  room_id: 44667418,
  sent_ts: 1501541672959,
  subscriber: true,
  tmi_sent_ts: 1501541673368,
  turbo: false,
  user_id: 44667418,
  user_type: 'mod',
  badges: { broadcaster: 1, subscriber: 0 },
  channel: '#kritzware',
  message: 'This is a message PogChamp',
  username: 'Kritzware' }

timeout - (event: Object)

Emitted when a user is timed out in the chat. The ban_reason attribute is null when no reason message is used.

Chat Trigger

kritzware: "/timeout {user} {duration} {reason}"

Usage

Bot.on('timeout', event => ... )

Example Response

{ ban_duration: 10, // seconds
  ban_reason: 'Using a banned word',
  room_id: 44667418,
  target_user_id: 37798112,
  tmi_sent_ts: 1503346029068,
  type: 'timeout',
  channel: '#kritzware',
  target_username: 'blarev' }

subscription - (event: Object)

Emitted when a user subscribes to a channel and chooses to share the subscription in chat.

Usage

Bot.on('subscription', event => ... )

Example Response

{
  "badges": {
   "broadcaster": 1,
   "staff": 1,
   "turbo": 1
  },
  "channel": "#dallas",
  "color": "#008000",
  "display_name": "ronni",
  "emotes": null,
  "id": "db25007f-7a18-43eb-9379-80131e44d633",
  "login": "ronni",
  "message": "Great stream -- keep it up!", // null if no message given
  "mod": 0,
  "msg_id": "resub",
  "msg_param_months": 6,
  "msg_param_sub_plan": "Prime",
  "msg_param_sub_plan_name": "Prime",
  "room_id": 1337,
  "subscriber": 1,
  "system_msg": "ronni has subscribed for 6 months!",
  "tmi_sent_ts": 1507246572675,
  "turbo": 1,
  "user_id": 1337,
  "user_type": "staff"
}

ban - (event: Object)

Emitted when a user is permanently banned from the chat. The ban_reason attribute is null when no reason message is used.

Usage

Bot.on('ban', event => ... )

Chat Trigger

kritzware: "/ban {user} {reason}"

Example Response

{ ban_reason: 'Using a banned word',
  room_id: 44667418,
  target_user_id: 37798112,
  tmi_sent_ts: 1503346078025,
  type: 'ban',
  channel: '#kritzware',
  target_username: 'blarev' }

error - (err: Object)

Emitted when any errors occurs in the Twitch IRC channel, or when attempting to connect to a channel.

Error types

Login authentication failed

This error occurs when either your twitch username or oauth are incorrect/invalid.

Response:

{ message: 'Login authentication failed' }
Improperly formatted auth

This error occurs when your oauth password is not formatted correctly. The valid format should be "oauth:your-oauth-password-123".

Response:

{ message: 'Improperly formatted auth' }
Your message was not sent because you are sending messages too quickly

This error occurs when a message fails to send due to sending messages too quickly. You can avoid this by making the bot a moderator in the channel, if applicable/allowed.

Response:

{ message: 'Your message was not sent because you are sending messages too quickly' }

Usage

Bot.on('error', err => ... )

Example Response

{ message: 'Some error happened in the IRC channel' }

close - ()

This event is emitted when the irc connection is destroyed via the Bot.close() method.

Usage

Bot.on('close', () => {
  console.log('closed bot irc connection')
})

Methods

join(channel: String)

Attempts to join a channel. If successful, emits the 'join' event.

Example

Bot.on('join', channel => {
  console.log(`Bot joined ${channel}`)
})
Bot.join('channel2')

part(channel: String)

Attempts to part from a channel. If successful, emits the 'part' event.

Example

Bot.on('part', channel => {
  console.log(`Bot left ${channel}`)
})
Bot.part('channel2')

say(message: String, channel: []Channel, err: Callback)

Send a message in the currently connected Twitch channel. channels parameter not needed when connected to a single channel. An optional callback is provided for validating if the message was sent correctly.

Example

Bot.say('This is a message')

Bot.say('Pretend this message is over 500 characters', err => {
  sent: false,
  message: 'Exceeded PRIVMSG character limit (500)'
  ts: '2017-08-13T16:38:54.989Z'
})

// If connected to multiple channels
Bot.say('message to #channel1', 'channel1')
Bot.say('message to #channel2', 'channel2')

timeout(username: String, channel: []Channel, duration: int, reason: String)

Timeout a user from the chat. channels parameter not needed when connected to a single channel. Default duration is 600 seconds. Optional reason message.

Example

Bot.timeout('kritzware', 10)
// "kritzware was timed out for 10 seconds"

Bot.timeout('kritzware', 5, 'Using a banned word')
// "kritzware was timed out for 5 seconds, reason: 'Using a banned word'"

Bot.on('message', chatter => {
  if(chatter.message === 'xD') Bot.timeout(chatter.username, 10)
})

ban(username: String, reason: String)

Permanently ban a user from the chat. channels parameter not needed when connected to a single channel. Optional reason message.

Example

Bot.ban('kritzware')
// "kritzware is now banned from the room"

Bot.timeout('kritzware', 'Using a banned word')
// "kritzware is now banned from the room, reason: 'Using a banned word'"

Bot.on('message', chatter => {
  if(chatter.message === 'Ban me!') Bot.ban(chatter.username)
})

close()

Closes the Twitch irc connection. Bot will be removed from the Twitch channel AND the irc server.

Example

Bot.close()

Running Tests

Running the test suite requires at least two twitch accounts, one moderator account and one normal account. The channel used must be the same - This is so timeout/ban methods can be tested with the mod account. Using these two accounts, set the following environment variables:

TWITCHBOT_USERNAME=mod_username
TWITCHBOT_OAUTH=oauth:mod-oauth-token
TWITCHBOT_CHANNEL=mod_channel
TWITCHBOT_USERNAME_NON_MOD=non_mod_username
TWITCHBOT_OAUTH_NON_MOD=oauth:non-mod-oauth-token
TWITCHBOT_CHANNEL_NON_MOD=mod_channel

To run the tests (powered with Mocha), use the following command:

yarn test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].