cinch-twitter 2.0.2 → 2.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c78167e8dea6ad52e63fde4d37a76883fb6dbc8
4
- data.tar.gz: 108e50c4e34bca3660891fc63b09af43240c9b79
3
+ metadata.gz: 97cce969296f624998cd0b31d92b943bf6472f5c
4
+ data.tar.gz: 2c70ea9305bb6a05926417a89d879ac025c11bb2
5
5
  SHA512:
6
- metadata.gz: cd97aa5ab04f56e044b00e0e52e063f4f23ede8851e7f6cc739144efc258bdcd23a05e0e0a11967804a79309548a13149f9e784e2f054bf4fa0ffa6674adda2e
7
- data.tar.gz: 2429229aae5a5234f8271eeebfb01eb49fa691aa779873114f01bbce34346bfb9230f0dd77ea2957a65bc9a92037d88aed4d3daca402d5b6ae6959414dae18de
6
+ metadata.gz: f55352869ccbab0d74aadf073b1f48d0a993338ebcf40f7e42780fee0bbd2eb6bf2dcd98f311b9f0c9c89a6d60dee51efa4c06f77edb33711813391298e43db8
7
+ data.tar.gz: 02557810e739f718fe157772a884e267f64c2b73822af5dad1cfb826fb8a648b725ee31bdacaa50b50a5f04d59181634142fbe57ec5fa856e7d53aa9aaaf8352
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # Version 2.0.3
2
+ * Fixes many regressions introduced in 2.0.2, including URLs not being expanded and parts of the tweet metadata being blank (i.e. 'from XXX')
3
+ * Switches back to UTC time for all tweet output
4
+ * Various small fixes
5
+
1
6
  # Version 2.0.2
2
7
  * Brings everything up to the latest version of the Twitter gem. Portions rewritten by @Namasteh.
3
8
 
@@ -1,5 +1,5 @@
1
1
  module Cinch
2
2
  module Twitter
3
- VERSION = "2.0.2"
3
+ VERSION = "2.0.3"
4
4
  end
5
5
  end
@@ -16,7 +16,7 @@ module Cinch
16
16
  Usage:
17
17
  * !tw <handle(-D)>: Fetch the latest Tweet from the bot or include an offset (I.E. !tw someuser-2) to fetch (-D) Tweets back (up to 19)
18
18
  * @<handle(-D): Same as above, just shorthand.
19
- * !t-search <terms>: Searches recent tweets containing your terms and returns the most recent three. You can search hash tags or do 'to:<handle>' to get the most recent tweets sent to that handle.
19
+ * !t-search <terms>: Searches recent tweets containing your terms and returns the most recent four. You can search hash tags or do 'to:<handle>' to get the most recent tweets sent to that handle.
20
20
  USAGE
21
21
 
22
22
  def initialize(*args)
@@ -30,13 +30,13 @@ module Cinch
30
30
  def execute_tweet(m, username, offset)
31
31
  offset ||= 0
32
32
 
33
- user = @client.user(username)
33
+ user = @client.user(username, include_entities: "1")
34
34
 
35
35
  return m.reply "This user's tweets are protected!" if user.protected?
36
36
  return m.reply "This user hasn't tweeted yet!" if user.status.nil?
37
37
 
38
38
  if offset.to_i > 0
39
- tweets = @client.user_timeline(user)
39
+ tweets = @client.user_timeline(user, include_entities: "1")
40
40
  return m.reply "You can not backtrack more than #{tweets.count.pred} tweets before the current tweet!" if offset.to_i > tweets.count.pred
41
41
  tweet = tweets[offset.to_i]
42
42
 
@@ -53,7 +53,7 @@ module Cinch
53
53
  match /t-search (.+)/, method: :execute_search
54
54
 
55
55
  def execute_search(m, term)
56
- @client.search("#{term}", :result_type => "recent").take(3).each do |tweet|
56
+ @client.search("#{term}", :result_type => "recent").take(4).each do |tweet|
57
57
  m.reply format_tweet(tweet)
58
58
  end
59
59
  end
@@ -62,7 +62,7 @@ module Cinch
62
62
  match /#(\d+)$/, method: :execute_id, prefix: /^@/
63
63
 
64
64
  def execute_id(m, id)
65
- tweet = @client.status(id)
65
+ tweet = @client.status(id, include_entities: "1")
66
66
 
67
67
  m.reply format_tweet(tweet)
68
68
  rescue ::Twitter::Error::NotFound => e
@@ -82,29 +82,28 @@ module Cinch
82
82
  end
83
83
 
84
84
  # Tweet tweet
85
- body = expand_uris(CGI.unescapeHTML(!!tweet.retweet? ? tweet.retweeted_status.full_text : tweet.full_text).gsub("\n", " ").squeeze(" "), tweet.urls)
86
-
85
+ body = CGI.unescapeHTML(!!tweet.retweet? ? tweet.retweeted_status.full_text : tweet.full_text).gsub("\n", " ").squeeze(" ")
86
+ body = expand_uris(body, tweet.urls)
87
+
87
88
  # Metadata
88
- ttime = tweet.created_at
89
+ ttime = tweet.created_at.getutc
89
90
  tail = []
90
- tail << ttime.ago.to_words
91
- tail << "from #{tweet.place.full_name}" if !!tweet.place
91
+ tail << ttime.ago.to_time.strftime('%b %-e %Y, %-l:%M %p %Z')
92
+ tail << "from #{tweet.place.full_name}" if !tweet.place.nil? && !!tweet.place.full_name
92
93
  tail << "via #{tweet.source.gsub( %r{</?[^>]+?>}, "" )}"
93
94
 
94
95
  # URLs for tweet and replied to:
95
96
  urls = []
96
- urls << "https://twitter.com/#{tweet.user.screen_name}/status/#{tweet.id}"
97
+ urls << tweet.url
97
98
  urls << "in reply to #{format_reply_url(tweet.in_reply_to_screen_name, tweet.in_reply_to_status_id)}" if tweet.reply?
98
99
 
99
100
  [Format(:bold, [*head, "»"] * " "), body, ["(", tail * " · ", ")"].join, urls * " "].join(" ")
100
101
  end
101
102
 
102
- def format_reply_url(username, id)
103
- "https://twitter.com/#{username}#{"/status/#{id}" if !!id}"
104
- end
105
-
106
103
  def expand_uris(t, uris)
107
- uris.each_with_object(t) { |entity, tweet| tweet.gsub!(entity.url, entity.expanded_url) }
104
+ uris.each_with_object(t) { |entity, tweet|
105
+ tweet.gsub!(entity.url.to_s, entity.expanded_url.to_s)
106
+ }
108
107
  end
109
108
 
110
109
  def twitter_client
@@ -118,5 +117,3 @@ module Cinch
118
117
  end
119
118
  end
120
119
  end
121
-
122
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch-twitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark SeymourRichard Banks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-20 00:00:00.000000000 Z
11
+ date: 2014-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: twitter