pygpt-net 2.6.1__py3-none-any.whl → 2.6.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pygpt_net/CHANGELOG.txt +4 -0
- pygpt_net/__init__.py +3 -3
- pygpt_net/app.py +15 -1
- pygpt_net/controller/chat/response.py +5 -3
- pygpt_net/controller/chat/stream.py +40 -2
- pygpt_net/controller/plugins/plugins.py +25 -0
- pygpt_net/controller/presets/editor.py +33 -88
- pygpt_net/controller/presets/experts.py +20 -1
- pygpt_net/controller/presets/presets.py +2 -2
- pygpt_net/controller/ui/mode.py +17 -66
- pygpt_net/core/agents/runner.py +15 -7
- pygpt_net/core/experts/experts.py +3 -3
- pygpt_net/data/config/config.json +3 -3
- pygpt_net/data/config/models.json +3 -3
- pygpt_net/data/locale/locale.de.ini +2 -0
- pygpt_net/data/locale/locale.en.ini +2 -0
- pygpt_net/data/locale/locale.es.ini +2 -0
- pygpt_net/data/locale/locale.fr.ini +2 -0
- pygpt_net/data/locale/locale.it.ini +2 -0
- pygpt_net/data/locale/locale.pl.ini +3 -1
- pygpt_net/data/locale/locale.uk.ini +2 -0
- pygpt_net/data/locale/locale.zh.ini +2 -0
- pygpt_net/plugin/base/plugin.py +35 -3
- pygpt_net/plugin/bitbucket/__init__.py +12 -0
- pygpt_net/plugin/bitbucket/config.py +267 -0
- pygpt_net/plugin/bitbucket/plugin.py +125 -0
- pygpt_net/plugin/bitbucket/worker.py +569 -0
- pygpt_net/plugin/facebook/__init__.py +12 -0
- pygpt_net/plugin/facebook/config.py +359 -0
- pygpt_net/plugin/facebook/plugin.py +114 -0
- pygpt_net/plugin/facebook/worker.py +698 -0
- pygpt_net/plugin/github/__init__.py +12 -0
- pygpt_net/plugin/github/config.py +441 -0
- pygpt_net/plugin/github/plugin.py +124 -0
- pygpt_net/plugin/github/worker.py +674 -0
- pygpt_net/plugin/google/__init__.py +12 -0
- pygpt_net/plugin/google/config.py +367 -0
- pygpt_net/plugin/google/plugin.py +126 -0
- pygpt_net/plugin/google/worker.py +826 -0
- pygpt_net/plugin/slack/__init__.py +12 -0
- pygpt_net/plugin/slack/config.py +349 -0
- pygpt_net/plugin/slack/plugin.py +116 -0
- pygpt_net/plugin/slack/worker.py +639 -0
- pygpt_net/plugin/telegram/__init__.py +12 -0
- pygpt_net/plugin/telegram/config.py +308 -0
- pygpt_net/plugin/telegram/plugin.py +118 -0
- pygpt_net/plugin/telegram/worker.py +563 -0
- pygpt_net/plugin/twitter/__init__.py +12 -0
- pygpt_net/plugin/twitter/config.py +491 -0
- pygpt_net/plugin/twitter/plugin.py +126 -0
- pygpt_net/plugin/twitter/worker.py +837 -0
- pygpt_net/provider/agents/llama_index/legacy/openai_assistant.py +35 -3
- pygpt_net/ui/base/config_dialog.py +4 -0
- pygpt_net/ui/dialog/preset.py +34 -77
- pygpt_net/ui/layout/toolbox/presets.py +2 -2
- pygpt_net/ui/main.py +3 -1
- {pygpt_net-2.6.1.dist-info → pygpt_net-2.6.2.dist-info}/METADATA +145 -2
- {pygpt_net-2.6.1.dist-info → pygpt_net-2.6.2.dist-info}/RECORD +61 -33
- {pygpt_net-2.6.1.dist-info → pygpt_net-2.6.2.dist-info}/LICENSE +0 -0
- {pygpt_net-2.6.1.dist-info → pygpt_net-2.6.2.dist-info}/WHEEL +0 -0
- {pygpt_net-2.6.1.dist-info → pygpt_net-2.6.2.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# ================================================== #
|
|
4
|
+
# This file is a part of PYGPT package #
|
|
5
|
+
# Website: https://pygpt.net #
|
|
6
|
+
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
|
7
|
+
# MIT License #
|
|
8
|
+
# Created By : Marcin Szczygliński #
|
|
9
|
+
# Updated Date: 2025.08.14 00:00:00 #
|
|
10
|
+
# ================================================== #
|
|
11
|
+
|
|
12
|
+
from pygpt_net.plugin.base.config import BaseConfig, BasePlugin
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Config(BaseConfig):
|
|
16
|
+
def __init__(self, plugin: BasePlugin = None, *args, **kwargs):
|
|
17
|
+
super(Config, self).__init__(plugin)
|
|
18
|
+
self.plugin = plugin
|
|
19
|
+
|
|
20
|
+
def from_defaults(self, plugin: BasePlugin = None):
|
|
21
|
+
# Mode / HTTP
|
|
22
|
+
plugin.add_option(
|
|
23
|
+
"mode",
|
|
24
|
+
type="combo",
|
|
25
|
+
value="bot",
|
|
26
|
+
keys=["bot", "user"],
|
|
27
|
+
label="Mode",
|
|
28
|
+
description="bot = Bot API (token). user = User account via Telethon.",
|
|
29
|
+
)
|
|
30
|
+
plugin.add_option(
|
|
31
|
+
"api_base",
|
|
32
|
+
type="text",
|
|
33
|
+
value="https://api.telegram.org",
|
|
34
|
+
label="API base (Bot)",
|
|
35
|
+
description="Telegram Bot API base.",
|
|
36
|
+
)
|
|
37
|
+
plugin.add_option(
|
|
38
|
+
"http_timeout",
|
|
39
|
+
type="int",
|
|
40
|
+
value=30,
|
|
41
|
+
label="HTTP timeout (s)",
|
|
42
|
+
description="Requests timeout in seconds.",
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# Bot options
|
|
46
|
+
plugin.add_option(
|
|
47
|
+
"bot_token",
|
|
48
|
+
type="textarea",
|
|
49
|
+
value="",
|
|
50
|
+
label="Bot token",
|
|
51
|
+
description="Token from BotFather.",
|
|
52
|
+
secret=True,
|
|
53
|
+
)
|
|
54
|
+
plugin.add_option(
|
|
55
|
+
"default_parse_mode",
|
|
56
|
+
type="combo",
|
|
57
|
+
value="HTML",
|
|
58
|
+
keys=["", "HTML", "Markdown", "MarkdownV2"],
|
|
59
|
+
label="Default parse_mode",
|
|
60
|
+
description="Default parse mode for sending text/captions.",
|
|
61
|
+
)
|
|
62
|
+
plugin.add_option(
|
|
63
|
+
"default_disable_preview",
|
|
64
|
+
type="bool",
|
|
65
|
+
value=False,
|
|
66
|
+
label="Disable link previews (default)",
|
|
67
|
+
description="Applies when not overridden in command.",
|
|
68
|
+
)
|
|
69
|
+
plugin.add_option(
|
|
70
|
+
"default_disable_notification",
|
|
71
|
+
type="bool",
|
|
72
|
+
value=False,
|
|
73
|
+
label="Disable notifications (default)",
|
|
74
|
+
description="Applies when not overridden in command.",
|
|
75
|
+
)
|
|
76
|
+
plugin.add_option(
|
|
77
|
+
"default_protect_content",
|
|
78
|
+
type="bool",
|
|
79
|
+
value=False,
|
|
80
|
+
label="Protect content (default)",
|
|
81
|
+
description="Applies when not overridden in command.",
|
|
82
|
+
)
|
|
83
|
+
plugin.add_option(
|
|
84
|
+
"last_update_id",
|
|
85
|
+
type="text",
|
|
86
|
+
value="",
|
|
87
|
+
label="(auto) last update id",
|
|
88
|
+
description="Stored after tg_get_updates.",
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
# User options (Telethon)
|
|
92
|
+
plugin.add_option(
|
|
93
|
+
"api_id",
|
|
94
|
+
type="text",
|
|
95
|
+
value="",
|
|
96
|
+
label="API ID (user mode)",
|
|
97
|
+
description="Get from https://my.telegram.org (Development tools).",
|
|
98
|
+
secret=False,
|
|
99
|
+
)
|
|
100
|
+
plugin.add_option(
|
|
101
|
+
"api_hash",
|
|
102
|
+
type="text",
|
|
103
|
+
value="",
|
|
104
|
+
label="API Hash (user mode)",
|
|
105
|
+
description="Get from https://my.telegram.org (Development tools).",
|
|
106
|
+
secret=True,
|
|
107
|
+
)
|
|
108
|
+
plugin.add_option(
|
|
109
|
+
"phone_number",
|
|
110
|
+
type="text",
|
|
111
|
+
value="",
|
|
112
|
+
label="Phone number (+CC...)",
|
|
113
|
+
description="Used to send login code in user mode.",
|
|
114
|
+
)
|
|
115
|
+
plugin.add_option(
|
|
116
|
+
"password_2fa",
|
|
117
|
+
type="text",
|
|
118
|
+
value="",
|
|
119
|
+
label="(optional) 2FA password",
|
|
120
|
+
description="Used if your account has two-step verification.",
|
|
121
|
+
secret=True,
|
|
122
|
+
)
|
|
123
|
+
plugin.add_option(
|
|
124
|
+
"user_session",
|
|
125
|
+
type="textarea",
|
|
126
|
+
value="",
|
|
127
|
+
label="(auto) Session (StringSession)",
|
|
128
|
+
description="Saved after successful login in user mode.",
|
|
129
|
+
secret=True,
|
|
130
|
+
)
|
|
131
|
+
plugin.add_option(
|
|
132
|
+
"auto_login_begin",
|
|
133
|
+
type="bool",
|
|
134
|
+
value=True,
|
|
135
|
+
label="Auto-begin login when needed",
|
|
136
|
+
description="If a user command needs auth and session missing, send code automatically (requires phone).",
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
# ---------------- Commands ----------------
|
|
140
|
+
|
|
141
|
+
# Auth (user)
|
|
142
|
+
plugin.add_cmd(
|
|
143
|
+
"tg_login_begin",
|
|
144
|
+
instruction="Begin Telegram user login (sends code to phone).",
|
|
145
|
+
params=[
|
|
146
|
+
{"name": "phone", "type": "str", "required": False, "description": "Phone E.164 (defaults to option)"},
|
|
147
|
+
],
|
|
148
|
+
enabled=True,
|
|
149
|
+
description="Auth (user): begin login",
|
|
150
|
+
tab="auth",
|
|
151
|
+
)
|
|
152
|
+
plugin.add_cmd(
|
|
153
|
+
"tg_login_complete",
|
|
154
|
+
instruction="Complete login with code (and optional 2FA password).",
|
|
155
|
+
params=[
|
|
156
|
+
{"name": "phone", "type": "str", "required": False, "description": "Phone E.164 (defaults to option)"},
|
|
157
|
+
{"name": "code", "type": "str", "required": True, "description": "Code received in Telegram"},
|
|
158
|
+
{"name": "password", "type": "str", "required": False, "description": "2FA password if required"},
|
|
159
|
+
],
|
|
160
|
+
enabled=True,
|
|
161
|
+
description="Auth (user): complete login",
|
|
162
|
+
tab="auth",
|
|
163
|
+
)
|
|
164
|
+
plugin.add_cmd(
|
|
165
|
+
"tg_logout",
|
|
166
|
+
instruction="Log out and clear saved session.",
|
|
167
|
+
params=[],
|
|
168
|
+
enabled=True,
|
|
169
|
+
description="Auth (user): logout",
|
|
170
|
+
tab="auth",
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
# Info
|
|
174
|
+
plugin.add_cmd(
|
|
175
|
+
"tg_mode",
|
|
176
|
+
instruction="Return current mode (bot|user).",
|
|
177
|
+
params=[],
|
|
178
|
+
enabled=True,
|
|
179
|
+
description="Info: mode",
|
|
180
|
+
tab="info",
|
|
181
|
+
)
|
|
182
|
+
plugin.add_cmd(
|
|
183
|
+
"tg_me",
|
|
184
|
+
instruction="Get authorized identity: Bot getMe or User get_me.",
|
|
185
|
+
params=[],
|
|
186
|
+
enabled=True,
|
|
187
|
+
description="Info: me",
|
|
188
|
+
tab="info",
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
# Messaging
|
|
192
|
+
plugin.add_cmd(
|
|
193
|
+
"tg_send_message",
|
|
194
|
+
instruction="Send text message to chat/channel.",
|
|
195
|
+
params=[
|
|
196
|
+
{"name": "chat", "type": "str", "required": True, "description": "chat id or @username"},
|
|
197
|
+
{"name": "text", "type": "str", "required": True, "description": "Message text"},
|
|
198
|
+
{"name": "parse_mode", "type": "str", "required": False, "description": "HTML|Markdown|MarkdownV2"},
|
|
199
|
+
{"name": "disable_web_page_preview", "type": "bool", "required": False, "description": "Default from options"},
|
|
200
|
+
{"name": "disable_notification", "type": "bool", "required": False, "description": "Default from options"},
|
|
201
|
+
{"name": "protect_content", "type": "bool", "required": False, "description": "Default from options"},
|
|
202
|
+
{"name": "reply_to_message_id", "type": "int", "required": False, "description": "Reply to"},
|
|
203
|
+
],
|
|
204
|
+
enabled=True,
|
|
205
|
+
description="Messaging: send message",
|
|
206
|
+
tab="messages",
|
|
207
|
+
)
|
|
208
|
+
plugin.add_cmd(
|
|
209
|
+
"tg_send_photo",
|
|
210
|
+
instruction="Send photo to chat/channel.",
|
|
211
|
+
params=[
|
|
212
|
+
{"name": "chat", "type": "str", "required": True, "description": "chat id or @username"},
|
|
213
|
+
{"name": "photo", "type": "str", "required": True, "description": "Local path, URL or file_id"},
|
|
214
|
+
{"name": "caption", "type": "str", "required": False, "description": "Caption"},
|
|
215
|
+
{"name": "parse_mode", "type": "str", "required": False, "description": "HTML|Markdown|MarkdownV2"},
|
|
216
|
+
{"name": "disable_notification", "type": "bool", "required": False, "description": "Default from options"},
|
|
217
|
+
{"name": "protect_content", "type": "bool", "required": False, "description": "Default from options"},
|
|
218
|
+
],
|
|
219
|
+
enabled=True,
|
|
220
|
+
description="Messaging: send photo",
|
|
221
|
+
tab="messages",
|
|
222
|
+
)
|
|
223
|
+
plugin.add_cmd(
|
|
224
|
+
"tg_send_document",
|
|
225
|
+
instruction="Send document/file to chat/channel.",
|
|
226
|
+
params=[
|
|
227
|
+
{"name": "chat", "type": "str", "required": True, "description": "chat id or @username"},
|
|
228
|
+
{"name": "document", "type": "str", "required": True, "description": "Local path, URL or file_id"},
|
|
229
|
+
{"name": "caption", "type": "str", "required": False, "description": "Caption"},
|
|
230
|
+
{"name": "disable_notification", "type": "bool", "required": False, "description": "Default from options"},
|
|
231
|
+
{"name": "protect_content", "type": "bool", "required": False, "description": "Default from options"},
|
|
232
|
+
],
|
|
233
|
+
enabled=True,
|
|
234
|
+
description="Messaging: send document",
|
|
235
|
+
tab="messages",
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
# Chats
|
|
239
|
+
plugin.add_cmd(
|
|
240
|
+
"tg_get_chat",
|
|
241
|
+
instruction="Get chat info by id or @username.",
|
|
242
|
+
params=[
|
|
243
|
+
{"name": "chat", "type": "str", "required": True, "description": "chat id or @username"},
|
|
244
|
+
],
|
|
245
|
+
enabled=True,
|
|
246
|
+
description="Chats: get chat",
|
|
247
|
+
tab="chats",
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
# Updates / Files (bot)
|
|
251
|
+
plugin.add_cmd(
|
|
252
|
+
"tg_get_updates",
|
|
253
|
+
instruction="Poll updates (bot mode). Stores last_update_id automatically.",
|
|
254
|
+
params=[
|
|
255
|
+
{"name": "offset", "type": "int", "required": False, "description": "Start from this update_id+1"},
|
|
256
|
+
{"name": "timeout", "type": "int", "required": False, "description": "Long polling timeout seconds"},
|
|
257
|
+
{"name": "allowed_updates", "type": "list", "required": False, "description": "update types list"},
|
|
258
|
+
],
|
|
259
|
+
enabled=True,
|
|
260
|
+
description="Bot: getUpdates",
|
|
261
|
+
tab="updates",
|
|
262
|
+
)
|
|
263
|
+
plugin.add_cmd(
|
|
264
|
+
"tg_download_file",
|
|
265
|
+
instruction="Download file by file_id (bot mode).",
|
|
266
|
+
params=[
|
|
267
|
+
{"name": "file_id", "type": "str", "required": True, "description": "file_id from a message"},
|
|
268
|
+
{"name": "save_as", "type": "str", "required": False, "description": "Local path (relative=./data)"},
|
|
269
|
+
],
|
|
270
|
+
enabled=True,
|
|
271
|
+
description="Bot: download file",
|
|
272
|
+
tab="updates",
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
# Contacts / Dialogs / Messages (user)
|
|
276
|
+
plugin.add_cmd(
|
|
277
|
+
"tg_contacts_list",
|
|
278
|
+
instruction="List contacts (user mode).",
|
|
279
|
+
params=[],
|
|
280
|
+
enabled=True,
|
|
281
|
+
description="User: contacts list",
|
|
282
|
+
tab="user",
|
|
283
|
+
)
|
|
284
|
+
plugin.add_cmd(
|
|
285
|
+
"tg_dialogs_list",
|
|
286
|
+
instruction="List recent dialogs/chats (user mode).",
|
|
287
|
+
params=[
|
|
288
|
+
{"name": "limit", "type": "int", "required": False, "description": "Default 20"},
|
|
289
|
+
],
|
|
290
|
+
enabled=True,
|
|
291
|
+
description="User: dialogs list",
|
|
292
|
+
tab="user",
|
|
293
|
+
)
|
|
294
|
+
plugin.add_cmd(
|
|
295
|
+
"tg_messages_get",
|
|
296
|
+
instruction="Get recent messages from chat (user mode).",
|
|
297
|
+
params=[
|
|
298
|
+
{"name": "chat", "type": "str", "required": True, "description": "chat id or @username"},
|
|
299
|
+
{"name": "limit", "type": "int", "required": False, "description": "Default 30"},
|
|
300
|
+
{"name": "offset_id", "type": "int", "required": False, "description": "Pagination"},
|
|
301
|
+
{"name": "min_id", "type": "int", "required": False, "description": "Fetch > min_id"},
|
|
302
|
+
{"name": "max_id", "type": "int", "required": False, "description": "Fetch < max_id"},
|
|
303
|
+
{"name": "search", "type": "str", "required": False, "description": "Search query"},
|
|
304
|
+
],
|
|
305
|
+
enabled=True,
|
|
306
|
+
description="User: messages get",
|
|
307
|
+
tab="user",
|
|
308
|
+
)
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# ================================================== #
|
|
4
|
+
# This file is a part of PYGPT package #
|
|
5
|
+
# Website: https://pygpt.net #
|
|
6
|
+
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
|
7
|
+
# MIT License #
|
|
8
|
+
# Created By : Marcin Szczygliński #
|
|
9
|
+
# Updated Date: 2025.07.14 00:00:00 #
|
|
10
|
+
# ================================================== #
|
|
11
|
+
|
|
12
|
+
import os
|
|
13
|
+
|
|
14
|
+
from pygpt_net.plugin.base.plugin import BasePlugin
|
|
15
|
+
from pygpt_net.core.events import Event
|
|
16
|
+
from pygpt_net.item.ctx import CtxItem
|
|
17
|
+
|
|
18
|
+
from .config import Config
|
|
19
|
+
from .worker import Worker
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Plugin(BasePlugin):
|
|
23
|
+
def __init__(self, *args, **kwargs):
|
|
24
|
+
super(Plugin, self).__init__(*args, **kwargs)
|
|
25
|
+
self.id = "telegram"
|
|
26
|
+
self.name = "Telegram"
|
|
27
|
+
self.description = "Send messages, photos, and documents; manage chats and contacts."
|
|
28
|
+
self.prefix = "API"
|
|
29
|
+
self.order = 100
|
|
30
|
+
self.allowed_cmds = [
|
|
31
|
+
"tg_login_begin",
|
|
32
|
+
"tg_login_complete",
|
|
33
|
+
"tg_logout",
|
|
34
|
+
"tg_mode",
|
|
35
|
+
"tg_me",
|
|
36
|
+
"tg_send_message",
|
|
37
|
+
"tg_send_photo",
|
|
38
|
+
"tg_send_document",
|
|
39
|
+
"tg_get_chat",
|
|
40
|
+
"tg_get_updates",
|
|
41
|
+
"tg_download_file",
|
|
42
|
+
"tg_contacts_list",
|
|
43
|
+
"tg_dialogs_list",
|
|
44
|
+
"tg_messages_get"
|
|
45
|
+
]
|
|
46
|
+
self.use_locale = False
|
|
47
|
+
self.worker = None
|
|
48
|
+
self.config = Config(self)
|
|
49
|
+
self.init_options()
|
|
50
|
+
|
|
51
|
+
def init_options(self):
|
|
52
|
+
"""Initialize options"""
|
|
53
|
+
self.config.from_defaults(self)
|
|
54
|
+
|
|
55
|
+
def handle(self, event: Event, *args, **kwargs):
|
|
56
|
+
"""
|
|
57
|
+
Handle dispatched event
|
|
58
|
+
|
|
59
|
+
:param event: event object
|
|
60
|
+
:param args: event args
|
|
61
|
+
:param kwargs: event kwargs
|
|
62
|
+
"""
|
|
63
|
+
name = event.name
|
|
64
|
+
data = event.data
|
|
65
|
+
ctx = event.ctx
|
|
66
|
+
|
|
67
|
+
if name == Event.CMD_SYNTAX:
|
|
68
|
+
self.cmd_syntax(data)
|
|
69
|
+
|
|
70
|
+
elif name == Event.CMD_EXECUTE:
|
|
71
|
+
self.cmd(
|
|
72
|
+
ctx,
|
|
73
|
+
data['commands'],
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
def cmd_syntax(self, data: dict):
|
|
77
|
+
"""
|
|
78
|
+
Event: CMD_SYNTAX
|
|
79
|
+
|
|
80
|
+
:param data: event data dict
|
|
81
|
+
"""
|
|
82
|
+
for option in self.allowed_cmds:
|
|
83
|
+
if self.has_cmd(option):
|
|
84
|
+
data['cmd'].append(self.get_cmd(option)) # append command
|
|
85
|
+
|
|
86
|
+
def cmd(self, ctx: CtxItem, cmds: list):
|
|
87
|
+
"""
|
|
88
|
+
Event: CMD_EXECUTE
|
|
89
|
+
|
|
90
|
+
:param ctx: CtxItem
|
|
91
|
+
:param cmds: commands dict
|
|
92
|
+
"""
|
|
93
|
+
is_cmd = False
|
|
94
|
+
my_commands = []
|
|
95
|
+
for item in cmds:
|
|
96
|
+
if item["cmd"] in self.allowed_cmds:
|
|
97
|
+
my_commands.append(item)
|
|
98
|
+
is_cmd = True
|
|
99
|
+
|
|
100
|
+
if not is_cmd:
|
|
101
|
+
return
|
|
102
|
+
|
|
103
|
+
# set state: busy
|
|
104
|
+
self.cmd_prepare(ctx, my_commands)
|
|
105
|
+
|
|
106
|
+
try:
|
|
107
|
+
worker = Worker()
|
|
108
|
+
worker.from_defaults(self)
|
|
109
|
+
worker.cmds = my_commands
|
|
110
|
+
worker.ctx = ctx
|
|
111
|
+
|
|
112
|
+
if not self.is_async(ctx):
|
|
113
|
+
worker.run()
|
|
114
|
+
return
|
|
115
|
+
worker.run_async()
|
|
116
|
+
|
|
117
|
+
except Exception as e:
|
|
118
|
+
self.error(e)
|