Created
April 1, 2011 20:56
-
-
Save takamii/898840 to your computer and use it in GitHub Desktop.
TwiProwlの通知メッセージを自分用に変更
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
# TwiProwl 1.4.0の通知メッセージ出力部分を自分好みに変更した部分(抜粋) | |
# 変更点: | |
# ・アイコンを変更 | |
# ・通知メッセージを簡潔にした | |
def process_stream( json ) | |
mentions = json['entities'] ? json['entities']['user_mentions'] : nil | |
retweets = json['retweeted_status'] | |
message = json['direct_message'] | |
event = json['event'] | |
if json['user'] | |
source = json['user']['screen_name'] | |
elsif json['source'] | |
source = json['source']['screen_name'] | |
else | |
source = nil | |
end | |
desc = retweets ? retweets['text'] : json['text'] | |
desc = unescape( desc ) | |
# RT event | |
if retweets and retweets['user']['screen_name'] == @user | |
return if @retweets.ignore and source == @user | |
desc = unescape( retweets['text'] ) | |
event = "@#{source}" | |
debug "Prowling: %s %s" % [ event, desc ] | |
debug "priority: %s, enable: %s" % [ @retweets.priority, @retweets.enable ] | |
prowl( :apikey => @@prowl_conf['APIKey'], | |
:application=> @application, | |
:event => "#{Unicode::E00E}#{event}", | |
:description => "RT: #{desc}", | |
:priority => @retweets.priority ) if @retweets.enable | |
return | |
end | |
# mentions event | |
if mentions and mentions.size > 0 and | |
mentions.find do |m| m['screen_name'] == @user end | |
return if @mentions.ignore and source == @user | |
desc = unescape( json['text'] ) | |
event = "@#{source}" | |
debug "Prowling: %s %s" % [ event, desc ] | |
debug "priority: %s, enable: %s" % [ @mentions.priority, @mentions.enable ] | |
prowl( :apikey => @@prowl_conf['APIKey'], | |
:application=> @application, | |
:event => "#{Unicode::E103}#{event}", | |
:description => "#{desc}", | |
:priority => @mentions.priority ) if @mentions.enable | |
return | |
end | |
# direct message | |
if message and message['recipient_screen_name'] == @user and | |
([email protected] or message['sender_screen_name'] != @user) | |
desc = unescape( message['text'] ) | |
event = "@#{message['sender_screen_name']}" | |
debug "Prowling: %s %s" % [ event, desc ] | |
prowl( :apikey => @@prowl_conf['APIKey'], | |
:application=> @application, | |
:event => "#{Unicode::E103}#{event}", | |
:description => "#{desc}", | |
:priority => @direct.priority ) if @direct.enable | |
return | |
end | |
# Membership event | |
case event | |
when "list_member_added" | |
if json['target']['screen_name'] == @user and @membership.enable and | |
([email protected] or json['target_object']['user']['screen_name'] != @user) | |
desc = "Listed: #{json['target_object']['full_name']}" | |
prowl( :apikey => @@prowl_conf['APIKey'], | |
:application=> @application, | |
:event => "#{Unicode::E110}@#{source}", | |
:description => "#{desc}", | |
:priority => @membership.priority ) | |
end | |
when "list_member_removed" | |
if json['target']['screen_name'] == @user and | |
@membership.enable and [email protected] and | |
([email protected] or json['target_object']['user']['screen_name'] != @user) | |
desc = "Unlisted: #{json['target_object']['full_name']}" | |
prowl( :apikey => @@prowl_conf['APIKey'], | |
:application=> @application, | |
:event => "#{Unicode::E333}@#{source}", | |
:description => "#{desc}", | |
:priority => @membership.priority ) | |
end | |
when "favorite" | |
target = json['target_object']['user']['screen_name'] | |
if target == @user and @favorite.enable and | |
([email protected] or source != @user) | |
text = json['target_object']['text'] | |
desc = unescape( text ) | |
debug "Prowling: %s %s" % [ source, desc ] | |
debug "priority: %s, enable: %s" % [ @favorite.priority, @favorite.enable ] | |
prowl( :apikey => @@prowl_conf['APIKey'], | |
:application=> @application, | |
:event => "#{Unicode::E32F}@#{source}", | |
:description => "#{desc}", | |
:priority => @favorite.priority ) | |
end | |
when "unfavorite" | |
target = json['target_object']['user']['screen_name'] | |
if target == @user and @favorite.enable and | |
[email protected] and | |
([email protected] or source != @user) | |
text = json['target_object']['text'] | |
desc = unescape( text ) | |
prowl( :apikey => @@prowl_conf['APIKey'], | |
:application=> @application, | |
:event => "#{Unicode::E421}@#{source}", | |
:description => "#{desc}", | |
:priority => @favorite.priority ) | |
end | |
else | |
debug "Event: #{event}" unless event.nil? || event.empty? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment