slack-smart-bot 1.13.2 → 1.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +142 -69
  3. data/lib/slack/smart-bot/ai/open_ai/connect.rb +61 -0
  4. data/lib/slack/smart-bot/ai/open_ai/models.rb +21 -0
  5. data/lib/slack/smart-bot/ai/open_ai/send_gpt_chat.rb +24 -0
  6. data/lib/slack/smart-bot/ai/open_ai/send_image_edit.rb +23 -0
  7. data/lib/slack/smart-bot/ai/open_ai/send_image_generation.rb +18 -0
  8. data/lib/slack/smart-bot/ai/open_ai/send_image_variation.rb +22 -0
  9. data/lib/slack/smart-bot/ai/open_ai/whisper_transcribe.rb +21 -0
  10. data/lib/slack/smart-bot/ai.rb +8 -0
  11. data/lib/slack/smart-bot/comm/get_channel_members.rb +15 -13
  12. data/lib/slack/smart-bot/comm/get_channels.rb +31 -29
  13. data/lib/slack/smart-bot/comm/respond_thread.rb +2 -2
  14. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat.rb +40 -0
  15. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_edit_image.rb +66 -0
  16. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_generate_image.rb +65 -0
  17. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_models.rb +37 -0
  18. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_variations_image.rb +84 -0
  19. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_whisper.rb +51 -0
  20. data/lib/slack/smart-bot/commands/general/bot_help.rb +1 -0
  21. data/lib/slack/smart-bot/commands/general/personal_settings.rb +38 -0
  22. data/lib/slack/smart-bot/commands/general/poster.rb +107 -104
  23. data/lib/slack/smart-bot/commands/general/public_holidays.rb +116 -114
  24. data/lib/slack/smart-bot/commands/general/set_public_holidays.rb +6 -2
  25. data/lib/slack/smart-bot/commands/general/teams/add_team.rb +87 -0
  26. data/lib/slack/smart-bot/commands/general/teams/delete_team.rb +69 -0
  27. data/lib/slack/smart-bot/commands/general/teams/memos/add_memo_team.rb +136 -0
  28. data/lib/slack/smart-bot/commands/general/teams/memos/add_memo_team_comment.rb +37 -0
  29. data/lib/slack/smart-bot/commands/general/teams/memos/delete_memo_team.rb +83 -0
  30. data/lib/slack/smart-bot/commands/general/teams/memos/see_memo_team.rb +97 -0
  31. data/lib/slack/smart-bot/commands/general/teams/memos/see_memos_team.rb +304 -0
  32. data/lib/slack/smart-bot/commands/general/teams/memos/set_memo_status.rb +66 -0
  33. data/lib/slack/smart-bot/commands/general/teams/ping_team.rb +104 -0
  34. data/lib/slack/smart-bot/commands/general/teams/see_teams.rb +236 -0
  35. data/lib/slack/smart-bot/commands/general/teams/see_vacations_team.rb +183 -0
  36. data/lib/slack/smart-bot/commands/general/teams/update_team.rb +137 -0
  37. data/lib/slack/smart-bot/commands/general_bot_commands.rb +905 -741
  38. data/lib/slack/smart-bot/commands/on_bot/add_shortcut.rb +1 -0
  39. data/lib/slack/smart-bot/commands/on_bot/delete_shortcut.rb +2 -2
  40. data/lib/slack/smart-bot/commands/on_bot/general/bot_stats.rb +379 -353
  41. data/lib/slack/smart-bot/commands/on_bot/repl.rb +6 -107
  42. data/lib/slack/smart-bot/commands/on_bot/repl_client.rb +233 -0
  43. data/lib/slack/smart-bot/commands/on_master/admin_master/exit_bot.rb +17 -4
  44. data/lib/slack/smart-bot/commands.rb +26 -10
  45. data/lib/slack/smart-bot/process.rb +14 -3
  46. data/lib/slack/smart-bot/process_first.rb +36 -2
  47. data/lib/slack/smart-bot/treat_message.rb +28 -0
  48. data/lib/slack/smart-bot/utils/check_vacations.rb +1 -0
  49. data/lib/slack/smart-bot/utils/create_routine_thread.rb +1 -1
  50. data/lib/slack/smart-bot/utils/display_calendar.rb +17 -10
  51. data/lib/slack/smart-bot/utils/encryption/decrypt.rb +23 -0
  52. data/lib/slack/smart-bot/utils/encryption/encrypt.rb +27 -0
  53. data/lib/slack/smart-bot/utils/{encryption_get_key_iv.rb → encryption/encryption_get_key_iv.rb} +12 -8
  54. data/lib/slack/smart-bot/utils/get_help.rb +3 -1
  55. data/lib/slack/smart-bot/utils/get_personal_settings.rb +14 -0
  56. data/lib/slack/smart-bot/utils/get_teams.rb +2 -2
  57. data/lib/slack/smart-bot/utils/get_vacations.rb +2 -2
  58. data/lib/slack/smart-bot/utils/save_stats.rb +3 -1
  59. data/lib/slack/smart-bot/utils/update_personal_settings.rb +18 -0
  60. data/lib/slack/smart-bot/utils/update_teams.rb +1 -1
  61. data/lib/slack/smart-bot/utils/update_vacations.rb +1 -1
  62. data/lib/slack/smart-bot/utils.rb +5 -3
  63. data/lib/slack-smart-bot.rb +12 -0
  64. data/whats_new.txt +13 -14
  65. metadata +63 -15
  66. data/lib/slack/smart-bot/commands/general/add_memo_team.rb +0 -117
  67. data/lib/slack/smart-bot/commands/general/add_team.rb +0 -81
  68. data/lib/slack/smart-bot/commands/general/delete_memo_team.rb +0 -69
  69. data/lib/slack/smart-bot/commands/general/delete_team.rb +0 -55
  70. data/lib/slack/smart-bot/commands/general/ping_team.rb +0 -100
  71. data/lib/slack/smart-bot/commands/general/see_memos_team.rb +0 -202
  72. data/lib/slack/smart-bot/commands/general/see_teams.rb +0 -230
  73. data/lib/slack/smart-bot/commands/general/see_vacations_team.rb +0 -136
  74. data/lib/slack/smart-bot/commands/general/set_memo_status.rb +0 -58
  75. data/lib/slack/smart-bot/commands/general/update_team.rb +0 -131
  76. data/lib/slack/smart-bot/utils/decrypt.rb +0 -15
  77. data/lib/slack/smart-bot/utils/encrypt.rb +0 -15
