mad_chatter 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Mad Chatter is a fun, easy to customize chat server. It's written in Ruby and utilizes HTML 5 Web Sockets for fast communication.
4
4
 
5
- The goal of Mad Chatter is to basically become an open-source version of [Campfire](http://campfirenow.com/), [HipChat](https://www.hipchat.com), or [FlowDock](https://www.flowdock.com). Or at least use those as inspiration.
5
+ The goal of Mad Chatter is to basically become an open-source version of [Campfire](http://campfirenow.com/), [HipChat](https://www.hipchat.com), or [FlowDock](https://www.flowdock.com)...or at least use those as inspiration.
6
6
 
7
7
  ## Getting Started
8
8
 
@@ -22,7 +22,7 @@ This command will generate the following structure:
22
22
 
23
23
  mychatroom/
24
24
  config.yml # for general configuration
25
- extensions.rb # for writing your own extensions
25
+ extensions/ # for writing your own extensions
26
26
  web/ # all of the html, css, and javascript live here
27
27
 
28
28
  To start your chat server, navigate to the directory that was just created and run...
@@ -33,7 +33,7 @@ This will start up the Mad Chatter chat server as well as a simple web server fo
33
33
 
34
34
  ![Mad Chatter screenshot](https://raw.github.com/andrewhavens/mad_chatter/master/screenshot.png)
35
35
 
36
- When you're ready to have other people use your chat server (friends, family, co-workers, etc) you'll want to host the server and web directory some place that they can access (on a web server, for example, if it will be used outside your local network). You'll also want to start the chat server and leave it running for a long time in the background. This is known as a "daemon". Here are a few useful commands for that:
36
+ When you're ready to have other people start using your new chat server (friends, family, co-workers, etc) you'll need to set up a web server so other people can access it. Set up your web server to serve the `web` directory that we created above. Now you're ready to start Mad Chatter and leave it running in the background. Here are a few useful commands for that:
37
37
 
38
38
  mad_chatter start
39
39
  mad_chatter stop
@@ -41,7 +41,7 @@ When you're ready to have other people use your chat server (friends, family, co
41
41
 
42
42
  ## Chat Actions
43
43
 
44
- Mad Chatter can do some special things depending on the chat messages you send. Every chat message is parsed to see if it is a normal chat message, or if its a special action. These actions are much like IRC commands. For example, if I wanted to change my screen name from Andrew to Andy I could chat this message:
44
+ Mad Chatter can do some special things depending on the chat messages you send. Every chat message is parsed to see if it is a normal chat message, or if it's a special action. These actions are much like IRC commands. For example, if I wanted to change my name from Andrew to Andy I could chat this message:
45
45
 
46
46
  /nick andy
47
47
 
@@ -62,31 +62,30 @@ You can even create your own actions!
62
62
 
63
63
  The goal of Mad Chatter is to make it easy to create, host, and customize your own chat server. Let's take a look at the different ways you can customize your new chat server.
64
64
 
65
- If you want to customize the html/css of your chatroom, you'll find it in the `web` directory.
65
+ All of the HTML, CSS, and Javascript is available for you to customize in the `web` directory.
66
66
 
67
67
  In the `config.yml` file you can see a few things you can customize.
68
68
 
69
- The `extensions.rb` file is for you to create your own chat extensions. You will find a few examples in that file.
69
+ The `extensions` directory contains all of your extensions. If you wanted to create a custom action, this is where you would put it. You will find a few examples in that directory.
70
70
 
71
71
 
72
72
  ## Mac, Windows, and Linux Wrappers
73
73
 
74
- Once you've got your chat server running and being used by other people, you might be interested in using/distributing an installable application so your users have the convenience of clicking on an icon, receiving growl notifications, etc. Here's a list of the currently available "wrapper" applications:
74
+ Once you've got your chat server running and being used by other people, you might be interested in using and distributing an installable application so your users have the convenience of clicking on an icon, receiving growl notifications, etc. Here's a list of the currently available "wrapper" applications:
75
75
 
76
76
  * [Mad Chatter for Mac](https://github.com/andrewhavens/mad_chatter_for_mac)
77
77
 
78
78
  ## Getting Help / Providing Feedback
79
79
 
80
- Feel free to submit bug reports and feature requests to our [GitHub Issues page](https://github.com/andrewhavens/mad_chatter/issues), or post to the [Google Group](https://groups.google.com/group/mad-chatter), or send me a message on GitHub.
80
+ If you need help or have feedback, feel free to submit bug reports and feature requests to our [GitHub Issues page](https://github.com/andrewhavens/mad_chatter/issues), or post to the [Google Group](https://groups.google.com/group/mad-chatter).
81
81
 
82
82
  You can also vote on upcoming features: https://madchatter.uservoice.com
83
83
 
84
84
  ## Contributing
85
85
 
86
+ Please fork and send pull requests! Or submit issues if you have suggestions on how to improve Mad Chatter.
86
87
  [![Build Status](https://secure.travis-ci.org/andrewhavens/mad_chatter.png)](http://travis-ci.org/andrewhavens/mad_chatter)
87
88
 
88
- Please fork and send pull requests! Or submit issues if you have suggestions on how to improve.
89
-
90
89
  ##Copyright
91
90
 
92
- Copyright (c) 2011-2012 Andrew Havens. MIT license. See LICENSE.txt for further details.
91
+ Created by Andrew Havens and released under the MIT license.
data/bin/mad_chatter CHANGED
@@ -14,10 +14,17 @@ module MadChatter
14
14
  desc "new [name]", "Generates a new Mad Chatter application"
15
15
  def new(name)
16
16
  copy_file "templates/config.yml", "#{name}/config.yml"
17
- copy_file "templates/extensions.rb", "#{name}/extensions.rb"
17
+ directory "templates/extensions", "#{name}/extensions"
18
18
  directory "templates/web", "#{name}/web"
19
19
  end
20
20
 
21
+ desc "update", "Updates an existing Mad Chatter application"
22
+ def new(name)
23
+ copy_file "templates/config.yml", "config.yml"
24
+ directory "templates/extensions", "extensions"
25
+ directory "templates/web", "web"
26
+ end
27
+
21
28
  desc 'preview', 'Starts both a web server and the Mad Chatter chat server'
22
29
  def preview
23
30
  t1 = Thread.new { require 'mad_chatter/web_server' }
@@ -4,25 +4,23 @@ module MadChatter
4
4
  def stop_message_handling
5
5
  raise "Don't call any more message listeners"
6
6
  end
7
-
8
- # def send_json(json)
9
- # MadChatter.send_json(json)
10
- # end
11
-
12
- def send_message(text, from)
13
- MadChatter.send_message MadChatter::Message.new('message', text, from)
7
+
8
+ def send_message(text, from = nil)
9
+ m = MadChatter::Message.new('message', text)
10
+ m.username = from || @message.username
11
+ m.channel = @message.channel
12
+ MadChatter.send_message(m)
14
13
  end
15
14
 
16
15
  def send_status_message(text)
17
- MadChatter.send_message MadChatter::Message.new('status', text)
16
+ MadChatter.send_message MadChatter::Message.new('status', text, nil, @message.channel)
18
17
  end
19
-
20
- # def send_users_list
21
- # send_json MadChatter::Users.to_json
22
- # end
23
-
18
+
24
19
  def send_action(action, *args)
25
- MadChatter.send_message MadChatter::Message.new('action', {function: action, args: args})
20
+ m = MadChatter::Message.new('action')
21
+ m.json = {function: action, args: args}
22
+ m.channel = @message.channel
23
+ MadChatter.send_message(m)
26
24
  end
27
25
 
28
26
  end
@@ -17,7 +17,6 @@ module MadChatter
17
17
 
18
18
  config = YAML::load(File.open(config_file))
19
19
  defaults = {
20
- 'websocket_backend' => 'websocket-rack',
21
20
  'websocket_port' => 8100,
22
21
  }
23
22
  @config = defaults.merge!(config)
@@ -30,15 +29,17 @@ module MadChatter
30
29
  end
31
30
 
32
31
  def init_extensions
33
- simple_extensions_file = File.join(Dir.pwd, 'extensions.rb')
34
- if File.exist?(simple_extensions_file)
35
- file_contents = File.read(simple_extensions_file)
36
- # MadChatter::Extensions.module_eval file_contents
37
- end
38
-
39
- # Dir[Dir.pwd + '/extensions/*.rb'].each do |file|
40
- # require file
32
+ # simple_extensions_file = File.join(Dir.pwd, 'extensions.rb')
33
+ # if File.exist?(simple_extensions_file)
34
+ # file_contents = File.read(simple_extensions_file)
35
+ # MadChatter::Extensions.class_eval file_contents
41
36
  # end
37
+
38
+ # Auto-require User Defined Extension Classes
39
+ Dir[Dir.pwd + '/extensions/*.rb'].each do |file|
40
+ require file
41
+ # MadChatter.message_listeners << Object.const_get('MadChatter').const_get('Extensions').const_get(file).new
42
+ end
42
43
  end
43
44
 
44
45
  def init_default_channels
@@ -0,0 +1,16 @@
1
+ module MadChatter
2
+ class Extension
3
+ include MadChatter::Actions
4
+
5
+ attr_accessor :message
6
+
7
+ def self.inherited(klass)
8
+ MadChatter.message_listeners << klass.new
9
+ end
10
+
11
+ def handle(message)
12
+ # subclasses should override this function, or use the on_message shortcut method
13
+ end
14
+
15
+ end
16
+ end
@@ -3,7 +3,7 @@ require 'cgi'
3
3
  module MadChatter
4
4
  class Message
5
5
 
6
- attr_accessor :type, :original_text, :filtered_text, :html, :token, :channel, :growl, :add_to_history, :timestamp
6
+ attr_accessor :type, :original_text, :filtered_text, :html, :json, :token, :channel, :growl, :add_to_history, :timestamp
7
7
 
8
8
  def initialize(type, text = nil, token = nil, channel_id = nil)
9
9
  @type = type
@@ -46,6 +46,7 @@ module MadChatter
46
46
  type: @type,
47
47
  text: @original_text,
48
48
  html: @html,
49
+ json: @json,
49
50
  username: username,
50
51
  channel: @channel,
51
52
  growl: @growl,
@@ -4,16 +4,13 @@ module MadChatter
4
4
 
5
5
  include MadChatter::Actions
6
6
 
7
- @@regex = %r{^/code (.+)}
8
-
9
7
  def handle(msg)
10
- if msg.original_text =~ @@regex
8
+ if msg.original_text =~ %r{^/code (.+)}
11
9
  code = parse(msg.original_text)
12
10
  message = MadChatter::Message.new('message', nil, msg.token, msg.channel)
13
11
  message.html = "<pre>" + message.filter(code) + "</pre>"
14
12
  message.growl = msg.username + ' has shared a code sample' if msg.username
15
- channel = MadChatter::find_channel_by_id(msg.channel)
16
- channel.send_message(message)
13
+ MadChatter.send_message(message)
17
14
  stop_message_handling
18
15
  end
19
16
  end
@@ -12,8 +12,7 @@ module MadChatter
12
12
  img_msg = MadChatter::Message.new('message', img_url, message.token, message.channel)
13
13
  img_msg.html = "<img src='#{img_url}'>"
14
14
  img_msg.growl = message.username + ' has shared an image'
15
- channel = MadChatter::find_channel_by_id(message.channel)
16
- channel.send_message(img_msg)
15
+ MadChatter.send_message(message)
17
16
  stop_message_handling
18
17
  end
19
18
  end
@@ -0,0 +1,26 @@
1
+ module MadChatter
2
+ module MessageListeners
3
+ class Video
4
+
5
+ include MadChatter::Actions
6
+
7
+ @@youtube = %r{^/youtube http://youtu.be/(.*)$}
8
+
9
+ def handle(message)
10
+ if message.original_text =~ @@youtube
11
+ youtube_id = parse_youtube_id(message.original_text)
12
+ img_msg = MadChatter::Message.new('message', nil, message.token, message.channel)
13
+ img_msg.html = "<iframe width='560' height='315' src='http://www.youtube.com/embed/#{youtube_id}' frameborder='0' allowfullscreen></iframe>"
14
+ img_msg.growl = message.username + ' has shared a YouTube video'
15
+ MadChatter.send_message(message)
16
+ stop_message_handling
17
+ end
18
+ end
19
+
20
+ def parse_youtube_id(text)
21
+ @@youtube.match(text).captures[0]
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -7,12 +7,7 @@ module MadChatter
7
7
  end
8
8
 
9
9
  def initialize_server
10
- # TODO: Figure out a better (more flexible/dynamic) way to initialize the server class
11
- if @config['websocket_backend'] && @config['websocket_backend'] == 'MadChatter::Servers::EventMachineWebSocket'
12
- return MadChatter::Servers::EventMachineWebSocket.new(@config['websocket_port'], self)
13
- end
14
-
15
- raise 'You did not specify a valid class name for websocket_backend'
10
+ return MadChatter::Servers::EventMachineWebSocket.new(@config['websocket_port'], self)
16
11
  end
17
12
 
18
13
  def start
@@ -1,5 +1,5 @@
1
1
  module MadChatter
2
2
 
3
- VERSION = '0.3.2'
3
+ VERSION = '0.3.3'
4
4
 
5
5
  end
data/lib/mad_chatter.rb CHANGED
@@ -19,15 +19,13 @@ require 'mad_chatter/message'
19
19
  require 'mad_chatter/message_history'
20
20
 
21
21
  require 'mad_chatter/actions'
22
+ require 'mad_chatter/extension'
22
23
  require 'mad_chatter/message_listeners/channel_commands'
23
24
  require 'mad_chatter/message_listeners/markdown'
24
25
  require 'mad_chatter/message_listeners/nick'
25
26
  require 'mad_chatter/message_listeners/image'
26
27
  require 'mad_chatter/message_listeners/code'
27
28
 
28
- require 'mad_chatter/extensions'
29
- require 'mad_chatter/message_listener'
30
-
31
29
  module MadChatter
32
30
 
33
31
  class << self
@@ -95,6 +93,7 @@ module MadChatter
95
93
 
96
94
  begin
97
95
  message_listeners.each do |listener|
96
+ listener.message = message if listener.respond_to?('message=')
98
97
  listener.handle(message)
99
98
  end
100
99
  send_message(message)
data/screenshot.png CHANGED
Binary file
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Mad Chatter Simple Extensions' do
4
+
5
+ before(:each) do
6
+ MadChatter.users = []
7
+ MadChatter.channels = []
8
+ end
9
+
10
+ it 'should allow you to define simple extensions that work' do
11
+
12
+ end
13
+
14
+ end
data/templates/config.yml CHANGED
@@ -2,5 +2,4 @@
2
2
  # Mad Chatter Configuration #
3
3
  # ------------------------------------ #
4
4
 
5
- websocket_backend: MadChatter::Servers::EventMachineWebSocket
6
5
  websocket_port: 8100
@@ -0,0 +1,11 @@
1
+ class Earthquake < MadChatter::Extension
2
+
3
+ def handle(message)
4
+ if message.text == '/earthquake'
5
+ send_status_message "#{message.username} has just caused an earthquake!"
6
+ send_action 'earthquake' # call a javascript function named 'earthquake'
7
+ stop_message_handling
8
+ end
9
+ end
10
+
11
+ end
@@ -1,16 +1,12 @@
1
- # this definitely doesnt work anymore
2
-
3
- class Example
4
- # include MadChatter::Extension
1
+ class MadChatterExtensionExample < MadChatter::Extension
5
2
 
6
3
  def handle(message)
7
4
  if message.text == 'show me an example'
8
5
  send_status_message "#{message.username} really wants an example"
9
6
  send_message 'I said...I want an example!!!'
10
- stop_message_handling # and don't let any other extensions handle it
11
- else
12
- # let other extensions handle it
7
+ stop_message_handling
13
8
  end
9
+ # ...otherwise, let other extensions have a chance at handling it
14
10
  end
15
11
 
16
12
  end
@@ -1,31 +1,19 @@
1
1
  #
2
2
  # Simple Mad Chatter Extensions
3
3
  #
4
- # You can add as many extensions as you want in this file using the
5
- # simple extension syntax. For more complicated extensions, add your
6
- # classes to the extensions directory.
4
+ # This file provides you with an easy way to extend Mad Chatter
5
+ # and react to different chat messages.
7
6
  #
8
- # Example:
9
- #
10
- # on_message /hey andrew: (.+)/ do |regex_capture|
11
- # send_status_message 'Someone is talking to andrew'
12
- # end
7
+ # Example Extension:
13
8
  #
9
+ # on_message %r{ hey andrew: (.+) } do |regex_capture|
10
+ # send_status_message "Someone is talking to Andrew"
11
+ # send_message "message: #{regex_capture}"
12
+ # stop_message_handling
13
+ # end
14
14
 
15
- #nothing in this file will work, now that we have multiple channels, sorry!!
16
15
 
17
16
  # on_message %r{^/youtube http://youtu.be/(.*)$} do |youtube_id|
18
17
  # send_message "<iframe width='560' height='315' src='http://www.youtube.com/embed/#{youtube_id}' frameborder='0' allowfullscreen></iframe>"
19
18
  # stop_message_handling
20
- # end
21
- #
22
- # on_message %r{^/alert (.*)$} do |alert_message|
23
- # send_action 'show_alert', alert_message
24
- # stop_message_handling
25
- # end
26
- #
27
- # on_message %r{^/earthquake$} do
28
- # send_status_message 'Someone has just caused an earthquake!'
29
- # send_action 'earthquake'
30
- # stop_message_handling
31
19
  # end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mad_chatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-17 00:00:00.000000000Z
12
+ date: 2012-02-18 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &2165016220 !ruby/object:Gem::Requirement
16
+ requirement: &2160471460 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2165016220
24
+ version_requirements: *2160471460
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: eventmachine
27
- requirement: &2165009100 !ruby/object:Gem::Requirement
27
+ requirement: &2160471040 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2165009100
35
+ version_requirements: *2160471040
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: em-websocket
38
- requirement: &2165008680 !ruby/object:Gem::Requirement
38
+ requirement: &2160470620 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2165008680
46
+ version_requirements: *2160470620
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: daemons
49
- requirement: &2165008180 !ruby/object:Gem::Requirement
49
+ requirement: &2160470120 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - =
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.1.4
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2165008180
57
+ version_requirements: *2160470120
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &2165007700 !ruby/object:Gem::Requirement
60
+ requirement: &2160469700 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2165007700
68
+ version_requirements: *2160469700
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
- requirement: &2165007160 !ruby/object:Gem::Requirement
71
+ requirement: &2160469180 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2165007160
79
+ version_requirements: *2160469180
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: guard
82
- requirement: &2165006660 !ruby/object:Gem::Requirement
82
+ requirement: &2160468740 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2165006660
90
+ version_requirements: *2160468740
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: guard-rspec
93
- requirement: &2165006100 !ruby/object:Gem::Requirement
93
+ requirement: &2160468220 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2165006100
101
+ version_requirements: *2160468220
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rb-fsevent
104
- requirement: &2165005240 !ruby/object:Gem::Requirement
104
+ requirement: &2160467720 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *2165005240
112
+ version_requirements: *2160467720
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: ruby-growl
115
- requirement: &2165004800 !ruby/object:Gem::Requirement
115
+ requirement: &2160467040 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *2165004800
123
+ version_requirements: *2160467040
124
124
  description: Mad Chatter is a fun, easy to customize chat server, utilizing HTML 5
125
125
  Web Sockets
126
126
  email:
@@ -145,15 +145,15 @@ files:
145
145
  - lib/mad_chatter/channel.rb
146
146
  - lib/mad_chatter/config.rb
147
147
  - lib/mad_chatter/daemon.rb
148
- - lib/mad_chatter/extensions.rb
148
+ - lib/mad_chatter/extension.rb
149
149
  - lib/mad_chatter/message.rb
150
150
  - lib/mad_chatter/message_history.rb
151
- - lib/mad_chatter/message_listener.rb
152
151
  - lib/mad_chatter/message_listeners/channel_commands.rb
153
152
  - lib/mad_chatter/message_listeners/code.rb
154
153
  - lib/mad_chatter/message_listeners/image.rb
155
154
  - lib/mad_chatter/message_listeners/markdown.rb
156
155
  - lib/mad_chatter/message_listeners/nick.rb
156
+ - lib/mad_chatter/message_listeners/video.rb
157
157
  - lib/mad_chatter/server.rb
158
158
  - lib/mad_chatter/servers/em_websocket.rb
159
159
  - lib/mad_chatter/user.rb
@@ -167,9 +167,11 @@ files:
167
167
  - spec/message_listeners/code_spec.rb
168
168
  - spec/message_listeners/markdown_spec.rb
169
169
  - spec/message_spec.rb
170
+ - spec/simple_extensions_spec.rb
170
171
  - spec/spec_helper.rb
171
172
  - templates/config.yml
172
173
  - templates/extensions.rb
174
+ - templates/extensions/earthquake.rb
173
175
  - templates/extensions/example.rb
174
176
  - templates/web/css/bootstrap.css
175
177
  - templates/web/css/bootstrap.min.css
@@ -219,4 +221,5 @@ test_files:
219
221
  - spec/message_listeners/code_spec.rb
220
222
  - spec/message_listeners/markdown_spec.rb
221
223
  - spec/message_spec.rb
224
+ - spec/simple_extensions_spec.rb
222
225
  - spec/spec_helper.rb
@@ -1,12 +0,0 @@
1
- module MadChatter
2
- module Extensions
3
-
4
- # include MadChatter::Actions
5
-
6
- # Used for defining simple extensions
7
- def on_message(regex, &block)
8
- MadChatter.message_listeners << MadChatter::MessageListener.new(regex, block)
9
- end
10
-
11
- end
12
- end
@@ -1,17 +0,0 @@
1
- module MadChatter
2
- class MessageListener
3
- include MadChatter::Actions
4
-
5
- def initialize(regex = nil, block = nil)
6
- @regex = regex
7
- @block = block
8
- end
9
-
10
- def handle(message)
11
- if message.original_text =~ @regex
12
- args = @regex.match(message.original_text).captures
13
- @block.call(args)
14
- end
15
- end
16
- end
17
- end