Class: Twitchbot::MessageQueuePlugin

Inherits:
Object
  • Object
show all
Includes:
TimedPlugin
Defined in:
lib/twitchbot/plugin/message_queue_plugin.rb

Overview

Plugin to handle sending messages to the server that have been queued from any plugins running.

TODO: Implement different levels of rate limiting according to bot status e.g. :mod, :verified, :trusted

Constant Summary

Constants included from TimedPlugin

TimedPlugin::COMMANDS

Instance Method Summary collapse

Methods included from TimedPlugin

#close, #error, included, #message, #open

Instance Method Details

#send_message(handler) ⇒ Object

Pull a message from the message queue if any are available and send to the server



15
16
17
18
19
20
21
22
# File 'lib/twitchbot/plugin/message_queue_plugin.rb', line 15

def send_message(handler)
  queue = handler.bot.message_queue
  unless queue.empty?
    message = queue.pop
    puts "< #{message}" if handler.bot.debug
    handler.connection.send message
  end
end