@@ -1,15 +1,18 @@
1
1
  class SlackSmartBot
2
- def display_calendar(from_user_name, year)
2
+ def display_calendar(from_user_name, year, country_region: '')
3
3
  if @vacations.key?(from_user_name) and @vacations[from_user_name][:public_holidays].to_s != ""
4
4
  country_region = @vacations[from_user_name][:public_holidays].downcase
5
- elsif config[:public_holidays].key?(:default_calendar)
5
+ elsif config[:public_holidays].key?(:default_calendar) and country_region.empty?
6
6
  country_region = config[:public_holidays][:default_calendar].downcase
7
- else
8
- country_region = ""
9
7
  end
8
+
10
9
  country, location = country_region.split("/")
11
10
  public_holidays(country.to_s, location.to_s, year, "", "", add_stats: false, publish_results: false)
12
- messages = ["*Time off #{year}*"]
11
+ if from_user_name.empty?
12
+ messages = ["*Calendar #{year} #{country_region}*"]
13
+ else
14
+ messages = ["*Time off #{year}*"]
15
+ end
13
16
  days_of_vacations = 0
14
17
  (1..12).each do |m|
15
18
  date = Date.parse("#{year}/#{m}/1")
@@ -74,13 +77,17 @@ class SlackSmartBot
74
77
  end
75
78
  messages << "#{month_line} #{month_name}\n"
76
79
  end
77
- messages << "\n\n:large_yellow_square: weekend / :white_square: weekday / :white_small_square: not in month / :large_red_square: Public Holiday / :palm_tree: Vacation / :face_with_thermometer: Sick / :baby: Sick child"
78
- if country_region != ""
79
- messages << "Your public holidays are set for #{country_region.downcase}. Call `set public holidays to COUNTRY/REGION` if you want to change it.\n"
80
+ if !from_user_name.empty?
81
+ messages << "\n\n:large_yellow_square: weekend / :white_square: weekday / :white_small_square: not in month / :large_red_square: Public Holiday / :palm_tree: Vacation / :face_with_thermometer: Sick / :baby: Sick child"
82
+ if country_region != ""
83
+ messages << "Your public holidays are set for #{country_region.downcase}. Call `set public holidays to COUNTRY/REGION` if you want to change it.\n"
84
+ else
85
+ messages << "Your public holidays are not set. Call `set public holidays to COUNTRY/REGION` to set it.\n"
86
+ end
87
+ messages << "You have spent #{days_of_vacations} days of vacations in #{year} considering only weekdays.\n\n"
80
88
  else
81
- messages << "Your public holidays are not set. Call `set public holidays to COUNTRY/REGION` to set it.\n"
89
+ messages << "\n\n:large_yellow_square: weekend / :white_square: weekday / :white_small_square: not in month / :large_red_square: Public Holiday"
82
90
  end
83
- messages << "You have spent #{days_of_vacations} days of vacations in #{year} considering only weekdays.\n\n"
84
91
  respond messages.join("\n")
85
92
  end
86
93
  end
@@ -0,0 +1,23 @@
1
+ class SlackSmartBot
2
+ module Utils
3
+ module Encryption
4
+ def self.decrypt(data, config)
5
+ if config.encrypt
6
+ require "openssl"
7
+ require "base64"
8
+
9
+ key, iv = Utils::Encryption.encryption_get_key_iv(config)
10
+ encrypted = Base64.decode64(data)
11
+ cipher = OpenSSL::Cipher.new("AES-256-CBC")
12
+ cipher.decrypt
13
+ cipher.key = key
14
+ cipher.iv = iv
15
+ plain = cipher.update(encrypted) + cipher.final
16
+ return plain
17
+ else
18
+ return data
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,27 @@
1
+ class SlackSmartBot
2
+ module Utils
3
+ module Encryption
4
+ def self.encrypt(data, config)
5
+ if config.encrypt
6
+ require "openssl"
7
+ require "base64"
8
+
9
+ key, iv = Utils::Encryption.encryption_get_key_iv(config)
10
+ cipher = OpenSSL::Cipher::Cipher.new "AES-256-CBC"
11
+ cipher.encrypt
12
+ cipher.key = key
13
+ cipher.iv = iv
14
+ encrypted = cipher.update(data) + cipher.final
15
+ encrypted = Base64.encode64(encrypted)
16
+ if defined?(Thread.current)
17
+ Thread.current[:encrypted] ||= []
18
+ Thread.current[:encrypted] << data
19
+ end
20
+ return encrypted
21
+ else
22
+ return data
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,5 +1,7 @@
1
1
  class SlackSmartBot
