lita-discord_oauth 0.1.2.alpha.48 → 0.1.2.alpha.49

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 445d240461e29036dceea2aa3d3984150ae53910
4
- data.tar.gz: fe0bec97b8bb0ff75076e1f53a908d7a6e556d3b
3
+ metadata.gz: e14675a2f966a4f5013655a128b38761f147302b
4
+ data.tar.gz: 0772731e0d8871d742660625d9b35bad377ff118
5
5
  SHA512:
6
- metadata.gz: 8a2bb393c939c7111d89e9431392b15bd0ffea5e95f4bb48359acb7a5ca369964b0b00b2b254acbb8e72e04409555180eb1da9944088e3e5202155bbc87722b9
7
- data.tar.gz: 05b06a1fc0dd134f3af9068eb5c417d2a91cabb94bd4df7000fdecf0581db43e4daa74fa203178283c56a98ce5e29af7c8be631d6d33e7531c1577bdef752dd4
6
+ metadata.gz: b5f98ec1f6940900a234591d7723ff500fddc465159eabde6e65d14e69de526b93ff84c90f404b902912c476c54c7ae51de27d003d5589295187bce5e44d33b5
7
+ data.tar.gz: 948ec8b7e0fe2cd6514c22b3d827eaaddc743f2fb35d9d6b925c56d421f73901d66802d90262a8f23bc077037b17d30632e3aa6e2ef33e6a2b4b38bb9d4e886e
@@ -23,11 +23,26 @@ module Lita
23
23
  @client.message do |event|
24
24
  message = event.message
25
25
  author_id = message.author.id.to_s
26
+ author_name = message.author.display_name.to_s
26
27
 
27
- Lita.logger.debug('Received message from ' + author_id + ': ' + message.content)
28
+ Lita.logger.debug("Received message from #{author_name}(#{author_id}): #{message.content}")
29
+ Lita.logger.debug("Finding user #{author_name}")
28
30
 
29
- user = Lita::User.find_by_id(author_id)
30
- user = Lita::User.create(author_id, {name: message.author.display_name.to_s}) unless user
31
+ user = Lita::User.find_by_name(author_name)
32
+
33
+ if user == nil
34
+ Lita.logger.debug("User #{author_name} not found, trying ID #{author_id}")
35
+ user = Lita::User.find_by_id(author_id)
36
+
37
+ if user != nil
38
+ Lita.logger.debug("User #{author_id} found, updating name to #{author_name}")
39
+ user.name = author_name
40
+ user.save
41
+ end
42
+
43
+ Lita.logger.debug("User #{author_id} not found, creating now")
44
+ user = Lita::User.create(author_id, {name: author_name}) unless user
45
+ end
31
46
 
32
47
  Lita.logger.debug('User ID: ' + user.id)
33
48
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-discord_oauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2.alpha.48
4
+ version: 0.1.2.alpha.49
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cas Eliëns