2020-03-16 21:02:05 -04:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2023-10-16 09:46:31 -04:00
|
|
|
|
|
|
|
from time import time_ns
|
|
|
|
|
|
|
|
from telethon import version
|
|
|
|
|
|
|
|
from ubot.micro_bot import micro_bot
|
|
|
|
|
|
|
|
ldr = micro_bot.loader
|
|
|
|
|
|
|
|
|
2020-05-02 17:04:27 -04:00
|
|
|
@ldr.add("del")
|
2020-05-01 10:27:07 -04:00
|
|
|
async def delete_message(event):
|
|
|
|
message_to_delete = await event.get_reply_message()
|
2020-05-26 14:23:04 -04:00
|
|
|
|
|
|
|
if message_to_delete and message_to_delete.from_id == (await event.client.get_me()).id:
|
2020-05-01 10:27:07 -04:00
|
|
|
await message_to_delete.delete()
|
|
|
|
|
|
|
|
|
2020-05-06 11:10:00 -04:00
|
|
|
@ldr.add("help")
|
|
|
|
async def help_cmd(event):
|
|
|
|
help_string = ""
|
|
|
|
|
|
|
|
for key, value in ldr.help_dict.items():
|
|
|
|
help_string += f"\n**{key}**: "
|
|
|
|
for info in value:
|
|
|
|
help_string += f"`{info}`, "
|
|
|
|
help_string = help_string.rstrip(", ")
|
|
|
|
|
2020-06-06 11:04:14 -04:00
|
|
|
await event.reply(f"**Available commands:**\n{help_string}")
|
2020-05-06 11:10:00 -04:00
|
|
|
|
|
|
|
|
2020-05-02 17:04:27 -04:00
|
|
|
@ldr.add("ping")
|
2020-05-02 16:43:52 -04:00
|
|
|
async def ping(event):
|
|
|
|
start = time_ns()
|
2020-06-06 11:04:14 -04:00
|
|
|
ping_msg = await event.reply("Ping…")
|
2020-05-03 16:44:01 -04:00
|
|
|
time_taken_ms = int((time_ns() - start) / 1000000)
|
2020-06-06 11:04:14 -04:00
|
|
|
await ping_msg.edit(f"Ping… Pong! -> **{time_taken_ms}**ms")
|
2020-05-02 16:43:52 -04:00
|
|
|
|
|
|
|
|
2020-05-02 17:04:27 -04:00
|
|
|
@ldr.add("repo")
|
2023-10-16 09:46:31 -04:00
|
|
|
async def bot_repo(event):
|
|
|
|
await event.reply("https://github.com/Nick80835/microbot")
|
2020-06-09 21:05:53 -04:00
|
|
|
|
|
|
|
|
|
|
|
@ldr.add("nsfw", admin=True)
|
|
|
|
async def nsfw_toggle(event):
|
|
|
|
if not event.args or event.args not in ("on", "off"):
|
|
|
|
if str(event.chat.id) not in ldr.settings.get_list("nsfw_blacklist"):
|
|
|
|
current_config = 'On'
|
|
|
|
else:
|
|
|
|
current_config = 'Off'
|
|
|
|
|
|
|
|
await event.reply(f"Syntax: {ldr.settings.get_config('cmd_prefix') or '.'}nsfw (on|off)\nCurrent config for this chat: {current_config}")
|
|
|
|
return
|
|
|
|
|
|
|
|
if event.args == "on":
|
|
|
|
ldr.settings.remove_from_list("nsfw_blacklist", event.chat.id)
|
2020-06-09 21:07:50 -04:00
|
|
|
await event.reply("NSFW commands enabled for this chat!")
|
2020-06-09 21:05:53 -04:00
|
|
|
elif event.args == "off":
|
|
|
|
ldr.settings.add_to_list("nsfw_blacklist", event.chat.id)
|
2020-06-09 21:07:50 -04:00
|
|
|
await event.reply("NSFW commands disabled for this chat!")
|