Skip to content

Commit d1f7e43

Browse files
Merge pull request #2 from oxenprogrammer/feat/slack-bot
Feat/slack bot
2 parents a6ae5fe + 7d1ebec commit d1f7e43

24 files changed

+445
-75
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SLACK_API_TOKEN=

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ build-iPhoneSimulator/
5454

5555
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
5656
# .rubocop-https?--*
57+
58+
# the .env file
59+
.env

.rspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
--require spec_helper
2+
--format documentation

.rubocop.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Style/FrozenStringLiteralComment:
2+
Enabled: false
3+
Style/FrozenStringLiteralComment:
4+
Enabled: false
5+
Naming/FileName:
6+
Enabled: false
7+
Layout/LineLength:
8+
Max: 120
9+
Style/BlockComments:
10+
Enabled: false

Gemfile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
source 'https://rubygems.org'
22
gem 'celluloid-io'
3-
gem 'slack-ruby-bot-server-events'
3+
gem 'slack-ruby-bot'
44

5+
gem 'async-websocket', '~> 0.8.0'
6+
gem 'dotenv'
7+
gem 'foreman'
8+
gem 'httparty'
9+
gem 'nokogiri'
10+
gem 'puma'
11+
gem 'rack'
12+
gem 'rack-test'
13+
gem 'rake'
514
gem 'rspec'
15+
gem 'rubocop-rspec', require: false
616
gem 'simplecov', require: false, group: :test
17+
gem 'slack-ruby-client'

Gemfile.lock

