File: template

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 (28 lines) | stat: -rw-r--r-- 625 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#
# プラグインテンプレート
#

# これを基にプラグインを作って行く
# 別にこれを基にしなくてもいい
# 以下、MyPluginプラグインを作る例

require 'utils'
require 'plugin/plugin'

module Plugin
  class MyPlugin < Plugin

    # 毎分のイベントハンドラ
    def onperiod(watch)
      return watch.post(Message.new('hello, MyPlugin!', [self.name]))
    end

    def oncall(watch, message, tag)
      return watch.post(Message.new("called by you", [self.name], message))
    end
  end

end

# プラグインの登録
Plugin::Ring.push Plugin::MyPlugin.new,[:period, :call]