Skip to content

Commit e8b2705

Browse files
feat(slack-bot): add comments
1 parent 97b1e48 commit e8b2705

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
Style/FrozenStringLiteralComment:
2+
Enable: false
3+
Style/FrozenStringLiteralComment:
4+
Enable: false
5+
Naming/FileName:
26
Enable: false

lib/command/slack_command.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
#!/usr/bin/env ruby
12
require 'httparty'
23
require 'nokogiri'
34

45
module JokerTheNerd
56
module Commands
7+
# Slack bot commands
68
class Jokes < SlackRubyBot::Commands::Base
79
command 'jokes_image' do |client, data, _match|
810
client.say(channel: data.channel, text: JokesImage.image_random_joke)
@@ -18,12 +20,14 @@ class Jokes < SlackRubyBot::Commands::Base
1820
end
1921
end
2022

23+
# Say hello class implementation
2124
class HelloText
2225
def self.say_hello
2326
'Heyyy, ready for some humors?'
2427
end
2528
end
2629

30+
# Text based jokes implementation
2731
class JokesText
2832
def self.text_jokes
2933
@text_url = 'https://upjoke.com/programmer-jokes'
@@ -37,6 +41,7 @@ def self.text_random_joke
3741
end
3842
end
3943

44+
# Image based jokes implentation
4045
class JokesImage
4146
def self.image_jokes
4247
@base_url = 'https://www.hongkiat.com/blog/programming-jokes/'

lib/slack-bot.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,22 @@ class SlackBot < SlackRubyBot::Bot
44
title 'Joker The Nerd Bot'
55
desc 'This bot serves you with some programming humors'
66

7-
command :get_all_humors do
8-
title 'get_all_humors'
9-
desc 'Images of humor'
10-
long_desc 'Images of programming humors'
7+
command :say_hello do
8+
title 'Greet the Bot'
9+
desc 'The Bot greets back'
10+
long_desc 'The bot responds with a greeting string'
11+
end
12+
13+
command :jokes_text do
14+
title 'Joke Text'
15+
desc 'Get random Programming Jokes as Text'
16+
long_desc 'The Bot craws and scraps the web, returning a random joke texts'
17+
end
18+
19+
command :jokes_image do
20+
title 'Joke Image'
21+
desc 'Get random Programming Jokes as Image'
22+
long_desc 'The Bot craws and scraps the web, returning a random joke image'
1123
end
1224
end
1325
end

0 commit comments

Comments
 (0)