Lines changed: 62 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ GEM
77
minitest (>= 5.1)
88
tzinfo (~> 2.0)
99
zeitwerk (~> 2.3)
10+
ast (2.4.2)
1011
async (1.28.5)
1112
console (~> 1.10)
1213
nio4r (~> 2.3)
1314
timers (~> 4.1)
14-
builder (3.2.4)
15+
async-io (1.30.1)
16+
async (~> 1.14)
17+
async-websocket (0.8.0)
18+
async-io
19+
websocket-driver (~> 0.7.0)
1520
celluloid (0.18.0)
1621
timers (~> 4)
1722
celluloid-io (0.17.3)
@@ -21,28 +26,9 @@ GEM
2126
concurrent-ruby (1.1.8)
2227
console (1.10.1)
2328
fiber-local
24-
declarative (0.0.20)
25-
declarative-option (0.1.0)
2629
diff-lcs (1.4.4)
2730
docile (1.3.5)
28-
dry-configurable (0.12.0)
29-
concurrent-ruby (~> 1.0)
30-
dry-core (~> 0.5, >= 0.5.0)
31-
dry-container (0.7.2)
32-
concurrent-ruby (~> 1.0)
33-
dry-configurable (~> 0.1, >= 0.1.3)
34-
dry-core (0.5.0)
35-
concurrent-ruby (~> 1.0)
36-
dry-inflector (0.2.0)
37-
dry-logic (1.1.0)
38-
concurrent-ruby (~> 1.0)
39-
dry-core (~> 0.5, >= 0.5)
40-
dry-types (1.5.0)
41-
concurrent-ruby (~> 1.0)
42-
dry-container (~> 0.3)
43-
dry-core (~> 0.5, >= 0.5)
44-
dry-inflector (~> 0.1, >= 0.1.2)
45-
dry-logic (~> 1.0, >= 1.0.2)
31+
dotenv (2.7.6)
4632
faraday (1.3.0)
4733
faraday-net_http (~> 1.0)
4834
multipart-post (>= 1.2, < 3)
@@ -53,48 +39,34 @@ GEM
5339
fiber-local (1.0.0)
5440
foreman (0.87.2)
5541
gli (2.19.2)
56-
grape (1.5.1)
57-
activesupport
58-
builder
59-
dry-types (>= 1.1)
60-
mustermann-grape (~> 1.0.0)
61-
rack (>= 1.3.0)
62-
rack-accept
63-
grape-roar (0.4.1)
64-
grape
65-
multi_json
66-
roar (~> 1.1.0)
67-
grape-swagger (1.3.1)
68-
grape (~> 1.3)
6942
hashie (4.1.0)
43+
httparty (0.18.1)
44+
mime-types (~> 3.0)
45+
multi_xml (>= 0.5.2)
7046
i18n (1.8.7)
7147
concurrent-ruby (~> 1.0)
72-
kaminari-core (1.2.1)
73-
kaminari-grape (1.0.1)
74-
grape
75-
kaminari-core (~> 1.0)
48+
mime-types (3.3.1)
49+
mime-types-data (~> 3.2015)
50+
mime-types-data (3.2020.1104)
7651
minitest (5.14.3)
77-
multi_json (1.15.0)
52+
multi_xml (0.6.0)
7853
multipart-post (2.1.1)
79-
mustermann (1.1.1)
80-
ruby2_keywords (~> 0.0.1)
81-
mustermann-grape (1.0.1)
82-
mustermann (>= 1.0.0)
8354
nio4r (2.5.4)
55+
nokogiri (1.11.1-x86_64-linux)
56+
racc (~> 1.4)
57+
parallel (1.20.1)
58+
parser (3.0.0.0)
59+
ast (~> 2.4.1)
60+
puma (5.2.0)
61+
nio4r (~> 2.0)
62+
racc (1.5.2)
8463
rack (2.2.3)
85-
rack-accept (0.4.5)
86-
rack (>= 0.4)
87-
rack-cors (1.1.1)
88-
rack (>= 2.0.0)
89-
rack-rewrite (1.5.1)
90-
rack-server-pages (0.1.0)
91-
rack
92-
representable (3.0.4)
93-
declarative (< 0.1.0)
94-
declarative-option (< 0.2.0)
95-
uber (< 0.2.0)
96-
roar (1.1.0)
97-
representable (~> 3.0.0)
64+
rack-test (1.1.0)
65+
rack (>= 1.0, < 3)
66+
rainbow (3.0.0)
67+
rake (13.0.3)
68+
regexp_parser (2.0.3)
69+
rexml (3.2.4)
9870
rspec (3.10.0)
9971
rspec-core (~> 3.10.0)
10072
rspec-expectations (~> 3.10.0)
@@ -104,30 +76,36 @@ GEM
10476
rspec-expectations (3.10.1)
10577
diff-lcs (>= 1.2.0, < 2.0)
10678
rspec-support (~> 3.10.0)
107-
rspec-mocks (3.10.1)
79+
rspec-mocks (3.10.2)
10880
diff-lcs (>= 1.2.0, < 2.0)
10981
rspec-support (~> 3.10.0)
110-
rspec-support (3.10.1)
82+
rspec-support (3.10.2)
83+
rubocop (1.9.1)
84+
parallel (~> 1.10)
85+
parser (>= 3.0.0.0)
86+
rainbow (>= 2.2.2, < 4.0)
87+
regexp_parser (>= 1.8, < 3.0)
88+
rexml
89+
rubocop-ast (>= 1.2.0, < 2.0)
90+
ruby-progressbar (~> 1.7)
91+
unicode-display_width (>= 1.4.0, < 3.0)
92+
rubocop-ast (1.4.1)
93+
parser (>= 2.7.1.5)
94+
rubocop-rspec (2.1.0)
95+
rubocop (~> 1.0)
96+
rubocop-ast (>= 1.1.0)
97+
ruby-progressbar (1.11.0)
11198
ruby2_keywords (0.0.4)
11299
simplecov (0.21.2)
113100
docile (~> 1.1)
114101
simplecov-html (~> 0.11)
115102
simplecov_json_formatter (~> 0.1)
116103
simplecov-html (0.12.3)
117104
simplecov_json_formatter (0.1.2)
118-
slack-ruby-bot-server (1.2.0)
119-
async
120-
foreman
121-
grape
122-
grape-roar (>= 0.4.0)
123-
grape-swagger
124-
kaminari-grape
125-
rack-cors
126-
rack-rewrite
127-
rack-server-pages
128-
slack-ruby-client
129-
slack-ruby-bot-server-events (0.3.0)
130-
slack-ruby-bot-server (>= 1.2.0)
105+
slack-ruby-bot (0.16.1)
106+
activesupport
107+
hashie
108+
slack-ruby-client (>= 0.14.0)
131109
slack-ruby-client (0.16.0)
132110
faraday (>= 1.0)
133111
faraday_middleware
@@ -137,7 +115,7 @@ GEM
137115
timers (4.3.2)
138116
tzinfo (2.0.4)
139117
concurrent-ruby (~> 1.0)
140-
uber (0.1.0)
118+
unicode-display_width (2.0.0)
141119
websocket-driver (0.7.3)
142120
websocket-extensions (>= 0.1.0)
143121
websocket-extensions (0.1.5)
@@ -147,10 +125,21 @@ PLATFORMS
147125
x86_64-linux
148126

