Last active
December 23, 2015 10:09
-
-
Save syusui-s/6619505 to your computer and use it in GitHub Desktop.
バッテリ残量で次の人ソートする奴
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
| # -*- conding: utf-8 -*- | |
| Plugin.create(:presenter_sort_battery) do | |
| hash = {} | |
| on_endpresen do |service| | |
| if not hash.empty? | |
| sorted = hash.sort | |
| idname = sorted[0][0] | |
| service.update(:message => "@#{idname.to_s} next is your turn") | |
| hash.delete(idname) | |
| puts "################ remove user #{idname.to_s}" | |
| end | |
| end | |
| on_mention do |service,messages| | |
| msgs = Plugin.filtering(:show_filter, messages.select{|m| not(m.from_me? or m[:retweet]) and m[:created] > DEFINED_TIME }).first | |
| msgs.each{|m| | |
| if m.to_s =~ /\d{1,3}%/ | |
| percentage = m.to_s.slice(/\d*/)[0].to_i | |
| if percentage >= 0 and percentage <= 100 | |
| hash[m.idname.to_sym] = percentage | |
| service.update(:message => "@#{m.idname} you are added successfully!!") | |
| puts "################ added user #{m.idname}" | |
| else | |
| service.update(:message => "@#{m.idname} wrong value. value should be between 0-100") | |
| end | |
| elsif m.to_s.split(' ')[1] =~ /\d+/ | |
| service.update(:message => "@#{m.idname} wrong format. value should be percentage. example: 100%, 45%, 0%") | |
| end | |
| } | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment