-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin_cmd_help.py
56 lines (44 loc) · 2.16 KB
/
plugin_cmd_help.py
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
# Плагин для озвучивания достуаных текущих команд VA
# author: Mikhaylenko Sergey
from datetime import datetime
from vacore import VACore
import random
# функция на старте
def start(core:VACore):
manifest = { # возвращаем настройки плагина - словарь
"name": "Подсказка по всем актуальным командам", # короткое описание
"version": "1.0", # версия
"require_online": False, # требует ли онлайн?
"commands": { # набор скиллов. Фразы скилла разделены | . Если найдены - вызывается функция
"что|что умеешь|что можешь": help_start,
}
}
return manifest
def help_start(core:VACore, phrase: str): # в phrase находится остаток фразы после названия скилла, если юзер сказал больше
core.say("Расказать кратко, подробно или отмена")
core.context_set(menu_main) # меню - набор фраз и правил, в конце файла
def help_cancel(core:VACore, phrase: str):
core.say("хорошо")
return
def help_short(core:VACore, phrase: str):
help_cmd(core,phrase,"short")
return
def help_desc(core:VACore, phrase: str):
help_cmd(core,phrase,"desc")
return
menu_main = {"кратко|коротко":help_short,"подробно":help_desc,"отмена":help_cancel}
def help_cmd(core:VACore, phrase: str, mode_help: str):
for manifs in core.plugin_manifests.keys():
commands=core.plugin_manifests[manifs].get('commands')
name=core.plugin_manifests[manifs].get('name')
if commands!=None:
for keyall in commands.keys():
keys = keyall.split("|")
msg=keys[0]
if msg=="что умеешь":
continue
if mode_help=='desc':
msg=msg + ' - '+name
print(msg)
core.say(msg)
return