| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- #nop vim: set filetype=tt:;
- /*
- 模块名称:框架依赖的工具函数
- 模块说明:本文件属于框架代码的一部分,不建议修改。如有需求请在 GitHub 发 issue 或者 PR
- 版权声明:本文件属于 PaoTin++ 的一部分
- ===========
- PaoTin++ © 2020~2023 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 享有并保留一切法律权利
- 你可以在遵照 GPLv3 协议的基础之上使用、修改及重新分发本程序。
- ===========
- */
- #func {existsSession} {
- #local session {%1};
- #if { !@existsFunction{$session} && {@{$session}{true}} == {true} } {
- #return 1;
- };
- #else {
- #return 0;
- };
- };
- #func {existsVar} {
- #local var {%1};
- #if { &{$var} > 0 } {
- #return 1;
- };
- #else {
- #return 0;
- };
- };
- #func {existsAlias} {
- #local pName {%1};
- #local pClass {%2};
- #info alias save;
- #local idx {};
- #foreach {*{info[ALIASES][]}} {idx} {
- #local name {$info[ALIASES][$idx][arg1]};
- #local class {$info[ALIASES][$idx][class]};
- #if { "$name" == "$pName" && ( "$pClass" == "" || "$class" == "$pClass" ) } {
- #return 1;
- };
- };
- #return 0;
- };
- #func {existsFunction} {
- #local pName {%1};
- #local pClass {%2};
- #info function save;
- #local idx {};
- #foreach {*{info[FUNCTIONS][]}} {idx} {
- #local name {$info[FUNCTIONS][$idx][arg1]};
- #local class {$info[FUNCTIONS][$idx][class]};
- #if { "$name" == "$pName" && ( "$pClass" == "" || "$class" == "$pClass" ) } {
- #return 1;
- };
- };
- #return 0;
- };
- #func {existsJobPlugin} {
- #local job {%1};
- #return {@existsPlugin{job/$job}};
- };
- #func {existsPlugin} {
- #local plugin {%1};
- #if { @existsFile{plugins/${plugin}.tin} } {
- #return 1;
- };
- #if { @existsFile{plugins/$plugin/__init__.tin} } {
- #return 1;
- };
- #if { @existsFile{plugins/$plugin/__main__.tin} } {
- #return 1;
- };
- #return 0;
- };
- #func {mkdir} {
- #local dir {%1};
- #local output {};
- #line quiet #script output {mkdir -p $dir 2>/dev/null && test -d $dir && echo 1 || echo 0};
- #return $output[1];
- };
- #func {uuid} {
- #local now {};
- #local random {};
- #math random {1d1000};
- #format random {%%03d} {$random};
- #format now {%U};
- #return {${now}.$random};
- };
- #alias {load-config} {
- #local config {%1};
- #if { @isEmpty{$config} } {
- xtt.Usage load-config;
- #return;
- };
- load-file etc/${config}.tin;
- };
|