lib/meimei/client.rb
# Creates a new plugin.
#
# === Parameters
# - name: The name of the plugin. There are two special cases: (1) If the name begins with "!", then it is considered a command. For example, a plugin named "!wiki" would only be invoked if a message began with "!wiki". The message passed to the plugin will have the command stripped out. (2) If the plugin begins with "@", then it is considered a timer event. For example, a plugin named "@60" will run every 60 seconds. "@10m" will run every 10 minutes, and "@4h" will run every 4 hours.
# - options[:position]: Insert plugin at position n (lower number positions will be run first).
Creates a new plugin.
Parameters
name: The name of the plugin. There are two special cases: (1) If the name begins with "!", then it is considered a command. For example, a plugin named "!wiki" would only be invoked if a message began with "!wiki". The message passed to the plugin will have the command stripped out. (2) If the plugin begins with "@", then it is considered a timer event. For example, a plugin named "@60" will run every 60 seconds. "@10m" will run every 10 minutes, and "@4h" will run every 4 hours.
options[:position]: Insert plugin at position n (lower number positions will be run first).
Creates a new plugin . Parameters name : The name of the plugin . There are two special cases : ( 1 ) If the name begins with " ! " then it is considered a command . For example a plugin named " !wiki " would only be invoked if a message began with " !wiki " . The message passed to the plugin will have the command stripped out . ( 2 ) If the plugin begins with " @ " then it is considered a timer event . For example a plugin named " @60 " will run every 60 seconds . " @10m " will run every 10 minutes and " @4h " will run every 4 hours . options [ : position ] : Insert plugin at position n ( lower number positions will be run first ) .
def define_plugin(name, options = {}, &block)
      case name
      when /^@(\d+)([mh])?/
        interval = $1.to_i
        if $2 == "m"
          interval = interval * 60
        elsif $2 == "h"
          interval = interval * 60 * 60
        end
        plugins = @timer_plugins
        plugin = [name, interval, Time.now, block, options]
      else
        plugins = @command_plugins
        plugin = [name, block, options]
      end
      if options[:position]
        plugins.insert(options[:position], plugin)
      else
        plugins << plugin
      end
      plugins.compact!
    end
def define_plugin ( name , options = { } , & block ) case name when / ^@( \d +)([mh])? / interval = $1 . to_i if $2 == "m" interval = interval * 60 elsif $2 == "h" interval = interval * 60 * 60 end plugins = @timer_plugins plugin = [ name , interval , Time . now , block , options ] else plugins = @command_plugins plugin = [ name , block , options ] end if options [ :position ] plugins . insert ( options [ :position ] , plugin ) else plugins << plugin end plugins . compact! end
Creates a new plugin.
Creates a new plugin .
# TODO: Is there a memory leak here?
name
<not_specific>
options
<not_specific>
block
<not_specific>