Last active
January 3, 2016 15:39
-
-
Save pocke/8484629 to your computer and use it in GitHub Desktop.
mikutter の Message に source の URL を含めるパッチ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/core/lib/mikutwitter/api_call_support.rb b/core/lib/mikutwitter/api_call_support.rb | |
index f40f200..15c9c31 100644 | |
--- a/core/lib/mikutwitter/api_call_support.rb | |
+++ b/core/lib/mikutwitter/api_call_support.rb | |
@@ -104,7 +104,8 @@ module MikuTwitter::ApiCallSupport | |
cnv = msg.convert_key(:text => :message, | |
:in_reply_to_user_id => :receiver, | |
:in_reply_to_status_id => :replyto) | |
- cnv[:source] = $1 if cnv[:source].is_a?(String) and cnv[:source].match(/^<a\s+.*>(.*?)<\/a>$/) | |
+ cnv[:source] = $2 if cnv[:source].is_a?(String) and cnv[:source].match(/^<a\s+href="(.*?)".*>(.*?)<\/a>$/) | |
+ cnv[:source_url] = $1 || 'https://twitter.com' | |
cnv[:created] = (Time.parse(msg[:created_at]) rescue Time.now) | |
cnv[:user] = Message::MessageUser.new(user(msg[:user]), msg[:user]) | |
cnv[:retweet] = message(msg[:retweeted_status]) if msg[:retweeted_status] | |
diff --git a/core/message.rb b/core/message.rb | |
index 9189f70..8f4c624 100644 | |
--- a/core/message.rb | |
+++ b/core/message.rb | |
@@ -38,6 +38,7 @@ class Message < Retriever::Model | |
[:replyto, Message], # Reply to this message | |
[:retweet, Message], # ReTweet to this message | |
[:source, :string], # using client | |
+ [:source_url, :string], # client url | |
[:geo, :string], # geotag | |
[:exact, :bool], # true if complete data | |
[:created, :time], # posted time |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for mikutter 0.2.2.1476