2
- def encryption_get_key_iv
2
+ module Utils
3
+ module Encryption
4
+ def self.encryption_get_key_iv(config)
3
5
  if defined?(@encryption_key_built)
4
6
  key = @encryption_key_built
5
7
  iv = @encryption_iv_built
@@ -11,19 +13,21 @@ class SlackSmartBot
11
13
  key = (Socket.gethostname + config.token.reverse)[0..49]
12
14
  iv = config.token[0..15]
13
15
  end
14
-
16
+
15
17
  #Convert from hex to raw bytes:
16
- key = [key].pack('H*')
18
+ key = [key].pack("H*")
17
19
  #Pad with zero bytes to correct length:
18
20
  key << ("\x00" * (32 - key.length))
19
-
21
+
20
22
  #Convert from hex to raw bytes:
21
- iv = [iv].pack('H*')
23
+ iv = [iv].pack("H*")
22
24
  #Pad with zero bytes to correct length:
23
- iv << ("\x00" * (16 - iv.length))
25
+ iv << ("\x00" * (16 - iv.length))
24
26
  @encryption_key_built = key
25
27
  @encryption_iv_built = iv
26
28
  end
27
29
  return key, iv
28
- end
29
- end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -4,7 +4,9 @@ class SlackSmartBot
4
4
  general: [:bot_help, :hi_bot, :bye_bot, :add_admin, :remove_admin, :see_admins, :poster, :add_announcement, :delete_announcement,
5
5
  :see_announcements, :see_command_ids, :share_messages, :see_shares, :delete_share, :see_favorite_commands, :see_statuses,
6
6
  :allow_access, :see_access, :deny_access, :add_team, :add_memo_team, :delete_memo_team, :set_memo_status, :see_teams, :update_team, :ping_team, :delete_team,
7
- :see_memos_team, :add_vacation, :remove_vacation, :see_vacations, :see_vacations_team, :public_holidays, :create_loop, :quit_loop],
7
+ :see_memos_team, :add_vacation, :remove_vacation, :see_vacations, :see_vacations_team, :public_holidays, :set_public_holidays, :create_loop, :quit_loop,
8
+ :get_personal_settings, :delete_personal_settings, :set_personal_settings,
9
+ :open_ai_chat, :open_ai_generate_image, :open_ai_edit_image, :open_ai_variations_image, :open_ai_whisper, :open_ai_models ],
8
10
  on_bot_general: [:whats_new, :suggest_command, :bot_status, :use_rules, :stop_using_rules, :bot_stats, :leaderboard],
9
11
  on_bot: [:ruby_code, :repl, :get_repl, :run_repl, :delete_repl, :see_repls, :kill_repl, :add_shortcut, :delete_shortcut, :see_shortcuts],
10
12
  on_bot_admin: [:extend_rules, :stop_using_rules_on, :start_bot, :pause_bot, :add_routine,
@@ -0,0 +1,14 @@
1
+ class SlackSmartBot
2
+ def get_personal_settings
3
+ @personal_settings ||= {}
4
+ @datetime_personal_settings_file ||= {}
5
+ files = Dir.glob(File.join(config.path, "personal_settings", "ps_*.yaml"))
6
+ files.each do |file|
7
+ if !defined?(@datetime_personal_settings_file) or !@datetime_personal_settings_file.key?(file) or @datetime_personal_settings_file[file] != File.mtime(file)
8
+ user_personal_settings = YAML.load(Utils::Encryption.decrypt(File.read(file),config))
9
+ @personal_settings[File.basename(file).gsub("ps_","").gsub(".yaml","")] = user_personal_settings
10
+ @datetime_personal_settings_file[file] = File.mtime(file)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -8,7 +8,7 @@ class SlackSmartBot
8
8
  teams = YAML.load(File.read(old_teams_file))
9
9
  @logger.info "@teams: #{teams.inspect}}"
10
10
  teams.each do |key, value|
11
- File.write(File.join(config.path, "teams", "t_#{key}.yaml"), encrypt(value.to_yaml))
11
+ File.write(File.join(config.path, "teams", "t_#{key}.yaml"), Utils::Encryption.encrypt(value.to_yaml, config))
12
12
  end
13
13
  @logger.info "Deleting old_teams_file: #{old_teams_file}"
14
14
  File.delete(old_teams_file)
@@ -17,7 +17,7 @@ class SlackSmartBot
17
17
  @datetime_teams_file ||= {}
18
18
  files.each do |file|
19
19
  if !defined?(@datetime_teams_file) or !@datetime_teams_file.key?(file) or @datetime_teams_file[file] != File.mtime(file)
20
- teams_team = YAML.load(decrypt(File.read(file)))
20
+ teams_team = YAML.load(Utils::Encryption.decrypt(File.read(file),config))
21
21
  team_name = File.basename(file).gsub("t_","").gsub(".yaml","")
22
22
  teams_team[:name] = team_name unless teams_team.key?(:name) #to be backward compatible
23
23
  @teams[team_name.to_sym] = teams_team
@@ -9,7 +9,7 @@ class SlackSmartBot
9
9
  vacations = YAML.load(File.read(old_vacations_file))
10
10
  @vacations = vacations unless vacations.is_a?(FalseClass)
11
11
  @vacations.each do |key, value|
12
- File.write(File.join(config.path, "vacations", "v_#{key}.yaml"), encrypt(value.to_yaml))
12
+ File.write(File.join(config.path, "vacations", "v_#{key}.yaml"), Utils::Encryption.encrypt(value.to_yaml, config))
13
13
  end
14
14
  @logger.info "Deleting old_vacations_file: #{old_vacations_file}"
15
15
  File.delete(old_vacations_file)
@@ -18,7 +18,7 @@ class SlackSmartBot
18
18
  @datetime_vacations_file ||= {}
19
19
  files.each do |file|
20
20
  if !defined?(@datetime_vacations_file) or !@datetime_vacations_file.key?(file) or @datetime_vacations_file[file] != File.mtime(file)
21
- vacations_user = YAML.load(decrypt(File.read(file)))
21
+ vacations_user = YAML.load(Utils::Encryption.decrypt(File.read(file), config))
22
22
  @vacations[File.basename(file).gsub("v_","").gsub(".yaml","")] = vacations_user
23
23
  @datetime_vacations_file[file] = File.mtime(file)
24
24
  end
@@ -3,6 +3,8 @@ class SlackSmartBot
3
3
  if has_access?(method, Thread.current[:user]) or forced
4
4
  if config.stats
5
5
  begin
6
+ command_ids_not_to_log = ['add_vacation', 'remove_vacation', 'add_memo_team', 'set_personal_settings']
7
+ Thread.current[:command_id] = method.to_s
6
8
  require "csv"
7
9
  if !File.exist?("#{config.stats_path}.#{Time.now.strftime("%Y-%m")}.log")
8
10
  CSV.open("#{config.stats_path}.#{Time.now.strftime("%Y-%m")}.log", "wb") do |csv|
@@ -42,7 +44,7 @@ class SlackSmartBot
42
44
  time_zone = user_info.tz_label
43
45
  job_title = user_info.profile.title
44
46
  end
45
-
47
+ command_txt = "#{method} encrypted" if command_ids_not_to_log.include?(method.to_s)
46
48
  CSV.open("#{config.stats_path}.#{Time.now.strftime("%Y-%m")}.log", "a+") do |csv|
47
49
  csv << [Time.now, config.channel, @channel_id, @channels_name[data.dest], data.dest, data.typem, user_name, user_id, command_txt, method, data.files, time_zone, job_title]
48
50
  end
@@ -0,0 +1,18 @@
1
+ class SlackSmartBot
2
+ def update_personal_settings(user_personal_settings=nil)
3
+ require 'yaml'
4
+ unless user_personal_settings.nil?
5
+ get_personal_settings()
6
+ @personal_settings.merge!(user_personal_settings)
7
+ end
8
+ user = Thread.current[:user]
9
+ personal_settings_file = File.join(config.path, "personal_settings", "ps_#{user.name}.yaml")
10
+
11
+ File.open(personal_settings_file, 'w') {|file|
12
+ file.flock(File::LOCK_EX)
13
+ file.write(Utils::Encryption.encrypt(@personal_settings[user.name].to_yaml, config))
14
+ file.flock(File::LOCK_UN)
15
+ }
16
+ @datetime_personal_settings_file[personal_settings_file] = File.mtime(personal_settings_file)
17
+ end
18
+ end
@@ -13,7 +13,7 @@ class SlackSmartBot
13
13
  team_file = File.join(config.path, "teams", "t_#{team}.yaml")
14
14
  File.open(team_file, 'w') {|file|
15
15
  file.flock(File::LOCK_EX)
16
- file.write(encrypt(@teams[team].to_yaml))
16
+ file.write(Utils::Encryption.encrypt(@teams[team].to_yaml, config))
17
17
  file.flock(File::LOCK_UN)
18
18
  }
19
19
  @datetime_teams_file[team_file] = File.mtime(team_file)
@@ -10,7 +10,7 @@ class SlackSmartBot
10
10
 
11
11
  File.open(vacations_file, 'w') {|file|
12
12
  file.flock(File::LOCK_EX)
13
- file.write(encrypt(@vacations[user.name].to_yaml))
13
+ file.write(Utils::Encryption.encrypt(@vacations[user.name].to_yaml, config))
14
14
  file.flock(File::LOCK_UN)
15
15
  }
16
16
  @datetime_vacations_file[vacations_file] = File.mtime(vacations_file)
@@ -26,12 +26,14 @@ require_relative 'utils/update_access_channels'
26
26
  require_relative 'utils/get_command_ids'
27
27
  require_relative 'utils/get_teams'
28
28
  require_relative 'utils/get_vacations'
29
+ require_relative 'utils/get_personal_settings'
30
+ require_relative 'utils/update_personal_settings'
29
31
  require_relative 'utils/update_teams'
30
32
  require_relative 'utils/update_vacations'
31
33
  require_relative 'utils/check_vacations'
32
34
  require_relative 'utils/display_calendar'
33
- require_relative 'utils/encryption_get_key_iv'
34
- require_relative 'utils/encrypt'
35
- require_relative 'utils/decrypt'
35
+ require_relative 'utils/encryption/encryption_get_key_iv'
36
+ require_relative 'utils/encryption/encrypt'
37
+ require_relative 'utils/encryption/decrypt'
36
38
  require_relative 'utils/get_team_members'
37
39
 
@@ -18,6 +18,7 @@ require_relative "slack/smart-bot/process_first"
18
18
  require_relative "slack/smart-bot/commands"
19
19
  require_relative "slack/smart-bot/process"
20
20
  require_relative "slack/smart-bot/utils"
21
+ require_relative "slack/smart-bot/ai"
21
22
 
22
23
  ADMIN_USERS = MASTER_USERS if defined?(MASTER_USERS) # for bg compatibility
23
24
  class SlackSmartBot
@@ -57,6 +58,15 @@ class SlackSmartBot
57
58
  config[:public_holidays] = { api_key: '' } unless config.key?(:public_holidays) and config[:public_holidays].key?(:api_key)
58
59
  config[:public_holidays][:host] ||= "https://calendarific.com"
59
60
  config[:public_holidays][:host] = "https://#{config[:public_holidays][:host]}" unless config[:public_holidays][:host] == '' or config[:public_holidays][:host].match?(/^http/)
61
+ config[:encrypt] ||= true unless config.key?(:encrypt)
62
+ config[:ai] ||= {} unless config.key?(:ai)
63
+ config[:ai][:open_ai] ||= {
64
+ access_token: '',
65
+ organization_id: ''
66
+ } unless config[:ai].key?(:open_ai)
67
+ config[:ai][:open_ai][:whisper_model] ||= 'whisper-1'
68
+ config[:ai][:open_ai][:image_size] ||= '256x256'
69
+ config[:ai][:open_ai][:gpt_model] ||= 'gpt-3.5-turbo'
60
70
 
61
71
  if config.path.to_s!='' and config.file.to_s==''
62
72
  config.file = File.basename($0)
@@ -80,6 +90,7 @@ class SlackSmartBot
80
90
  Dir.mkdir("#{config.path}/rules") unless Dir.exist?("#{config.path}/rules")
81
91
  Dir.mkdir("#{config.path}/vacations") unless Dir.exist?("#{config.path}/vacations")
82
92
  Dir.mkdir("#{config.path}/teams") unless Dir.exist?("#{config.path}/teams")
93
+ Dir.mkdir("#{config.path}/personal_settings") unless Dir.exist?("#{config.path}/personal_settings")
83
94
  File.delete("#{config.path}/config_tmp.status") if File.exist?("#{config.path}/config_tmp.status")
84
95
 
85
96
  config.masters = MASTER_USERS if config.masters.to_s=='' and defined?(MASTER_USERS)
@@ -326,6 +337,7 @@ class SlackSmartBot
326
337
  get_admins_channels()
327
338
  get_access_channels()
328
339
  get_vacations()
340
+ get_personal_settings()
329
341
 
330
342
  if @routines.key?(@channel_id)
331
343
  @routines[@channel_id].each do |k, v|
data/whats_new.txt CHANGED
@@ -1,21 +1,20 @@
1
- *Version 1.13.2* Released 2023-Mar-15
1
+ *Version 1.14.1* Released 2023-Apr-13
2
2
 
3
3
  *For General users*
4
- - It is possible to run any command on a loop: `for 3 times every 5 minutes !ruby puts Time.now` (<https://github.com/MarioRuiz/slack-smart-bot/issues/83|#83>).
5
- - You can add collaborators to your REPL by sending `add collaborator @USER` to the session. (<https://github.com/MarioRuiz/slack-smart-bot/issues/85|#85>).
6
- - If using the `monthly` option when calling `bot stats` it will show a graph (<https://github.com/MarioRuiz/slack-smart-bot/issues/86|#86>).
7
- - New `public holidays COUNTRY/REGION` command (<https://github.com/MarioRuiz/slack-smart-bot/issues/88|#88>)
8
- - When calling `see my vacations` on a DM will display a calendar of the year with the days off, including public holidays (<https://github.com/MarioRuiz/slack-smart-bot/issues/89|#89>)
9
- - `set public holidays to COUNTRY/REGION` will set the public holidays for the country and region specified. (<https://github.com/MarioRuiz/slack-smart-bot/issues/90|#90>)
10
- - `see MEMO_TYPE from TEAM_NAME team` will show the memos of the team. (<https://github.com/MarioRuiz/slack-smart-bot/issues/91|#91>)
4
+ - `team TEAM_NAME memo ID MESSAGE`, `TEAM_NAME team memo ID MESSAGE` It will add a comment to the memo ID specified on the team specified. (<https://github.com/MarioRuiz/slack-smart-bot/issues/95|#95>).
5
+ - `team TEAM_NAME memo ID`, `TEAM_NAME team memo ID` It will show the memo ID specified on the team specified along with all the comments. (<https://github.com/MarioRuiz/slack-smart-bot/issues/96|#96>)
6
+ - When on a repl it is possible to get the documentation and source code of any method: `doc METHOD`, `source METHOD`, `code METHOD`. Examples: `doc Operations.list`, `code World::API::Time.get` (<https://github.com/MarioRuiz/slack-smart-bot/issues/98|#98>)
7
+ - Deleted memos will be accessible by the creator (<https://github.com/MarioRuiz/slack-smart-bot/issues/100|#100>)
8
+ - `calendar COUNTRY`, `calendar COUNTRY/STATE`, `calendar COUNTRY/STATE DATE` will display the calendar of public holidays. (<https://github.com/MarioRuiz/slack-smart-bot/issues/102|#102>)
9
+ - Display public holidays for every member on vacation team calendar (<https://github.com/MarioRuiz/slack-smart-bot/issues/103|#103>)
10
+ - OpenAI integration for personal results. ChatGPT, Whisper, Image generation, Image Variations and Image Edition (<https://github.com/MarioRuiz/slack-smart-bot/issues/101|#101>)
11
+ - New `set personal settings` command (<https://github.com/MarioRuiz/slack-smart-bot/issues/105|#105>)
11
12
 
12
13
  *For Admin users*
13
- - It is possible to see routines filtering the HEADER supplied using the given REGEXP: `see routines HEADER /REGEXP/` (<https://github.com/MarioRuiz/slack-smart-bot/issues/84|#84>).
14
- - `send message to users from YYYY/MM/DD to YYYY/MM/DD #CHANNEL COMMAND_ID: MESSAGE` will send a DM to all users that have been using the SmartBot according to the SmartBot Stats. One message every 5sc. #CHANNEL and COMMAND are optional filters. (<https://github.com/MarioRuiz/slack-smart-bot/issues/87|#87>)
15
- - `update message URL TEXT` It will update the SmartBot message supplied. You can use this command only if you are a Master admin user and if you are in a private conversation with the bot. (<https://github.com/MarioRuiz/slack-smart-bot/issues/33|#33>)
16
- - Routines now can create threads (<https://github.com/MarioRuiz/slack-smart-bot/issues/36|#36>)
17
- - `add routine NAME on the DAY_OF_MONTH at TIME COMMAND` (<https://github.com/MarioRuiz/slack-smart-bot/issues/82|#82>)
14
+ - New 'silent' option for command `exit bot silent`. It won't notify the SmartBot channels. (<https://github.com/MarioRuiz/slack-smart-bot/issues/93|#93>).
15
+ - Show graph for `bot stats` when specifying option `graph` and grouping by daily, weekly, monthly or yearly. (<https://github.com/MarioRuiz/slack-smart-bot/issues/97|#97>).
16
+ - config.encrypt (Boolean) By default will be set to true. (<https://github.com/MarioRuiz/slack-smart-bot/issues/99|#99>)
18
17
 
19
18
  ------------------------------
20
19
 
21
- *Previous*: <https://github.com/MarioRuiz/slack-smart-bot/blob/2b93317d7556ceaeb724494f53cfa9e8907c3e52/whats_new.txt|1.12.9>
20
+ *Previous*: <https://github.com/MarioRuiz/slack-smart-bot/blob/644c0882dec62281d5961d7565f6aba001be8d91/whats_new.txt|1.13.2>
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: 1.13.2
4
+ version: 1.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-15 00:00:00.000000000 Z
11
+ date: 2023-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slack-ruby-client
@@ -44,6 +44,34 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1.9'
47
+ - !ruby/object:Gem::Dependency
48
+ name: method_source
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: ruby-openai
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3'
47
75
  - !ruby/object:Gem::Dependency
48
76
  name: nice_hash
49
77
  requirement: !ruby/object:Gem::Requirement
@@ -154,6 +182,14 @@ files:
154
182
  - lib/slack-smart-bot_general_commands.rb
155
183
  - lib/slack-smart-bot_general_rules.rb
156
184
  - lib/slack-smart-bot_rules.rb
185
+ - lib/slack/smart-bot/ai.rb
186
+ - lib/slack/smart-bot/ai/open_ai/connect.rb
187
+ - lib/slack/smart-bot/ai/open_ai/models.rb
188
+ - lib/slack/smart-bot/ai/open_ai/send_gpt_chat.rb
189
+ - lib/slack/smart-bot/ai/open_ai/send_image_edit.rb
190
+ - lib/slack/smart-bot/ai/open_ai/send_image_generation.rb
191
+ - lib/slack/smart-bot/ai/open_ai/send_image_variation.rb
192
+ - lib/slack/smart-bot/ai/open_ai/whisper_transcribe.rb
157
193
  - lib/slack/smart-bot/comm.rb
158
194
  - lib/slack/smart-bot/comm/ask.rb
159
195
  - lib/slack/smart-bot/comm/delete.rb
@@ -177,19 +213,21 @@ files:
177
213
  - lib/slack/smart-bot/commands.rb
178
214
  - lib/slack/smart-bot/commands/general/add_admin.rb
179
215
  - lib/slack/smart-bot/commands/general/add_announcement.rb
180
- - lib/slack/smart-bot/commands/general/add_memo_team.rb
181
- - lib/slack/smart-bot/commands/general/add_team.rb
182
216
  - lib/slack/smart-bot/commands/general/add_vacation.rb
217
+ - lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat.rb
218
+ - lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_edit_image.rb
219
+ - lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_generate_image.rb
220
+ - lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_models.rb
221
+ - lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_variations_image.rb
222
+ - lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_whisper.rb
183
223
  - lib/slack/smart-bot/commands/general/allow_access.rb
184
224
  - lib/slack/smart-bot/commands/general/bot_help.rb
185
225
  - lib/slack/smart-bot/commands/general/bye_bot.rb
186
226
  - lib/slack/smart-bot/commands/general/delete_announcement.rb
187
- - lib/slack/smart-bot/commands/general/delete_memo_team.rb
188
227
  - lib/slack/smart-bot/commands/general/delete_share.rb
189
- - lib/slack/smart-bot/commands/general/delete_team.rb
190
228
  - lib/slack/smart-bot/commands/general/deny_access.rb
191
229
  - lib/slack/smart-bot/commands/general/hi_bot.rb
192
- - lib/slack/smart-bot/commands/general/ping_team.rb
230
+ - lib/slack/smart-bot/commands/general/personal_settings.rb
193
231
  - lib/slack/smart-bot/commands/general/poster.rb
194
232
  - lib/slack/smart-bot/commands/general/public_holidays.rb
195
233
  - lib/slack/smart-bot/commands/general/remove_admin.rb
@@ -199,16 +237,23 @@ files:
199
237
  - lib/slack/smart-bot/commands/general/see_announcements.rb
200
238
  - lib/slack/smart-bot/commands/general/see_command_ids.rb
201
239
  - lib/slack/smart-bot/commands/general/see_favorite_commands.rb
202
- - lib/slack/smart-bot/commands/general/see_memos_team.rb
203
240
  - lib/slack/smart-bot/commands/general/see_shares.rb
204
241
  - lib/slack/smart-bot/commands/general/see_statuses.rb
205
- - lib/slack/smart-bot/commands/general/see_teams.rb
206
242
  - lib/slack/smart-bot/commands/general/see_vacations.rb
207
- - lib/slack/smart-bot/commands/general/see_vacations_team.rb
208
- - lib/slack/smart-bot/commands/general/set_memo_status.rb
209
243
  - lib/slack/smart-bot/commands/general/set_public_holidays.rb
210
244
  - lib/slack/smart-bot/commands/general/share_messages.rb
211
- - lib/slack/smart-bot/commands/general/update_team.rb
245
+ - lib/slack/smart-bot/commands/general/teams/add_team.rb
246
+ - lib/slack/smart-bot/commands/general/teams/delete_team.rb
247
+ - lib/slack/smart-bot/commands/general/teams/memos/add_memo_team.rb
248
+ - lib/slack/smart-bot/commands/general/teams/memos/add_memo_team_comment.rb
249
+ - lib/slack/smart-bot/commands/general/teams/memos/delete_memo_team.rb
250
+ - lib/slack/smart-bot/commands/general/teams/memos/see_memo_team.rb
251
+ - lib/slack/smart-bot/commands/general/teams/memos/see_memos_team.rb
252
+ - lib/slack/smart-bot/commands/general/teams/memos/set_memo_status.rb
253
+ - lib/slack/smart-bot/commands/general/teams/ping_team.rb
254
+ - lib/slack/smart-bot/commands/general/teams/see_teams.rb
255
+ - lib/slack/smart-bot/commands/general/teams/see_vacations_team.rb
256
+ - lib/slack/smart-bot/commands/general/teams/update_team.rb
212
257
  - lib/slack/smart-bot/commands/general_bot_commands.rb
213
258
  - lib/slack/smart-bot/commands/on_bot/add_shortcut.rb
214
259
  - lib/slack/smart-bot/commands/on_bot/admin/add_routine.rb
@@ -239,6 +284,7 @@ files:
239
284
  - lib/slack/smart-bot/commands/on_bot/get_repl.rb
240
285
  - lib/slack/smart-bot/commands/on_bot/kill_repl.rb
241
286
  - lib/slack/smart-bot/commands/on_bot/repl.rb
287
+ - lib/slack/smart-bot/commands/on_bot/repl_client.rb
242
288
  - lib/slack/smart-bot/commands/on_bot/ruby_code.rb
243
289
  - lib/slack/smart-bot/commands/on_bot/run_repl.rb
244
290
  - lib/slack/smart-bot/commands/on_bot/see_repls.rb
@@ -262,16 +308,17 @@ files:
262
308
  - lib/slack/smart-bot/utils/build_help.rb
263
309
  - lib/slack/smart-bot/utils/check_vacations.rb
264
310
  - lib/slack/smart-bot/utils/create_routine_thread.rb
265
- - lib/slack/smart-bot/utils/decrypt.rb
266
311
  - lib/slack/smart-bot/utils/display_calendar.rb
267
- - lib/slack/smart-bot/utils/encrypt.rb
268
- - lib/slack/smart-bot/utils/encryption_get_key_iv.rb
312
+ - lib/slack/smart-bot/utils/encryption/decrypt.rb
313
+ - lib/slack/smart-bot/utils/encryption/encrypt.rb
314
+ - lib/slack/smart-bot/utils/encryption/encryption_get_key_iv.rb
269
315
  - lib/slack/smart-bot/utils/get_access_channels.rb
270
316
  - lib/slack/smart-bot/utils/get_admins_channels.rb
271
317
  - lib/slack/smart-bot/utils/get_bots_created.rb
272
318
  - lib/slack/smart-bot/utils/get_channels_name_and_id.rb
273
319
  - lib/slack/smart-bot/utils/get_command_ids.rb
274
320
  - lib/slack/smart-bot/utils/get_help.rb
321
+ - lib/slack/smart-bot/utils/get_personal_settings.rb
275
322
  - lib/slack/smart-bot/utils/get_repls.rb
276
323
  - lib/slack/smart-bot/utils/get_routines.rb
277
324
  - lib/slack/smart-bot/utils/get_rules_imported.rb
@@ -287,6 +334,7 @@ files:
287
334
  - lib/slack/smart-bot/utils/update_access_channels.rb
288
335
  - lib/slack/smart-bot/utils/update_admins_channels.rb
289
336
  - lib/slack/smart-bot/utils/update_bots_file.rb
337
+ - lib/slack/smart-bot/utils/update_personal_settings.rb
290
338
  - lib/slack/smart-bot/utils/update_repls.rb
291
339
  - lib/slack/smart-bot/utils/update_routines.rb
292
340
  - lib/slack/smart-bot/utils/update_rules_imported.rb
@@ -1,117 +0,0 @@
1
- class SlackSmartBot
2
- def add_memo_team(user, privacy, team_name, topic, type, message)
3
- save_stats(__method__)
4
-
5
- get_teams()
6
- if @teams.key?(team_name.to_sym)
7
- assigned_members = @teams[team_name.to_sym].members.values.flatten
8
- assigned_members.uniq!
9
- all_team_members = assigned_members.dup
10
- team_members = []
11
- if @teams[team_name.to_sym].channels.key?("members")
12
- @teams[team_name.to_sym].channels["members"].each do |ch|
13
- get_channels_name_and_id() unless @channels_id.key?(ch)
14
- tm = get_channel_members(@channels_id[ch])
15
- tm.each do |m|
16
- user_info = @users.select { |u| u.id == m or (u.key?(:enterprise_user) and u.enterprise_user.id == m) }[-1]
17
- team_members << user_info.name unless user_info.is_app_user or user_info.is_bot
18
- end
19
- end
20
- end
21
- team_members.flatten!
22
- team_members.uniq!
23
- all_team_members += team_members
24
- all_team_members.uniq!
25
- end
26
- if type == "jira"
27
- able_to_connect_jira = false
28
- begin
29
- http = NiceHttp.new(config.jira.host)
30
- http.headers.authorization = NiceHttpUtils.basic_authentication(user: config.jira.user, password: config.jira.password)
31
- message.gsub!(/^\s*</, "")
32
- message.gsub!(/\>$/, "")
33
- message.gsub!(/\|.+$/, "")
34
- message.gsub!(/^#{config.jira.host}/, "")
35
- if message.include?("/browse/")
36
- message = message.scan(/\/browse\/(.+)/).join
37
- resp = http.get("/rest/api/latest/issue/#{message}")
38
- else
39
- message.gsub!(/^\/issues\/\?jql=/, "")
40
- message.gsub!(" ", "%20")
41
- resp = http.get("/rest/api/latest/search/?jql=#{message}")
42
- end
43
- if resp.code == 200
44
- able_to_connect_jira = true
45
- else
46
- error_code = resp.code
47
- if resp.code == 400
48
- error_message = resp.data.json(:errorMessages)[-1]
49
- else
50
- error_message = ""
51
- end
52
- end
53
- http.close
54
- rescue => exception
55
- @logger.fatal exception
56
- end
57
- elsif type == "github"
58
- able_to_connect_github = false
59
- begin
60
- http = NiceHttp.new(config.github.host)
61
- http.headers.authorization = "token #{config.github.token}"
62
- message.gsub!(/^\s*</, "")
63
- message.gsub!(/\>$/, "")
64
- message.gsub!(/\|.+$/, "")
65
- message.gsub!(/^#{config.github.host}/, "")
66
- message.gsub!("https://github.com", "")
67
- message.slice!(0) if message[0] == "/"
68
- resp = http.get("/repos#{message}")
69
- if resp.code == 200
70
- able_to_connect_github = true
71
- else
72
- error_code = resp.code
73
- if resp.code == 401
74
- error_message = resp.data.json(:message)[-1]
75
- else
76
- error_message = ""
77
- end
78
- end
79
- http.close
80
- rescue => exception
81
- @logger.fatal exception
82
- end
83
- end
84
-
85
- if !@teams.key?(team_name.to_sym)
86
- respond "It seems like the team *#{team_name}* doesn't exist\nRelated commands `add team TEAM_NAME PROPERTIES`, `see team TEAM_NAME`, `see teams`"
87
- elsif !(all_team_members + config.masters).flatten.include?(user.name)
88
- respond "You have to be a member of the team or a Master admin to be able to add a memo to the team."
89
- elsif type == "jira" and !able_to_connect_jira
90
- if error_message == ""
91
- respond "You need to supply the correct credentials for JIRA on the SmartBot settings: `jira: { host: HOST, user: USER, password: PASSWORD }` and a correct JQL string or JQL url"
92
- else
93
- respond "You need to supply a correct JQL string or JQL url: #{error_message}"
94
- end
95
- else
96
- topic = :no_topic if topic == ""
97
- @teams[team_name.to_sym][:memos] ||= []
98
- if @teams[team_name.to_sym][:memos].empty?
99
- memo_id = 1
100
- else
101
- memo_id = @teams[team_name.to_sym][:memos].memo_id.flatten.max + 1
102
- end
103
- @teams[team_name.to_sym][:memos] << {
104
- memo_id: memo_id,
105
- topic: topic,
106
- type: type,
107
- privacy: privacy,
108
- user: user.name,
109
- date: Time.now.strftime("%Y-%m-%dT%H:%M:%S.000Z")[0..18],
110
- message: message,
111
- status: ':new: '
112
- }
113
- update_teams()
114
- respond "The memo has been added to *#{team_name}* team."
115
- end
116
- end
117
- end