Skip to content

Commit

Permalink
Merge pull request #27 from RodrigoMNardi/feature/translatename2id
Browse files Browse the repository at this point in the history
Translate Name to ID
  • Loading branch information
RodrigoMNardi authored Oct 15, 2024
2 parents 87ef450 + a561909 commit 21c024a
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 99 deletions.
29 changes: 9 additions & 20 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,19 @@
source 'https://rubygems.org'

gem 'activerecord', require: 'active_record'

gem 'base64', '0.1.1'

gem 'certified'
gem 'dotenv'

gem 'nio4r', '2.5.8'

gem 'otr-activerecord', '2.0.3'

gem 'pagy'
gem 'otr-activerecord'
gem 'pagy_cursor'
gem 'parser', '3.0.2.0'
gem 'pg', '1.2.3'
gem 'puma', '5.5.2'

gem 'racc', '1.5.1'
gem 'rack', '2.2.3.1'
gem 'pg'
gem 'puma'
gem 'rack'
gem 'rackup'
gem 'rubocop', '0.89.1', group: %i[development test], require: false
gem 'rubocop-ast', '0.6.0', group: %i[development test], require: false
gem 'rubocop-performance', '1.7.1', group: %i[development test], require: false

gem 'sinatra', '2.0.8.1'
gem 'slack-ruby-bot-server', '2.1.1'
gem 'slack-ruby-bot-server-events', '0.3.2'
gem 'sinatra'
gem 'slack-ruby-bot-server'
gem 'slack-ruby-bot-server-events'
gem 'slack-ruby-client'