149127
DEPENDENCIES
128+
async-websocket (~> 0.8.0)
150129
celluloid-io
130+
dotenv
131+
foreman
132+
httparty
133+
nokogiri
134+
puma
135+
rack
136+
rack-test
137+
rake
151138
rspec
139+
rubocop-rspec
152140
simplecov
153-
slack-ruby-bot-server-events
141+
slack-ruby-bot
142+
slack-ruby-client
154143

155144
BUNDLED WITH
156145
2.2.5

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: bundle exec rackup

README.md

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,78 @@
1-
# nerd-bot
1+
![](https://img.shields.io/badge/Microverse-blueviolet)
2+
3+
# Capstone Project: Ruby: Slack Bot
4+
> nerd-bot is a bot built with the goal to automate jokes and humor mainly popular within the developers community. Most times
5+
we developers/programmers get tired writing code and since https://www.slack.com is where most of our interaction occurs, it's not uncommon to just chat with a bot cracking jokes as your teammates might still be busy, nice right?
6+
Nerd-bot scraps the web and returns you random jokes in form of images or text given the right commands in slack.
7+
8+
## Screenshot
9+
![screenshot](./nerd-bot.png)
10+
11+
## Built With
12+
- [Ruby](https://www.ruby-lang.org/en/)
13+
- [Gems](https://rubygems.org/)
14+
- [slack-ruby-bot](https://github.com/slack-ruby/slack-ruby-bot)
15+
- [Nokogiri](https://nokogiri.org/)
16+
- [HTTParty](https://github.com/jnunemaker/httparty)
17+
- [Rspec](https://rspec.info/)
18+
- Plus other dependencies, checkout the `Gemfile`
19+
20+
## Getting Started
21+
### Slack Workspace
22+
- You will need to create a new slackwork space
23+
- Head over to http://slack.com/services/new/bot
24+
- Give your bot a name
25+
- Configure it as you desire and save integration
26+
- Save the SLACK_API_TOKEN string that starts with `xoxb`, you will need it later
27+
- Head over to slack and you will see your bot
28+
### Ruby Project
29+
- Clone this project locally
30+
- Run `git checkout feat/slack-bot` in the terminal
31+
- Run `bundle` to install `Gems` and their dependencies.
32+
- Create a `.env` file and paste your earlier saved SLACK_API_KEY
33+
- Check the `.env.example` file on how to do it
34+
- Run `bundle exec rackup` to start it the server
35+
- Your bot should be working by now
36+
37+
### Running Test
38+
- Test have been built using `Rspec` as Test Runner and Fixture
39+
- Test Coverage by `SimpleCov`
40+
- Run `rspec` to run the test
41+
- On windows run `open coverage/index.html` for code coverage
42+
- On unix based systems run `xdg-open coverage/index.html` for code coverage
43+
44+
### Testing on Slack
45+
- The bot can be invited into other workspace or direct messaged
46+
- Use `@bot_username jokes_image` to get programming jokes as images where `@bot_username` is the name of your bot
47+
- Use `@bot_username jokes_text` to get programming jokes as texts
48+
- Use `@bot_username say_hello` to greet the bot
49+
- The `@bot_username` is optional while talking in a Direct message with the bot
50+
- Type `@bot_username` `help` for the above commands
51+
- Enjoy
52+
53+
54+
## Author
55+
56+
👤 **Emmanuel Okello**
57+
58+
- GitHub: [@oxenprogrammer](https://github.com/oxenprogrammer)
59+
- Twitter: [@ox_emmy](https://twitter.com/ox_emmy)
60+
- LinkedIn: [LinkedIn](https://www.linkedin.com/in/emanuel-okello-1217b4b3/)
61+
62+
## 🤝 Contributing
63+
64+
Contributions, issues, and feature requests are welcome!
65+
66+
## Acknowledgments
67+
68+
- ![](https://img.shields.io/badge/Microverse-blueviolet)
69+
70+
- https://github.com/slack-ruby/slack-ruby-bot
71+
72+
## Show your support
73+
74+
Give a ⭐️ if you like this project!
75+
76+
## 📝 License
77+
78+
This project is [MIT](https://opensource.org/licenses/MIT) licensed.

bin/bot.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'slack-ruby-bot'
4+
require_relative './../lib/command/slack_command'
5+
require_relative './../lib/slack_bot'

config.ru

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
$LOAD_PATH.unshift(File.dirname(__FILE__))
2+
3+
require 'dotenv'
4+
Dotenv.load
5+
6+
require_relative './bin/bot'
7+
8+
Joker::Slack.run

0 commit comments

Comments
 (0)