-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAliasModule.php
More file actions
34 lines (28 loc) · 1.08 KB
/
AliasModule.php
File metadata and controls
34 lines (28 loc) · 1.08 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
<?php
namespace kjBotModule\kj415j45\CoreModule;
use kjBot\Framework\Module;
use kjBot\Framework\Message;
use kjBot\Framework\Event\MessageEvent;
class AliasModule extends Module{
public function process(array $args, MessageEvent $event): Message{
Access::Control($event)->hasLevelOrDie(AccessLevel::Supporter);
return $event->sendBack(
Session::Start($event->getId())
->prompt('请输入要设置的别名:', __CLASS__, 'setAliasName')
);
}
public function setAliasName($event){
(new Alias($event->getId()))->setAlias($event->getMsg(), NULL);
return $event->sendBack(
Session::Start($event->getId())
->prompt('请输入要映射的命令:', __CLASS__, 'setAlias')
);
}
public function setAlias($event){
$alias = new Alias($event->getId());
$aliasName = array_search(NULL, $alias->getAlias());
$alias->setAlias($aliasName, $event->getMsg());
Session::Stop($event->getId());
return $event->sendBack('设置成功');
}
}