gem 'unicode-display_width', '1.6.1'
170 changes: 96 additions & 74 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,119 +1,136 @@
GEM
remote: https://rubygems.org/
specs:
activemodel (7.0.8)
activesupport (= 7.0.8)
activerecord (7.0.8)
activemodel (= 7.0.8)
activesupport (= 7.0.8)
activesupport (7.0.8)
activemodel (7.0.8.4)
activesupport (= 7.0.8.4)
activerecord (7.0.8.4)
activemodel (= 7.0.8.4)
activesupport (= 7.0.8.4)
activesupport (7.0.8.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
async (1.31.0)
console (~> 1.10)
nio4r (~> 2.3)
timers (~> 4.1)
base64 (0.1.1)
builder (3.2.4)
concurrent-ruby (1.2.2)
console (1.23.2)
async (2.17.0)
console (~> 1.26)
fiber-annotation
fiber-local
io-event (~> 1.6, >= 1.6.5)
base64 (0.2.0)
bigdecimal (3.1.8)
certified (1.0.0)
concurrent-ruby (1.3.4)
console (1.27.0)
fiber-annotation
fiber-local (~> 1.1)
json
declarative (0.0.20)
dotenv (2.8.1)
dotenv (3.1.4)
dry-core (1.0.1)
concurrent-ruby (~> 1.0)
zeitwerk (~> 2.6)
dry-inflector (1.0.0)
dry-inflector (1.1.0)
dry-logic (1.5.0)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0, < 2)
zeitwerk (~> 2.6)
dry-types (1.7.1)
dry-types (1.7.2)
bigdecimal (~> 3.0)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0)
dry-inflector (~> 1.0)
dry-logic (~> 1.4)
zeitwerk (~> 2.6)
faraday (2.7.11)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday (2.12.0)
faraday-net_http (>= 2.0, < 3.4)
json
logger
faraday-mashify (0.1.1)
faraday (~> 2.0)
hashie
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (3.0.2)
faraday-net_http (3.3.0)
net-http
fiber-annotation (0.2.0)
fiber-local (1.0.0)
foreman (0.87.2)
gli (2.21.1)
grape (1.8.0)
activesupport (>= 5)
builder
fiber-local (1.1.0)
fiber-storage
fiber-storage (1.0.0)
foreman (0.88.1)
gli (2.21.5)
grape (2.2.0)
activesupport (>= 6)
dry-types (>= 1.1)
mustermann-grape (~> 1.0.0)
rack (>= 1.3.0)
rack-accept
mustermann-grape (~> 1.1.0)
rack (>= 2)
zeitwerk
grape-roar (0.4.1)
grape
multi_json
roar (~> 1.1.0)
grape-swagger (1.6.1)
grape (~> 1.3)
grape-swagger (2.1.1)
grape (>= 1.7, < 3.0)
rack-test (~> 2)
hashie (5.0.0)
hashie-forbidden_attributes (0.1.1)
hashie (>= 3.0)
i18n (1.14.1)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
io-event (1.7.1)
json (2.7.2)
kaminari-core (1.2.2)
kaminari-grape (1.0.1)
grape
kaminari-core (~> 1.0)
minitest (5.20.0)
logger (1.6.1)
minitest (5.25.1)
multi_json (1.15.0)
multipart-post (2.3.0)
mustermann (1.1.2)
multipart-post (2.4.1)
mustermann (3.0.3)
ruby2_keywords (~> 0.0.1)
mustermann-grape (1.0.2)
mustermann-grape (1.1.0)
mustermann (>= 1.0.0)
net-http (0.4.1)
uri
nio4r (2.5.8)
otr-activerecord (2.0.3)
activerecord (>= 4.0, < 7.1)
otr-activerecord (2.4.0)
activerecord (>= 6.0, < 7.3)
hashie-forbidden_attributes (~> 0.1)
pagy (6.2.0)
pagy_cursor (0.6.1)
pagy (8.6.3)
pagy_cursor (0.8.0)
activerecord (>= 5)
pagy (>= 6, < 7)
parallel (1.23.0)
parser (3.0.2.0)
pagy (>= 6, < 9)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
pg (1.2.3)
pg (1.5.8)
puma (5.5.2)
nio4r (~> 2.0)
racc (1.5.1)
rack (2.2.3.1)
rack-accept (0.4.5)
rack (>= 0.4)
rack-cors (2.0.1)
racc (1.7.3)
rack (3.1.7)
rack-cors (2.0.2)
rack (>= 2.0.0)
rack-protection (2.0.8.1)
rack
rack-protection (4.0.0)
base64 (>= 0.1.0)
rack (>= 3.0.0, < 4)
rack-rewrite (1.5.1)
rack-server-pages (0.1.0)
rack
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rainbow (3.1.1)
regexp_parser (2.8.2)
regexp_parser (2.9.2)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
rexml (3.2.6)
rexml (3.3.8)
roar (1.1.1)
representable (~> 3.0)
rubocop (0.89.1)
Expand All @@ -131,10 +148,11 @@ GEM
rubocop (>= 0.82.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sinatra (2.0.8.1)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.8.1)
sinatra (4.0.0)
mustermann (~> 3.0)
rack (>= 3.0.0, < 4)
rack-protection (= 4.0.0)
rack-session (>= 2.0.0, < 3)
tilt (~> 2.0)
slack-ruby-bot-server (2.1.1)
async
Expand All @@ -149,40 +167,44 @@ GEM
slack-ruby-client
slack-ruby-bot-server-events (0.3.2)
slack-ruby-bot-server (>= 0.12.0)
slack-ruby-client (2.2.0)
slack-ruby-client (2.4.0)
faraday (>= 2.0)
faraday-mashify
faraday-multipart
gli
hashie
tilt (2.3.0)
timers (4.3.5)
tilt (2.4.0)
trailblazer-option (0.1.2)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uber (0.1.0)
unicode-display_width (1.6.1)
zeitwerk (2.6.12)
uri (0.13.1)
webrick (1.8.2)
zeitwerk (2.7.0)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
activerecord
certified
dotenv
nio4r (= 2.5.8)
otr-activerecord (= 2.0.3)
pagy
otr-activerecord
pagy_cursor
pg (= 1.2.3)
puma (= 5.5.2)
rack (= 2.2.3.1)
pg
puma
rack
rackup
rubocop (= 0.89.1)
rubocop-ast (= 0.6.0)
rubocop-performance (= 1.7.1)
sinatra (= 2.0.8.1)
slack-ruby-bot-server (= 2.1.1)
slack-ruby-bot-server-events (= 0.3.2)
sinatra
slack-ruby-bot-server
slack-ruby-bot-server-events
slack-ruby-client
unicode-display_width (= 1.6.1)

BUNDLED WITH
2.2.22
2.5.9
2 changes: 1 addition & 1 deletion lib/github_app/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Server < Sinatra::Base

halt 404, 'User not found' unless user_info

halt 200, user_info.profile.display_name
halt 200, user_info
end

post '/comment' do
Expand Down
9 changes: 5 additions & 4 deletions lib/slack/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ def initialize
config.open_timeout = 60
end

@client = Slack::Web::Client.new do |faraday|
faraday.ssl[:ca_file] = '/home/rnardi/.rvm/gems/ruby-3.3.1@slack_bot/gems/certified-1.0.0/ca-certificates.crt'
end
@client = Slack::Web::Client.new
end

def find_user_id_by_name(username)
user = @client.users_info(user: "@#{username}")
user = @client.users_list.members.find { |u| u.name == username || u.display_name == username }

puts user.inspect

user ? user.id : nil

Check warning on line 31 in lib/slack/client.rb

View workflow job for this annotation

GitHub Actions / Rubocop

[rubocop] reported by reviewdog 🐶 Use safe navigation (`&.`) instead of checking if an object exists before calling the method. Raw Output: lib/slack/client.rb:31:5: C: Style/SafeNavigation: Use safe navigation (`&.`) instead of checking if an object exists before calling the method.
end

Expand Down

0 comments on commit 21c024a

Please sign in to comment.