Sha256: 4d217028c966e93745c9fcc1d602bc7fbc12c10f00028175d207d41f20fe56f9

Contents?: true

Size: 1023 Bytes

Versions: 2

Compression:

Stored size: 1023 Bytes

Contents

module MadChatter
  module Actions
    module Dsl
      
      # Used to define a simple extension
      def on_message(regex, &block)
        MadChatter.message_listeners << MadChatter::Actions::Base.new(regex, block)
      end
      
      # Helper methods
    
      def stop_message_handling
        raise "Don't call any more message listeners"
      end
    
      def send_json(json)
        MadChatter::Server.send_json(json)
      end
    
      def send_message(text)
        MadChatter::Server.send_message MadChatter::Message.new('message', text)
      end
    
      def send_status_message(text)
        MadChatter::Server.send_message MadChatter::Message.new('status', text)
      end
    
      def send_users_list
        MadChatter::Server.send_message MadChatter::Message.new('users', MadChatter::Users.current)
      end
    
      def send_action(action, *args)
        MadChatter::Server.send_message MadChatter::Message.new('action', {function: action, args: args})
      end
      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mad_chatter-0.3.1 lib/mad_chatter/actions/dsl.rb
mad_chatter-0.3.0 lib/mad_chatter/actions/dsl.rb