Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
only query db if no args are provided and capture message content
Browse files Browse the repository at this point in the history
  • Loading branch information
Chew committed May 9, 2019
1 parent 7574ddf commit f505597
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions lib/plugins/user.rb
Expand Up @@ -35,32 +35,33 @@ module User
begin
keys = JSON.parse(File.read('keys.json'))
name = namearg.join(' ') unless namearg.length.zero?
user = BotUser.new(event.user.id)
if user.exists? && namearg.length.zero?
profile = user
name = profile.username
elsif namearg.length.zero?
name = event.user.display_name
end

key = CONFIG['api']

extra = false
if namearg.length.zero? && user.exists? && profile.authkey?
extra = true
key = keys[profile.keyid]
if namearg.empty?
user = BotUser.new(event.user.id)
if user.exists?
profile = user
name = profile.username
else
name = event.user.display_name
end

if user.exists? && profile.authkey?
extra = true
key = keys[profile.keyid]

teste = RestClient.get('https://api-quiz.hype.space/users/me',
Authorization: key,
'x-hq-client': 'iOS/1.3.27 b121',
'Content-Type': :json)
teste = RestClient.get('https://api-quiz.hype.space/users/me',
Authorization: key,
'x-hq-client': 'iOS/1.3.27 b121',
'Content-Type': :json)

teste = JSON.parse(teste)
teste = JSON.parse(teste)

unless teste['username'].casecmp(profile.username).zero?
key = CONFIG['api']
extra = false
event.respond 'Auth key doesn\'t match your profile username, not returning any extra stats!'
unless teste['username'].casecmp(profile.username).zero?
key = CONFIG['api']
extra = false
event.respond 'Auth key doesn\'t match your profile username, not returning any extra stats!'
end
end
end

Expand Down Expand Up @@ -207,14 +208,14 @@ module User
event.respond 'Hey! It\'s me, money-flippin\' Matt Richards! I need some memes, dreams, and the ability to embed links! You gotta grant me these permissions!'
end
rescue StandardError => e
puts "Error"
msg.edit "<:xmark:314349398824058880> Error occured getting stats. This incident has been reported. Join the support server with `hq, invite`"
event.bot.channel(572532026125582336).send_embed do |embed|
embed.title = "Command `hq, user` Errored"
puts 'Error'
msg.edit '<:xmark:314349398824058880> Error occured getting stats. This incident has been reported. Join the support server with `hq, invite`'
event.bot.channel(572_532_026_125_582_336).send_embed do |embed|
embed.title = 'Command `hq, user` Errored'
embed.description = e
end
Raven.user_context(id: event.user.id)
Raven.extra_context(channel_id: event.channel.id, server_id: event.server.id)
Raven.extra_context(channel_id: event.channel.id, server_id: event.server.id, message: event.message.content)
Raven.capture_exception(e)
nil
end
Expand Down

0 comments on commit f505597

Please sign in to comment.