Skip to content

Instantly share code, notes, and snippets.

@pocke
Last active January 3, 2016 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pocke/8484629 to your computer and use it in GitHub Desktop.
Save pocke/8484629 to your computer and use it in GitHub Desktop.
mikutter の Message に source の URL を含めるパッチ
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
@pocke
Copy link
Author

pocke commented Jan 18, 2014

for mikutter 0.2.2.1476

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment