Class: Twitchbot::AuthPlugin

Inherits:
Object
  • Object
show all
Includes:
Plugin
Defined in:
lib/twitchbot/plugin/auth_plugin.rb

Overview

Plugin to handle authenticating the bot account and authorizing the use of all available Twitch IRCv3 capabilities

Constant Summary collapse

CAPABILITIES =

The capabilities available to request

%w(
   twitch.tv/tags
   twitch.tv/commands
   twitch.tv/membership
).freeze

Constants included from Plugin

Plugin::COMMANDS

Instance Method Summary collapse

Methods included from Plugin

#close, #error, included, #message

Instance Method Details

#open(handler) ⇒ Object

Send bot account credentials after the connection has opened



17
18
19
20
# File 'lib/twitchbot/plugin/auth_plugin.rb', line 17

def open(handler)
  handler.send_raw "PASS #{handler.bot.password}"
  handler.send_raw "NICK #{handler.bot.username}"
end

#request_caps(handler) ⇒ Object

Listen for the last message of a successful authentication attempt and request capabilities

> :tmi.twitch.tv 001 bot :Welcome, GLHF!
> :tmi.twitch.tv 002 bot :Your host is tmi.twitch.tv
> :tmi.twitch.tv 003 bot :This server is rather new
> :tmi.twitch.tv 004 bot :-
> :tmi.twitch.tv 375 bot :-
> :tmi.twitch.tv 372 bot :You are in a maze of twisty passages, all alike.
> :tmi.twitch.tv 376 bot :>


33
34
35
# File 'lib/twitchbot/plugin/auth_plugin.rb', line 33

def request_caps(handler)
  handler.send_raw "CAP REQ :#{CAPABILITIES.join ' '}"
end