-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplugins_api.php
More file actions
66 lines (66 loc) · 2.07 KB
/
plugins_api.php
File metadata and controls
66 lines (66 loc) · 2.07 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace tzdtwsj\TzBot;
function RegisterPlugin(string $name,string $description,array $version=array(1,0,0),array $order_description=array()): bool{
return \regplugin($name,$description,$version,$order_description);
}
function RegisterCmd(string $command,string $usage,callable $func,bool $can_get_for_help=true,int $permission=0,bool $must_at=false,bool $group=true,bool $private=true): bool{
return \regcmd($command,$usage,$func,$can_get_for_help,$permission,$must_at,$group,$private);
}
function RegisterConsoleCmd(string $cmd,string $description,string $usage,callable $func): bool{
return \regccmd($cmd,$description,$usage,$func);
}
function RunOnTime(array $time,callable $func): bool{
return \run_on_time($time,$func);
}
function SendMsg(array $param,string $msg,bool $auto_at=false,bool $all_is_string=false){
return \send_msg($param,$msg,$auto_at,$all_is_string);
}
function SendGroupMsg(int $group_id,string $message,bool $all_is_string=true){
return \send_group_msg($group_id,$message,$all_is_string);
}
function SendPivateMsg(int $user_id,string $message,bool $all_is_string=false){
return \send_private_msg($user_id,$message,$all_is_string);
}
function GetAllGroups(){
return \get_all_groups();
}
function GetUserPermission(array $param){
return \get_user_permission($param);
}
function RequireDepend(string $file){
return \require_depend($file);
}
function GetLoadedPlugins(){
return \get_loaded_plugins();
}
function JsonFileGet(string $file,string $to_array=false){
if(file_exists($file)){
if(is_dir($file)){
throw new Exception("是一个目录");
}else{
$fi = fopen($file,"r");
$text = fread($fi,filesize($file)+1);
fclose($fi);
$decode_text = json_decode($text,$to_array);
if($decode_text==false){
return false;
}else{
return $decode_text;
}
}
}else{
throw new Exception("文件不存在");
}
}
function JsonFileWrite(string $file,array|stdclass $json){
if(file_exists($file)){
if(is_dir($file)){
throw new Exception("是一个目录");
}
}
$fi = fopen($file,"w");
fwrite($fi,json_encode($json));
fclose($fi);
return true;
}
?>