Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TimerLib

遅延タスクや定期タスクを呼び出すための簡単なタイマー機能を提供します。

前提

使い方例

from datetime import datetime, timedelta
from dncore.plugin import Plugin

# depends(plugin.yml) に TimerLib を加える
from dncore.extensions.timerlib import Timer, TimerTask


class ExamplePlugin(Plugin):
    def __init__(self):
        # Timerの初期化
        self.timer = Timer(self)  # Pluginインスタンスを紐づける
        
    async def on_enable(self):
        # 1分後にスケジュール
        self.timer.once(60, self.on_time)
        # 毎朝7時にスケジュール
        self.timer.daily(7, 0, self.on_morning)
        
    async def on_time(self, task: TimerTask):
        log.info("1分が経過しました!")

    async def on_morning(self, task: TimerTask):
        log.info("おはよう!")

About

簡単なタイマー機能を提供するライブラリプラグイン for dnCoreV6

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages