JQ-Networks / UnifiedMessageRelay

Group Message Forward Framework (supports QQ Telegram Line Discord)
MIT License
419 stars 59 forks source link

Telegram 群组中发送的图片不能被转发到 QQ 群 #55

Closed tnqzh123 closed 5 years ago

tnqzh123 commented 6 years ago

如题,在 Telegram 群组中发送图片时,Python 抛出这个异常:

Traceback (most recent call last):
  File "C:\Python\lib\site-packages\telegram\ext\dispatcher.py", line 279, in process_update
    handler.handle_update(update, self)
  File "C:\Python\lib\site-packages\telegram\ext\messagehandler.py", line 169, in handle_update
    return self.callback(dispatcher.bot, update, **optional_args)
  File "C:\coolq-telegram-bot-master\plugins\_1100_text_forward.py", line 57, in photo_from_telegram
    filename = tg_get_file(file_id)
  File "C:\coolq-telegram-bot-master\main\tg_utils.py", line 92, in tg_get_file
    os.rename(filename, new_name_full)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\CoolQ\\data/image\\AgADBQADLagxG2vkgFf6_eD8yFAxj16t1jIABKinO5HSwJ7T_CUEAAEC' -> 'C:\\CoolQ\\data/image\\AgADBQADLagxG2vkgFf6_eD8yFAxj16t1jIABKinO5HSwJ7T_CUEAAEC.jpg'

但是 Telegram 群组中发送的 Sticker 是可以被正常转发到 QQ 群的。 系统是 Windows Server 2016,Python 版本为 3.6.6

Z4HD commented 6 years ago

看起来像是要重命名的文件 C:\\CoolQ\\data/image\\AgADBQADLagxG2vkgFf6_eD8yFAxj16t1jIABKinO5HSwJ7T_CUEAAEC 被另一个进程占用使得重命名操作失败了。检查一下目录访问权限?

tnqzh123 commented 6 years ago

@Z4HD 访问权限应该没问题的,PowerShell 是以管理员权限运行的。

tnqzh123 commented 5 years ago

自己动手解决了... main\tg_utils.py 中 L93、L101、L109 的重命名

os.rename(filename, new_name_full)

改成复制就完了...

shutil.copyfile(filename, new_name_full)