Created
April 11, 2017 13:54
-
-
Save yswallow/bab7f099f9d3af44c2a96341b23f7e99 to your computer and use it in GitHub Desktop.
右クリックメニューで指定したユーザーを30分間ミュートするmikutterプラグイン
This file contains hidden or 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
| Plugin.create(:half_hour_mute) do | |
| mutes = [] | |
| command(:half_hour_mute, | |
| name: '半時ROMれ', | |
| condition: lambda{ |opt| true } , | |
| visible: true, | |
| role: :timeline) do |opt| | |
| opt.messages.each do |message| | |
| user = message.user.to_s | |
| def user.expire | |
| return @expire | |
| end | |
| def user.expire=(time) | |
| @expire = time | |
| end | |
| user.expire = Time.now + 1800 | |
| p [user, user.expire] | |
| mutes << user | |
| end | |
| end | |
| filter_update do |service, messages| | |
| messages = messages.select { |m| | |
| p user = m.user.to_s | |
| not mutes.any? do |muted_user| | |
| if user == muted_user | |
| p [ muted_user, muted_user.expire ] | |
| if muted_user.expire < Time.now | |
| mutes.delete muted_user | |
| false | |
| else | |
| true | |
| end | |
| else | |
| false | |
| end | |
| end | |
| } | |
| [service, messages] | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment