Last active
January 11, 2018 20:08
-
-
Save toshia/1306093 to your computer and use it in GitHub Desktop.
自動的によるほーする例。でもよるほーは手動でやれよ
This file contains 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
# -*- coding: utf-8 -*- | |
# say "よるほー" | |
# よるほーの例です。あくまでReserverのデモンストレーション用に作りました。 | |
# なので実戦投入はしないこと。よるほーは自分でタイミングを合わせることにこそ意義があるのです。 | |
Plugin.create(:yoruho) do | |
class << self | |
def main | |
Reserver.new(nextyrhtime){ | |
say_yoruho() | |
sleep 1 | |
main } end | |
# 次回のよるほー時間を取得 | |
def nextyrhtime | |
now = Time.new | |
result = Time.local(now.year, now.month, now.day, 0, 0) | |
while result < now | |
result += 86400 end | |
result end | |
# よるほーとつぶやく | |
def say_yoruho() | |
world, = Plugin.filtering(:world_current, nil) | |
compose(world, message: 'ておほー') end | |
end | |
main | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment