slack-smart-bot 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/slack-smart-bot.rb +14 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dd7ec5a931f45aeef862b601c89dd869edfb317e5e05f47fd997f3c48af0b0f
|
4
|
+
data.tar.gz: b6c6171727919ba7f8200d9ff14f299e19a1d0b07c62263759758ed88ba4f14e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82fded753140cd4b5f1635ed3a22f6f5c156b57e7d93d9b45a1f8f643d8ed92acb5a6c83aabfb005feb753cc73c05e9d6de1c481532f26a851e21ccdb22aa30f
|
7
|
+
data.tar.gz: b81648ea8b9ff046d0a379941acbc6db78823bb1d5c2b3d95a57ed11b77c8a5ada4f398c443cefcf7251dc0ba348c1eebddcab784dddceb74f70b105300641cb
|
data/lib/slack-smart-bot.rb
CHANGED
@@ -79,7 +79,7 @@ class SlackSmartBot
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
# rules imported only for
|
82
|
+
# rules imported only for DM
|
83
83
|
if ON_MASTER_BOT and File.exist?("./rules/rules_imported.rb")
|
84
84
|
file_conf = IO.readlines("./rules/rules_imported.rb").join
|
85
85
|
unless file_conf.to_s() == ""
|
@@ -176,7 +176,7 @@ class SlackSmartBot
|
|
176
176
|
def listen
|
177
177
|
@salutations = [config[:nick], config[:nick_id], "bot", "smart"]
|
178
178
|
client.on :message do |data|
|
179
|
-
if data.channel[0] == "D" or data.channel[0] == "C" #Direct message or Channel
|
179
|
+
if data.channel[0] == "D" or data.channel[0] == "C" or data.channel[0] == "G" #Direct message or Channel or Private Channel
|
180
180
|
dest = data.channel
|
181
181
|
else # not treated
|
182
182
|
dest = nil
|
@@ -184,7 +184,7 @@ class SlackSmartBot
|
|
184
184
|
#todo: sometimes data.user is nil, check the problem.
|
185
185
|
@logger.warn "!dest is nil. user: #{data.user}, channel: #{data.channel}, message: #{data.text}" if dest.nil?
|
186
186
|
# Direct messages are treated only on the master bot
|
187
|
-
if !dest.nil? and ((dest[0] == "D" and ON_MASTER_BOT) or (dest[0] == "C")) and data.user.to_s != ""
|
187
|
+
if !dest.nil? and ((dest[0] == "D" and ON_MASTER_BOT) or (dest[0] == "C" or dest[0] == "G")) and data.user.to_s != ""
|
188
188
|
begin
|
189
189
|
#todo: when changed @questions user_id then move user_info inside the ifs to avoid calling it when not necessary
|
190
190
|
user_info = client.web_client.users_info(user: data.user)
|
@@ -253,7 +253,7 @@ class SlackSmartBot
|
|
253
253
|
nick = user.name
|
254
254
|
rules_file = ''
|
255
255
|
|
256
|
-
if dest[0] == "C" # on a channel
|
256
|
+
if dest[0] == "C" or dest[0] == "G" # on a channel or private channel
|
257
257
|
rules_file = RULES_FILE
|
258
258
|
|
259
259
|
if @rules_imported.key?(user.id) and @rules_imported[user.id].key?(dchannel)
|
@@ -279,7 +279,6 @@ class SlackSmartBot
|
|
279
279
|
end
|
280
280
|
end
|
281
281
|
|
282
|
-
#todo: verify if on slack on anytime nick == config[:nick]
|
283
282
|
if nick == config[:nick] #if message is coming from the bot
|
284
283
|
begin
|
285
284
|
case text
|
@@ -357,7 +356,7 @@ class SlackSmartBot
|
|
357
356
|
#todo: verify this
|
358
357
|
|
359
358
|
|
360
|
-
if dest[0] == "C" #only for channels, not for DM
|
359
|
+
if dest[0] == "C" or dest[0] == "G" #only for channels, not for DM
|
361
360
|
if @rules_imported.key?(user.id) and @rules_imported[user.id].key?(dchannel)
|
362
361
|
if @bots_created.key?(@rules_imported[user.id][dchannel])
|
363
362
|
if @bots_created[@rules_imported[user.id][dchannel]][:status] != :on
|
@@ -447,7 +446,7 @@ class SlackSmartBot
|
|
447
446
|
respond "#{greetings} #{firstname}", dest
|
448
447
|
if @rules_imported.key?(user.id) and @rules_imported[user.id].key?(user.id) and dest[0] == "D"
|
449
448
|
respond "You are using specific rules for channel: <##{@rules_imported[user.id][user.id]}>", dest
|
450
|
-
elsif @rules_imported.key?(user.id) and @rules_imported[user.id].key?(dchannel) and dest[0] == "C"
|
449
|
+
elsif @rules_imported.key?(user.id) and @rules_imported[user.id].key?(dchannel) and (dest[0] == "C" or dest[0] == "G")
|
451
450
|
respond "You are using specific rules for channel: <##{@rules_imported[user.id][dchannel]}>", dest
|
452
451
|
end
|
453
452
|
@listening << from unless @listening.include?(from)
|
@@ -730,7 +729,7 @@ class SlackSmartBot
|
|
730
729
|
else
|
731
730
|
if user.id == channel_found.creator or members.include?(user.id)
|
732
731
|
@rules_imported[user.id] = {} unless @rules_imported.key?(user.id)
|
733
|
-
if dest[0] == "C" #todo: take in consideration bots that are not master
|
732
|
+
if dest[0] == "C" or dest[0] == "G" #todo: take in consideration bots that are not master
|
734
733
|
@rules_imported[user.id][dchannel] = channel_found.id
|
735
734
|
else
|
736
735
|
@rules_imported[user.id][user.id] = channel_found.id
|
@@ -754,7 +753,7 @@ class SlackSmartBot
|
|
754
753
|
else
|
755
754
|
channel_id = channel
|
756
755
|
end
|
757
|
-
if dest[0] == "C" #channel
|
756
|
+
if dest[0] == "C" or dest[0] == "G" #channel
|
758
757
|
if @rules_imported.key?(user.id) and @rules_imported[user.id].key?(dchannel)
|
759
758
|
if @rules_imported[user.id][dchannel] != channel_id
|
760
759
|
respond "You are not using those rules.", dest
|
@@ -797,12 +796,12 @@ class SlackSmartBot
|
|
797
796
|
if ADMIN_USERS.include?(from) #admin user
|
798
797
|
respond "*Commands for administrators:*\n#{help_message.scan(/#\s*help\s*admin:(.*)/).join("\n")}", dest
|
799
798
|
end
|
800
|
-
if ON_MASTER_BOT and dest[0] == "C"
|
799
|
+
if ON_MASTER_BOT and (dest[0] == "C" or dest[0] == "G")
|
801
800
|
respond "*Commands only on Master Channel <##{@channels_id[MASTER_CHANNEL]}>:*\n#{help_message.scan(/#\s*help\s*master:(.*)/).join("\n")}", dest
|
802
801
|
end
|
803
802
|
respond help_message.scan(/#\s*help\s*:(.*)/).join("\n"), dest
|
804
803
|
end
|
805
|
-
if dest[0] == "C" # on a channel
|
804
|
+
if dest[0] == "C" or dest[0] == "G" # on a channel
|
806
805
|
if @rules_imported.key?(user.id) and @rules_imported[user.id].key?(dchannel)
|
807
806
|
if @bots_created.key?(@rules_imported[user.id][dchannel])
|
808
807
|
respond "*You are using rules from another channel: <##{@rules_imported[user.id][dchannel]}>. These are the specific commands for that channel:*", dest
|
@@ -1008,6 +1007,8 @@ class SlackSmartBot
|
|
1008
1007
|
end
|
1009
1008
|
end
|
1010
1009
|
|
1010
|
+
respond "Running", dest if code.size > 100
|
1011
|
+
|
1011
1012
|
begin
|
1012
1013
|
ruby = "ruby -e \"#{code.gsub('"', '\"')}\""
|
1013
1014
|
ruby = ("cd #{project_folder} &&" + ruby) if defined?(project_folder)
|
@@ -1039,7 +1040,7 @@ class SlackSmartBot
|
|
1039
1040
|
def respond(msg, dest = nil)
|
1040
1041
|
if dest.nil?
|
1041
1042
|
client.message(channel: @channels_id[CHANNEL], text: msg, as_user: true)
|
1042
|
-
elsif dest[0] == "C" # channel
|
1043
|
+
elsif dest[0] == "C" or dest[0] == "G" # channel
|
1043
1044
|
client.message(channel: dest, text: msg, as_user: true)
|
1044
1045
|
elsif dest[0] == "D" # Direct message
|
1045
1046
|
send_msg_user(dest, msg)
|
@@ -1053,7 +1054,7 @@ class SlackSmartBot
|
|
1053
1054
|
def ask(question, context, to, dest = nil)
|
1054
1055
|
if dest.nil?
|
1055
1056
|
client.message(channel: @channels_id[CHANNEL], text: "#{to}: #{question}", as_user: true)
|
1056
|
-
elsif dest[0] == "C" # channel
|
1057
|
+
elsif dest[0] == "C" or dest[0] == "G" # channel
|
1057
1058
|
client.message(channel: dest, text: "#{to}: #{question}", as_user: true)
|
1058
1059
|
elsif dest[0] == "D" #private message
|
1059
1060
|
send_msg_user(dest, "#{to}: #{question}")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-smart-bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slack-ruby-client
|