Closed is-a-gamer closed 1 year ago
贴一下配置文件
# your bot token
TOKEN=1/XXXXXXXXX
# default voice channel
CHANNEL=276XXXXXXXXXXXX
# the name of khl-voice sdk container, it should be different with your manager(bot) container name
CONTAINER_NAME=sticky_rice_bot
# the admin user id list
ADMIN_USERS=["1774XXXXXX"]
# the file_logger switch
FILE_LOGGER=false
PUBLIC=false
可以贴一下装饰器log的实现吗
这个是解析参数列表长度时发现参数过多/过少导致报错,
实现上是通过command的函数签名解析出需要的参数列表长度,然后和实际传入的参数列表比较 所以这里加了一层装饰器log可能会导致函数签名解析出问题
但是为什么会出现表现不一致的问题我也没什么头绪
确实是log引起的,惊扰到大佬了 而且当我把log放在了command上方的时候就正常了,目前还不知道是什么原因导致服务器上和wsl2中表现不一致
import uuid
import traceback
from loguru import logger
from khl import Message
from app.config.common import settings
def loguru_decorator_factory(command: str=""):
def loguru_decorator(func):
async def wrapped_function(msg: Message, *args, **kwargs):
log_id = uuid.uuid4()
logger.info(f"user: {msg.author.username} user_id: {msg.author.id} in guild_id: {msg.ctx.guild.id} "
f"used command {command} with args {args} and {kwargs}, log_id: {log_id}")
try:
msg.ctx.log_id = log_id
await func(msg, *args, **kwargs)
except Exception as e:
logger.error(f"error occurred, msg: {e}, log_id: {log_id}, traceback: {traceback.format_exc()}")
try:
if settings.debug:
await msg.channel.send(traceback.format_exc())
else:
await msg.channel.send(str(e))
except Exception as e:
logger.critical(f"fatal error, log_id: {log_id}, traceback: {traceback.format_exc()}")
return wrapped_function
return loguru_decorator
Describe the bug 我的两个环境的
@bot.command()
的表现行为不一致开发环境
使用的是 WSL2 Ubuntu22.04部署环境
是腾讯云 Ubuntu20.04 python3 和 khl.py的版本一致To Reproduce
Expected behavior
在开发环境, 也就是WSL2中,当我输入
/hideout_all
时,机器人提醒我当前未输入版本
当我部署到腾讯云上时,直接输入/hideout_all
无任何返回,查看后台,出现报错Logs/Screenshots
Environment