Sha256: ded4f8cd1274c45e38340bc7a3bfd2161954d78027a92fc717f1befa514d85af

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

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)
        message = MadChatter::Message.new('message', text)
        send_json(message.to_json)
      end
    
      def send_status_message(text)
        message = MadChatter::Message.new('status', text)
        send_json(message.to_json)
      end
    
      def send_users_list
        message = MadChatter::Message.new('users', MadChatter::Users.current)
        send_json(message.to_json)
      end
    
      def send_action(action, *args)
        message = MadChatter::Message.new('action', {function: action, args: args})
        send_json(message.to_json)
      end
      
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mad_chatter-0.2.8 lib/mad_chatter/actions/dsl.rb
mad_chatter-0.2.7 lib/mad_chatter/actions/dsl.rb
mad_chatter-0.2.6 lib/mad_chatter/actions/dsl.rb
mad_chatter-0.2.5 lib/mad_chatter/actions/dsl.rb
mad_chatter-0.2.4 lib/mad_chatter/actions/dsl.rb
mad_chatter-0.2.3 lib/mad_chatter/actions/dsl.rb