Class: Twitchbot::ChannelPlugin
- Inherits:
-
Object
- Object
- Twitchbot::ChannelPlugin
- Includes:
- Plugin
- Defined in:
- lib/twitchbot/plugin/channel_plugin.rb
Overview
Plugin to handle joining the specified channel, as well as maintaining a list of users who have joined or left the channel
TODO: Handle 353 and 366 (NAMES list)
Constant Summary
Constants included from Plugin
Instance Method Summary collapse
-
#join_channel(handler) ⇒ Object
Listen for the response from AuthPlugin#request_caps and request to join the channel.
-
#process_join(handler) ⇒ Object
Listen for any JOIN commands and add the user to the channel user list.
-
#process_part(handler) ⇒ Object
Listen for any PART commands and remove the user from the channel user list.
Methods included from Plugin
#close, #error, included, #message, #open
Instance Method Details
#join_channel(handler) ⇒ Object
Listen for the response from AuthPlugin#request_caps and request to join the channel
> :tmi.twitch.tv CAP * ACK :twitch.tv/tags twitch.tv/commands twitch.tv/membership
17 18 19 |
# File 'lib/twitchbot/plugin/channel_plugin.rb', line 17 def join_channel(handler) handler.send_raw "JOIN ##{handler.bot.channel.name}" end |
#process_join(handler) ⇒ Object
Listen for any JOIN commands and add the user to the channel user list
> :<user>!<user>@<user>.tmi.twitch.tv JOIN #<channel>
25 26 27 28 29 30 31 32 33 |
# File 'lib/twitchbot/plugin/channel_plugin.rb', line 25 def process_join(handler) channel = handler.bot.channel handler..each do || /:(?<sender>\w+)/ =~ .raw unless channel.users.key? sender channel.users[sender] = User.new sender end end end |
#process_part(handler) ⇒ Object
Listen for any PART commands and remove the user from the channel user list
> :<user>!<user>@<user>.tmi.twitch.tv PART #<channel>
40 41 42 43 44 45 46 47 48 |
# File 'lib/twitchbot/plugin/channel_plugin.rb', line 40 def process_part(handler) channel = handler.bot.channel handler..each do || /:(?<sender>\w+)/ =~ .raw if channel.users.key? sender channel.users.delete sender end end end |