R.A. Epigonos et al.

[weechat] cron.pyを使う

cron.pyは、weechatでcron的なことをするためのスクリプト。

cron.pyのロード

/python load python/cron.py
03:00:40 weechat | python: loading script "/**********/.weechat/python/cron.py"
03:00:40 weechat | python: registered script "cron", version 0.3 (Time-based scheduler, like cron and at)
03:00:40 weechat | cron: 0 job loaded from "/**********/.weechat/cron.txt"

ロードの確認。

/python
03:04:06 weechat | python scripts loaded:
03:04:06 weechat |   cron v0.3 - Time-based scheduler, like cron and at

使い方の確認。

/help cron
03:04:50 weechat | [python]  /cron  list
03:04:50 weechat |                  add <minute> <hour> <monthday> <month> <weekday> <repeat> <buffer> <command>
03:04:50 weechat |                  del <number>|-all
03:04:50 weechat |                  exec <number>
03:04:50 weechat |                  reload|save
03:04:50 weechat |
03:04:50 weechat | Manage jobs in crontab
03:04:50 weechat |
03:04:50 weechat |     list: display jobs in crontab
03:04:50 weechat |      add: add a job in crontab
03:04:50 weechat |   minute: minute (0-59)
03:04:50 weechat |     hour: hour (0-23)
03:04:50 weechat | monthday: day of month (1-31)
03:04:50 weechat |    month: month (1-12)
03:04:50 weechat |  weekday: day of week (0-6, or name: sun (0), mon (1), tue (2), wed (3), thu (4), fri (5), sat (6))
03:04:50 weechat |   repeat: number of times job will be executed, must be >= 1 or special value * (repeat forever)
03:04:50 weechat |   buffer: buffer where command is executed
03:04:50 weechat |           ("current" for current buffer, "core.weechat" for WeeChat core buffer)
03:04:50 weechat |  command: a keyword, followed by arguments:
03:04:50 weechat |           - command: execute a command (starting with "/") or send text to buffer (like input)
03:04:50 weechat |           - commands: execute many commands separated by ";"
03:04:50 weechat |           - print: print a message on buffer
03:04:50 weechat |           - print_hl: print a message on buffer with "highlight" notify on line
03:04:50 weechat |           - print_msg: print a message on buffer with "message" notify on line
03:04:50 weechat |           - python: evaluate python code
03:04:50 weechat |      del: remove job(s) from crontab
03:04:50 weechat |   number: job number
03:04:50 weechat |     -all: remove all jobs
03:04:50 weechat |     exec: execute a command for a job (useful for testing command)
03:04:50 weechat |   reload: reload crontab file (automatic by default)
03:04:50 weechat |     save: save current crontab to file (automatic by default)
03:04:50 weechat |
03:04:50 weechat | Format for time and date is similar to crontab, see man 5 crontab.
03:04:50 weechat |
03:04:50 weechat | Examples:
03:04:50 weechat |   Display "short drink!" at 12:00 each day:
03:04:50 weechat |     /cron add 0 12 * * * * core.weechat print short drink!
03:04:50 weechat |   Same example with python code:
03:04:50 weechat |     /cron add 0 12 * * * * core.weechat python weechat.prnt("", "short drink!")
03:04:50 weechat |   Set away status on all servers at 23:30:
03:04:50 weechat |     /cron add 30 23 * * * * core.weechat command /away -all I am sleeping
03:04:50 weechat |   Remove away status on all servers at 07:00:
03:04:50 weechat |     /cron add 0 7 * * * * core.weechat command /away -all I am sleeping
03:04:50 weechat |   Set away status on all servers at 10:00 every sunday:
03:04:50 weechat |     /cron add 0 10 * * sun * core.weechat command /away -all I am playing tennis
03:04:50 weechat |   Say "hello" on IRC channel #private at 08:00 from monday to friday:
03:04:50 weechat |     /cron add 0 8 * * mon-fri * irc.freenode.#private command hello
03:04:50 weechat |   Display "wake up!" at 06:00 next monday, only one time, with highlight:
03:04:50 weechat |     /cron add 0 6 * * mon 1 core.weechat print_hl wake up!
03:04:50 weechat |   Delete first entry in crontab:
03:04:50 weechat |     /cron del 1

ヘルプを元に、1月1日0時0分に特定のチャンネル宛に"Happy New Year!!"と発言するcron設定を追加してみる。

/cron add 0 0 1 1 * * irc.freenode.#weechat command Happy New Year!!
03:11:03 weechat | cron: job added:  0 0 1 1 * * irc.freenode.#weechat command Happy New Year!!

cronの確認。

/cron list
03:11:27 weechat | crontab:
03:11:27 weechat |   [001] 0 0 1 1 * * irc.freenode.#weechat command Happy New Year!!

リファレンス

  1. WeeChat, the extensible chat client
  2. WeeChat :: download
  3. WeeChat User’s Guide
  4. WeeChat :: scripts
  5. WeeChat :: scripts
  6. WeeChat :: scripts

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2010-03-20T03:15:43+09:00
  2. Modified: 2010-03-20T03:15:43+09:00
  3. Generated: 2024-11-18T23:09:16+09:00