diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index b018b31..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -### 0.1.0 (Next) - -* Initial public release - [@dblock](https://github.com/dblock). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index e698334..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,139 +0,0 @@ -# Contributing to SlackMathbot - -This project is work of [many contributors](https://github.com/dblock/slack-mathbot/graphs/contributors). - -You're encouraged to submit [pull requests](https://github.com/dblock/slack-mathbot/pulls), [propose features and discuss issues](https://github.com/dblock/slack-mathbot/issues). - -In the examples below, substitute your Github username for `contributor` in URLs. - -## Fork the Project - -Fork the [project on Github](https://github.com/dblock/slack-mathbot) and check out your copy. - -``` -git clone https://github.com/contributor/slack-mathbot.git -cd slack-mathbot -git remote add upstream https://github.com/dblock/slack-mathbot.git -``` - -## Bundle Install and Test - -Ensure that you can build the project and run tests. - -``` -bundle install -bundle exec rake -``` - -## Run SlackMathbot in Development - -Create a private slack group for yourself. - -Create a new Bot Integration under [services/new/bot](http://slack.com/services/new/bot). - -![](screenshots/register-bot.png) - -On the next screen, note the API token. - -Run `SLACK_API_TOKEN= foreman start`. - -You can also create a `.env` file with `SLACK_API_TOKEN=` and just run `foreman start`. - -## Create a Topic Branch - -Make sure your fork is up-to-date and create a topic branch for your feature or bug fix. - -``` -git checkout master -git pull upstream master -git checkout -b my-feature-branch -``` - -## Write Tests - -Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. -Add to [spec](spec). - -We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix. - -## Write Code - -Implement your feature or bug fix. - -Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop). -Run `bundle exec rubocop` and fix any style issues highlighted. - -Make sure that `bundle exec rake` completes without errors. - -## Write Documentation - -Document any external behavior in the [README](README.md). - -## Update Changelog - -Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. -Make it look like every other line, including your name and link to your Github account. - -## Commit Changes - -Make sure git knows your name and email address: - -``` -git config --global user.name "Your Name" -git config --global user.email "contributor@example.com" -``` - -Writing good commit logs is important. A commit log should describe what changed and why. - -``` -git add ... -git commit -``` - -## Push - -``` -git push origin my-feature-branch -``` - -## Make a Pull Request - -Go to https://github.com/contributor/slack-mathbot and select your feature branch. -Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days. - -## Rebase - -If you've been working on a change for a while, rebase with upstream/master. - -``` -git fetch upstream -git rebase upstream/master -git push origin my-feature-branch -f -``` - -## Update CHANGELOG Again - -Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows. - -``` -* [#123](https://github.com/dblock/slack-mathbot/pull/123): Reticulated splines - [@contributor](https://github.com/contributor). -``` - -Amend your previous commit and force push the changes. - -``` -git commit --amend -git push origin my-feature-branch -f -``` - -## Check on Your Pull Request - -Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above. - -## Be Patient - -It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there! - -## Thank You - -Please do know that we really appreciate and value your time and work. We love you, really. diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md deleted file mode 100644 index 7aadeb5..0000000 --- a/DEPLOYMENT.md +++ /dev/null @@ -1,29 +0,0 @@ -## Installation - -Create a new Bot Integration under [services/new/bot](http://slack.com/services/new/bot). - -![](screenshots/register-bot.png) - -On the next screen, note the API token. - -## Deploy Slack-Mathbot - -[![Deploy to Heroku](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy) - -### Environment - -#### SLACK_API_TOKEN - -Set SLACK_API_TOKEN from the Bot integration settings on Slack. - -``` -heroku config:add SLACK_API_TOKEN=... -``` - -#### GIPHY_API_KEY - -Slack-Mathbot replies with animated GIFs. While it's currently not necessary, you may need to set GIPHY_API_KEY in the future, see [github.com/Giphy/GiphyAPI](https://github.com/Giphy/GiphyAPI) for details. - -### Heroku Idling - -Heroku free tier applications will idle. Either pay 7$ a month for the hobby dyno or use [UptimeRobot](http://uptimerobot.com) or similar to prevent your instance from sleeping or pay for a production dyno. diff --git a/Gemfile b/Gemfile index a1f9a13..7c71e52 100644 --- a/Gemfile +++ b/Gemfile @@ -1,21 +1,4 @@ source 'http://rubygems.org' -ruby '2.2.3' - gem 'slack-ruby-bot' -gem 'puma' -gem 'sinatra' -gem 'dentaku' - -group :development, :test do - gem 'rake', '~> 10.4' - gem 'rubocop', '0.31.0' - gem 'foreman' -end - -group :test do - gem 'rspec' - gem 'rack-test' - gem 'vcr' - gem 'webmock' -end +gem 'wolfram' diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index dd3c8d8..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,119 +0,0 @@ -GEM - remote: http://rubygems.org/ - specs: - activesupport (4.2.3) - i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - addressable (2.3.8) - ast (2.0.0) - astrolabe (1.3.1) - parser (~> 2.2) - crack (0.4.2) - safe_yaml (~> 1.0.0) - dentaku (1.2.6) - diff-lcs (1.2.5) - eventmachine (1.0.7) - faraday (0.9.1) - multipart-post (>= 1.2, < 3) - faraday_middleware (0.9.2) - faraday (>= 0.7.4, < 0.10) - faraday_middleware-parse_oj (0.3.0) - faraday (~> 0.9.0) - faraday_middleware (~> 0.9.1) - oj (~> 2.0) - faye-websocket (0.10.0) - eventmachine (>= 0.12.0) - websocket-driver (>= 0.5.1) - foreman (0.78.0) - thor (~> 0.19.1) - giphy (2.0.2) - faraday (~> 0.9) - faraday_middleware (~> 0.9) - faraday_middleware-parse_oj (~> 0.3) - launchy (~> 2.4) - hashie (3.4.2) - i18n (0.7.0) - json (1.8.3) - launchy (2.4.3) - addressable (~> 2.3) - minitest (5.7.0) - multipart-post (2.0.0) - oj (2.12.10) - parser (2.2.2.6) - ast (>= 1.1, < 3.0) - powerpack (0.1.1) - puma (2.12.2) - rack (1.6.4) - rack-protection (1.5.3) - rack - rack-test (0.6.3) - rack (>= 1.0) - rainbow (2.0.0) - rake (10.4.2) - rspec (3.3.0) - rspec-core (~> 3.3.0) - rspec-expectations (~> 3.3.0) - rspec-mocks (~> 3.3.0) - rspec-core (3.3.2) - rspec-support (~> 3.3.0) - rspec-expectations (3.3.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.3.0) - rspec-mocks (3.3.2) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.3.0) - rspec-support (3.3.0) - rubocop (0.31.0) - astrolabe (~> 1.3) - parser (>= 2.2.2.1, < 3.0) - powerpack (~> 0.1) - rainbow (>= 1.99.1, < 3.0) - ruby-progressbar (~> 1.4) - ruby-progressbar (1.7.5) - safe_yaml (1.0.4) - sinatra (1.4.6) - rack (~> 1.4) - rack-protection (~> 1.4) - tilt (>= 1.3, < 3) - slack-ruby-bot (0.4.0) - activesupport - giphy (~> 2.0.2) - hashie - slack-ruby-client - websocket-driver (~> 0.5.4) - slack-ruby-client (0.1.0) - eventmachine - faraday - faraday_middleware - faye-websocket - thor (0.19.1) - thread_safe (0.3.5) - tilt (2.0.1) - tzinfo (1.2.2) - thread_safe (~> 0.1) - vcr (2.9.3) - webmock (1.21.0) - addressable (>= 2.3.6) - crack (>= 0.3.2) - websocket-driver (0.5.4) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.2) - -PLATFORMS - ruby - -DEPENDENCIES - dentaku - foreman - puma - rack-test - rake (~> 10.4) - rspec - rubocop (= 0.31.0) - sinatra - slack-ruby-bot - vcr - webmock diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 81ae90d..0000000 --- a/LICENSE.md +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2015 Daniel Doubrovkine, Artsy and Contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Procfile b/Procfile index 4fd3163..d94f69e 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: bundle exec puma -p $PORT +console: bundle exec ruby numberman.rb diff --git a/README.md b/README.md deleted file mode 100644 index 56d3154..0000000 --- a/README.md +++ /dev/null @@ -1,46 +0,0 @@ -Slack-Mathbot -============= - -[![Build Status](https://travis-ci.org/dblock/slack-mathbot.png)](https://travis-ci.org/dblock/slack-mathbot) - -A math bot for Slack. Math is good for you. - -![](screenshots/two-plus-two.gif) - -## Installation - -See [DEPLOYMENT](DEPLOYMENT.md). - -## Usage - -Invite your bot to a channel. Do math by starting a message with an equal sign. - -![](screenshots/example.gif) - -### Commands - -#### mathbot calculate [expression] - -Calculates an expression, currently just basic math. See [Dentaku](https://github.com/rubysolo/dentaku) for what's supported. - -#### mathbot - -Shows MathBot version and links. - -#### mathbot hi - -Politely says 'hi' back. - -#### mathbot help - -Get help. - -## Contributing - -See [CONTRIBUTING](CONTRIBUTING.md). - -## Copyright and License - -Copyright (c) 2015, Daniel Doubrovkine, Artsy and [Contributors](CHANGELOG.md). - -This project is licensed under the [MIT License](LICENSE.md). diff --git a/Rakefile b/Rakefile deleted file mode 100644 index 32f34c9..0000000 --- a/Rakefile +++ /dev/null @@ -1,18 +0,0 @@ -require 'rubygems' -require 'bundler' - -Bundler.setup :default, :development - -unless ENV['RACK_ENV'] == 'production' - require 'rspec/core' - require 'rspec/core/rake_task' - - RSpec::Core::RakeTask.new(:spec) do |spec| - spec.pattern = FileList['spec/**/*_spec.rb'] - end - - require 'rubocop/rake_task' - RuboCop::RakeTask.new - - task default: [:rubocop, :spec] -end diff --git a/app.json b/app.json deleted file mode 100644 index 26085b2..0000000 --- a/app.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "Math bot for Slack", - "description": "Slack integration with math.", - "respository": "https://github.com/dblock/slack-mathbot", - "keywords": ["slack", "integration", "math"], -} diff --git a/config.ru b/config.ru deleted file mode 100644 index bda0adb..0000000 --- a/config.ru +++ /dev/null @@ -1,16 +0,0 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__)) - -require 'slack-mathbot' -require 'web' - -Thread.new do - begin - SlackMathbot::App.instance.run - rescue Exception => e - STDERR.puts "ERROR: #{e}" - STDERR.puts e.backtrace - raise e - end -end - -run SlackMathbot::Web diff --git a/slack-mathbot/commands/calculate.rb b/numberman.rb similarity index 67% rename from slack-mathbot/commands/calculate.rb rename to numberman.rb index e800029..5c4ddc4 100644 --- a/slack-mathbot/commands/calculate.rb +++ b/numberman.rb @@ -1,9 +1,10 @@ -module SlackMathbot - module Commands - class Calculate < SlackRubyBot::Commands::Base +require 'slack-ruby-bot' +require 'wolfram' + +module NumberManBot + class App < SlackRubyBot::App operator '=' command 'calculate' - def self.call(client, data, match) puts match[:expression] result = Dentaku::Calculator.new.evaluate(match[:expression]) @@ -17,6 +18,13 @@ module SlackMathbot rescue StandardError => e send_message client, data.channel, "Sorry, #{e.message}." end + end + + class Ping < SlackRubyBot::Commands::Base + def self.call(client, data, _match) + client.message text: 'pong', channel: data.channel end end end + +NumberManBot::App.instance.run diff --git a/screenshots/example.gif b/screenshots/example.gif deleted file mode 100644 index 5698c67..0000000 Binary files a/screenshots/example.gif and /dev/null differ diff --git a/screenshots/register-bot.png b/screenshots/register-bot.png deleted file mode 100644 index 391a201..0000000 Binary files a/screenshots/register-bot.png and /dev/null differ diff --git a/screenshots/two-plus-two.gif b/screenshots/two-plus-two.gif deleted file mode 100644 index b95dbe0..0000000 Binary files a/screenshots/two-plus-two.gif and /dev/null differ diff --git a/slack-mathbot.rb b/slack-mathbot.rb deleted file mode 100644 index a13c570..0000000 --- a/slack-mathbot.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'slack-ruby-bot' -require 'slack-mathbot/version' -require 'slack-mathbot/about' -require 'slack-mathbot/commands' -require 'slack-mathbot/app' diff --git a/slack-mathbot/about.rb b/slack-mathbot/about.rb deleted file mode 100644 index 9401cdb..0000000 --- a/slack-mathbot/about.rb +++ /dev/null @@ -1,7 +0,0 @@ -module SlackMathbot - ABOUT = <<-ABOUT - #{SlackMathbot::VERSION} - https://github.com/dblock/slack-mathbot - https://twitter.com/dblockdotorg - ABOUT -end diff --git a/slack-mathbot/app.rb b/slack-mathbot/app.rb deleted file mode 100644 index 068a8f5..0000000 --- a/slack-mathbot/app.rb +++ /dev/null @@ -1,4 +0,0 @@ -module SlackMathbot - class App < SlackRubyBot::App - end -end diff --git a/slack-mathbot/commands.rb b/slack-mathbot/commands.rb deleted file mode 100644 index 73a2f68..0000000 --- a/slack-mathbot/commands.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'slack-mathbot/commands/calculate' -require 'slack-mathbot/commands/echo' -require 'slack-mathbot/commands/about' -require 'slack-mathbot/commands/help' diff --git a/slack-mathbot/commands/about.rb b/slack-mathbot/commands/about.rb deleted file mode 100644 index ebb997a..0000000 --- a/slack-mathbot/commands/about.rb +++ /dev/null @@ -1,11 +0,0 @@ -module SlackMathbot - module Commands - class Default < SlackRubyBot::Commands::Base - match(/^(?\w*)$/) - - def self.call(client, data, _match) - send_message client, data.channel, SlackMathbot::ABOUT - end - end - end -end diff --git a/slack-mathbot/commands/echo.rb b/slack-mathbot/commands/echo.rb deleted file mode 100644 index acb4f77..0000000 --- a/slack-mathbot/commands/echo.rb +++ /dev/null @@ -1,13 +0,0 @@ -module SlackMathbot - module Commands - class Echo < SlackRubyBot::Commands::Base - command 'echo' - - def self.call(client, data, match) - send_message client, data.channel, match[:expression] - rescue StandardError => e - send_message client, data.channel, "Sorry, #{e.message}." - end - end - end -end diff --git a/slack-mathbot/commands/help.rb b/slack-mathbot/commands/help.rb deleted file mode 100644 index 6ed20c5..0000000 --- a/slack-mathbot/commands/help.rb +++ /dev/null @@ -1,9 +0,0 @@ -module SlackMathbot - module Commands - class Help < SlackRubyBot::Commands::Base - def self.call(client, data, _match) - send_message client, data.channel, 'See https://github.com/dblock/slack-mathbot, please.' - end - end - end -end diff --git a/slack-mathbot/version.rb b/slack-mathbot/version.rb deleted file mode 100644 index ec90e43..0000000 --- a/slack-mathbot/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module SlackMathbot - VERSION = '0.1.0' -end diff --git a/spec/slack-mathbot/app_spec.rb b/spec/slack-mathbot/app_spec.rb deleted file mode 100644 index f6f8b11..0000000 --- a/spec/slack-mathbot/app_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'spec_helper' - -describe SlackMathbot::App do - def app - SlackMathbot::App.new - end - it_behaves_like 'a slack ruby bot' -end diff --git a/spec/slack-mathbot/commands/about_spec.rb b/spec/slack-mathbot/commands/about_spec.rb deleted file mode 100644 index c17dcc9..0000000 --- a/spec/slack-mathbot/commands/about_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'spec_helper' - -describe SlackMathbot::Commands::Default do - def app - SlackMathbot::App.new - end - it 'mathbot' do - expect(message: 'mathbot').to respond_with_slack_message(SlackMathbot::ABOUT) - end - it 'Mathbot' do - expect(message: 'Mathbot').to respond_with_slack_message(SlackMathbot::ABOUT) - end -end diff --git a/spec/slack-mathbot/commands/calculate_spec.rb b/spec/slack-mathbot/commands/calculate_spec.rb deleted file mode 100644 index 3a53fee..0000000 --- a/spec/slack-mathbot/commands/calculate_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -describe SlackMathbot::Commands::Calculate do - def app - SlackMathbot::App.new - end - it 'adds two numbers' do - expect(message: 'mathbot calculate 2+2', channel: 'channel').to respond_with_slack_message('4') - end - it 'adds two numbers via =' do - expect(message: '= 2+2', channel: 'channel').to respond_with_slack_message('4') - end - it 'adds two numbers via = without a space' do - expect(message: '=2+2', channel: 'channel').to respond_with_slack_message('4') - end - it 'sends something without an answer' do - expect(message: 'mathbot calculate pi', channel: 'channel').to respond_with_slack_message('Got nothing.') - end - it 'reports division by zero' do - expect(message: 'mathbot calculate 1/0', channel: 'channel').to respond_with_slack_message('Sorry, divided by 0.') - end -end diff --git a/spec/slack-mathbot/commands/help_spec.rb b/spec/slack-mathbot/commands/help_spec.rb deleted file mode 100644 index 36c635b..0000000 --- a/spec/slack-mathbot/commands/help_spec.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'spec_helper' - -describe SlackMathbot::Commands::Help do - def app - SlackMathbot::App.new - end - it 'help' do - expect(message: 'mathbot help').to respond_with_slack_message('See https://github.com/dblock/slack-mathbot, please.') - end -end diff --git a/spec/slack-mathbot/commands/hi_spec.rb b/spec/slack-mathbot/commands/hi_spec.rb deleted file mode 100644 index 897610d..0000000 --- a/spec/slack-mathbot/commands/hi_spec.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'spec_helper' - -describe SlackRubyBot::Commands::Hi do - def app - SlackMathbot::App.new - end - it 'says hi' do - expect(message: 'mathbot hi').to respond_with_slack_message('Hi <@user>!') - end -end diff --git a/spec/slack-mathbot/commands/unknown_spec.rb b/spec/slack-mathbot/commands/unknown_spec.rb deleted file mode 100644 index 56e1d52..0000000 --- a/spec/slack-mathbot/commands/unknown_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe SlackRubyBot::Commands::Unknown do - def app - SlackMathbot::App.new - end - let(:client) { app.send(:client) } - it 'invalid command' do - expect(message: 'mathbot foobar').to respond_with_slack_message("Sorry <@user>, I don't understand that command!") - end - it 'does not respond to sad face' do - expect(SlackRubyBot::Commands::Base).to_not receive(:send_message) - SlackMathbot::App.new.send(:message, client, text: ':((') - end -end diff --git a/spec/slack-mathbot/version_spec.rb b/spec/slack-mathbot/version_spec.rb deleted file mode 100644 index 754c246..0000000 --- a/spec/slack-mathbot/version_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'spec_helper' - -describe SlackMathbot do - it 'has a version' do - expect(SlackMathbot::VERSION).to_not be nil - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb deleted file mode 100644 index f878dc6..0000000 --- a/spec/spec_helper.rb +++ /dev/null @@ -1,9 +0,0 @@ -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..')) - -require 'slack-ruby-bot/rspec' - -Dir[File.join(File.dirname(__FILE__), 'support', '**/*.rb')].each do |file| - require file -end - -require 'slack-mathbot' diff --git a/spec/support/slack_mathbot.rb b/spec/support/slack_mathbot.rb deleted file mode 100644 index e1bf327..0000000 --- a/spec/support/slack_mathbot.rb +++ /dev/null @@ -1,5 +0,0 @@ -RSpec.configure do |config| - config.before do - SlackRubyBot.config.user = 'mathbot' - end -end diff --git a/web.rb b/web.rb deleted file mode 100644 index 70d9d1d..0000000 --- a/web.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'sinatra/base' - -module SlackMathbot - class Web < Sinatra::Base - get '/' do - 'Math is good for you.' - end - end -end