Merge "plugins" plugin into _core

master
Dan Elkouby 2020-08-02 14:45:25 +00:00
parent 3813ed60e8
commit dd49e13fbf
2 changed files with 13 additions and 17 deletions

View File

@ -1,17 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""
Show all loaded .plugins
"""
from telethon import events
@borg.on(events.NewMessage(pattern=r"\.plugins", outgoing=True))
async def _(event):
result = f'{len(borg._plugins)} plugins loaded:'
for name, mod in sorted(borg._plugins.items(), key=lambda t: t[0]):
desc = (mod.__doc__ or '__no description__').replace('\n', ' ').strip()
result += f'\n**{name}**: {desc}'
await event.edit(result)

View File

@ -48,3 +48,16 @@ async def remove(event):
if not borg.me.bot:
await asyncio.sleep(DELETE_TIMEOUT)
await borg.delete_messages(msg.to_id, msg)
@borg.on(borg.admin_cmd(r"plugins"))
async def list_plugins(event):
result = f'{len(borg._plugins)} plugins loaded:'
for name, mod in sorted(borg._plugins.items(), key=lambda t: t[0]):
desc = (mod.__doc__ or '__no description__').replace('\n', ' ').strip()
result += f'\n**{name}**: {desc}'
if not borg.me.bot:
await event.edit(result)
else:
await event.respond(result)