-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSessionPlugin.php
More file actions
30 lines (27 loc) · 1.05 KB
/
SessionPlugin.php
File metadata and controls
30 lines (27 loc) · 1.05 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
<?php
namespace kjBotModule\kj415j45\CoreModule;
use kjBot\Framework\Plugin;
use kjBot\Framework\Event\MessageEvent;
use kjBot\Framework\DataStorage;
use kjBot\Framework\Message;
use kjBot\Framework\QuitException;
use kjBot\Framework\SilenceModule;
class SessionPlugin extends Plugin{
public $handleDepth = 1;
public function message(MessageEvent $event): ?Message{
$session = json_decode(DataStorage::GetData("CoreModule.Session/{$event->getId()}"));
if($session !== NULL){
SilenceModule::$silence = true;
try{
$obj = (new \ReflectionClass($session->class))->newInstance();
$method = new \ReflectionMethod($session->class, $session->method);
return $msg = $method->invoke($obj, $event);
}catch(\ReflectionException $e){
d("Reflect error: {$e->getMessage()}");
q('反射你的会话文件失败,请联系master');
}catch(QuitException $e){
throw $e;
}
}else return NULL;
}
}