merge pull request #171 from levina-lab/logger
[new] some fixes and improvements
This commit is contained in:
commit
7840f3f0d7
8
main.py
8
main.py
@ -1,17 +1,19 @@
|
||||
import asyncio
|
||||
|
||||
from program import LOGS
|
||||
from pytgcalls import idle
|
||||
from driver.core import calls, bot, user
|
||||
|
||||
|
||||
async def start_bot():
|
||||
await bot.start()
|
||||
print("[INFO]: BOT & UBOT CLIENT STARTED !!")
|
||||
LOGS.info("[INFO]: BOT & USERBOT CLIENT STARTED !!")
|
||||
await calls.start()
|
||||
print("[INFO]: PY-TGCALLS CLIENT STARTED !!")
|
||||
LOGS.info("[INFO]: PY-TGCALLS CLIENT STARTED !!")
|
||||
await user.join_chat("VeezSupportGroup")
|
||||
await user.join_chat("levinachannel")
|
||||
await idle()
|
||||
print("[INFO]: STOPPING BOT & USERBOT")
|
||||
LOGS.info("[INFO]: BOT & USERBOT STOPPED !!")
|
||||
await bot.stop()
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
|
@ -1,3 +1,18 @@
|
||||
__version__ = "0.6.5"
|
||||
# >>> patch : F.11.22
|
||||
|
||||
# update patch : F.11.22
|
||||
import time
|
||||
import logging
|
||||
|
||||
from driver.core import me_bot
|
||||
|
||||
logging.basicConfig(
|
||||
filename=f'streambot-logs-{me_bot.id}.txt',
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
||||
)
|
||||
logging.getLogger("yt_dlp").setLevel(logging.ERROR)
|
||||
logging.getLogger("pyrogram").setLevel(logging.ERROR)
|
||||
logging.getLogger("PyTgCalls").setLevel(logging.ERROR)
|
||||
|
||||
LOGS = logging.getLogger(__name__)
|
||||
|
@ -231,6 +231,7 @@ async def sudo_set(_, query: CallbackQuery):
|
||||
» /blocklist - show you the list of all blacklisted chat
|
||||
» /speedtest - run the bot server speedtest
|
||||
» /sysinfo - show the system information
|
||||
» /logs - generate the current bot logs
|
||||
» /eval - execute any code (`developer stuff`)
|
||||
» /sh - run any command (`developer stuff`)
|
||||
|
||||
|
@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/licenses.html
|
||||
"""
|
||||
|
||||
|
||||
import os
|
||||
import re
|
||||
import uuid
|
||||
import socket
|
||||
@ -25,15 +26,19 @@ import platform
|
||||
|
||||
from config import BOT_USERNAME
|
||||
|
||||
from program import LOGS
|
||||
from driver.core import me_bot
|
||||
from driver.filters import command
|
||||
from driver.utils import remove_if_exists
|
||||
from driver.decorators import sudo_users_only, humanbytes
|
||||
|
||||
from pyrogram import Client, filters
|
||||
from pyrogram.types import Message
|
||||
|
||||
|
||||
@Client.on_message(command(["sysinfo", f"sysinfo@{BOT_USERNAME}"]) & ~filters.edited)
|
||||
@sudo_users_only
|
||||
async def give_sysinfo(client, message):
|
||||
async def give_sysinfo(c: Client, message: Message):
|
||||
splatform = platform.system()
|
||||
platform_release = platform.release()
|
||||
platform_version = platform.version()
|
||||
@ -68,3 +73,22 @@ async def give_sysinfo(client, message):
|
||||
**DISK :** `{disk}`
|
||||
"""
|
||||
await message.reply(somsg)
|
||||
|
||||
|
||||
@Client.on_message(command(["logs", f"logs@{BOT_USERNAME}"]) & ~filters.edited)
|
||||
@sudo_users_only
|
||||
async def get_bot_logs(c: Client, m: Message):
|
||||
bot_log_path = f'streambot-logs-{me_bot.id}.txt'
|
||||
if os.path.exists(bot_log_path):
|
||||
try:
|
||||
await m.reply_document(
|
||||
bot_log_path,
|
||||
quote=True,
|
||||
caption='📄 This is the bot logs',
|
||||
)
|
||||
remove_if_exists(bot_log_path)
|
||||
except BaseException as err:
|
||||
LOGS.info(f'[ERROR]: {err}')
|
||||
else:
|
||||
if not os.path.exists(bot_log_path):
|
||||
await m.reply_text('❌ no logs found !')
|
||||
|
Loading…
Reference in New Issue
Block a user