Debian Codegraph @

plugin/notification/notification.rb

raw symbols SCIP
1 # coding: utf-8
2 require 'json'
3
4 Plugin.create :notification do
5 settings(_('お知らせ')) do
6 boolean(_('ステータスバーにmikutterから配信されるお知らせを表示する'), :notification_enable)
7 .tooltip(_('チェックすると、ステータスバーに表示することが特にない間、mikutterの最新情報を表示しておきます。この変更は再起動後に適用されます'))
8 end
9
10 def main
11 return unless UserConfig[:notification_enable]
12 next_time = (Time.new + 86400).freeze
13 Delayer.new(delay: next_time, &method(:main))
14 Thread.new do
15 URI('https://mikutter.hachune.net/notification.json').open('rb:utf-8') do |io|
16 JSON.parse(io.read, symbolize_names: true).sort_by{|n| n[:expire]}.reverse_each do |node|
17 Plugin.call(:gui_window_rewindstatus, Plugin::GUI::Window.instance(:default), node[:text], [Time.iso8601(node[:expire]),next_time].min)
18 end
19 end
20 end
21 end
22
23 Delayer.new(&method(:main))
24 end