File: notification.rb

package info (click to toggle)
mikutter 3.5.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,256 kB
  • ctags: 2,165
  • sloc: ruby: 19,079; sh: 205; makefile: 20
file content (21 lines) | stat: -rw-r--r-- 930 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# coding: utf-8

Plugin.create :notification do
  settings(_('お知らせ')) do
    boolean(_('ステータスバーにmikutterから配信されるお知らせを表示する'), :notification_enable)
      .tooltip(_('チェックすると、ステータスバーに表示することが特にない間、mikutterの最新情報を表示しておきます。この変更は再起動後に適用されます'))
  end

  def main
    return unless UserConfig[:notification_enable]
    next_time = (Time.new + 86400).freeze
    Reserver.new(next_time){ main }
    open('http://mikutter.hachune.net/notification.json') do |io|
      JSON.parse(io.read, symbolize_names: true).sort_by{|n| n[:expire]}.reverse_each do |node|
        Plugin.call(:gui_window_rewindstatus, Plugin::GUI::Window.instance(:default), node[:text], [Time.iso8601(node[:expire]),next_time].min)
      end
    end
  end

  Delayer.new{ Thread.new{ main } }
end