Skip to content

Instantly share code, notes, and snippets.

@syusui-s
Last active October 5, 2015 02:22
Show Gist options
  • Save syusui-s/2070646 to your computer and use it in GitHub Desktop.
Save syusui-s/2070646 to your computer and use it in GitHub Desktop.
TLに特定のユーザーのツイートが流れてきたら、ユーザー名とツイートを通知します。
# -*- coding: utf-8 -*-
Plugin::create(:update_notify) do
settings "ポスト通知" do
boolean "通知", :update_notify_bool
fileselect("通知音", :update_notify_sound, "skin/data/sounds")
input "ユーザー", :update_notify_users
end
onboot do
UserConfig[:boot_time] = Time.now.to_s;
end
onupdate do |psrc, mesgs|
if UserConfig[:update_notify_bool] && !UserConfig[:update_notify_users].empty? then
UserConfig[:update_notify_users].split(",").each { |usr|
mesgs.each { |m|
# メッセージのユーザーが一致し、自分の投稿ではなく、リプライやメンションでもなく、起動後にツイートされたものであれば、通知します
if (m.idname == usr) && (m.idname != Post.primary.user) && !("#{m.message}".index("@")) && (m[:created].to_s<=>UserConfig[:boot_time])>=0 then
Plugin.call(:popup_notify, User::findbyidname(m.message.user.idname),"update:#{m.message}")
Plugin.call(:play_sound, UserConfig[:update_notify_sound]) if !UserConfig[:update_notify_sound].empty?
end
}
}
end
end
end
@syusui-s
Copy link
Author

現在、終了時に通知をオフにしておかないと、次回起動時に通知が大量に発生してしまいます。終了時にわすれないようにしてください。

この問題を修正しました

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