Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

群文件在上传后toRemoteFile返回NULL #1250

Closed
Nambers opened this issue May 6, 2021 · 4 comments
Closed

群文件在上传后toRemoteFile返回NULL #1250

Nambers opened this issue May 6, 2021 · 4 comments
Labels
z:as-designed 状态: 一个正常的行为

Comments

@Nambers
Copy link
Contributor

Nambers commented May 6, 2021

group.uploadFile上传文件后,调用返回值的toRemoteFile方法返回null

2021-05-06 20:39:54 V/Bot 692928873: Group(788189105) <- HI
2021-05-06 20:39:54 V/Net 692928873: Send: OidbSvc.0x6d6_0
2021-05-06 20:39:54 V/Net 692928873: Recv: CommonOidbResponse.Success
2021-05-06 20:39:54 V/Net 692928873: Send: OidbSvc.0x6d8_1
2021-05-06 20:39:54 V/Net 692928873: Send: OnlinePush.RespPush
2021-05-06 20:39:54 V/Net 692928873: Recv: CommonOidbResponse.Success
2021-05-06 20:39:54 V/Net 692928873: Send: OidbSvc.0x6d8_1
2021-05-06 20:39:55 V/Net 692928873: Send: OnlinePush.RespPush
2021-05-06 20:39:55 V/Net 692928873: Recv: CommonOidbResponse.Success
2021-05-06 20:39:55 W/Bot 692928873: 异常:kotlin返回空字符串

代码:

suspend fun uploadFile(path: String, file: String, c: Config.Contact): String {
        val group = AIbot.getGroup(c.id) ?: let {
            logger.error("找不到对应群组,位置K-uploadfile(),gid:${c.id}")
            return "E1"
        }
        val f = File(file)
        if (!f.exists() || !f.isFile) {
            return "E2"
        }
        val tmp =
            try {
                group.uploadFile(path, f) //Point 1
            } catch (e: IllegalStateException) {
                return "E3"
            } catch (e: Exception){
                logger.error(e.message)
                e.printStackTrace()
                return "E3"
            }
        val temp = tmp.toRemoteFile(group)?:let{ // Point 2
            logger.error("hhh?")
            return "E3"
        }
        logger.info(fileInfo0(temp))
        return fileInfo0(temp)
    }

在point 1上传后,在point2 返回null

版本

  • mirai-core: 2.6.3

补充信息

@Nambers Nambers added the x:question 标签: 需要更多信息 label May 6, 2021
@Him188 Him188 added t:bug 类型: bug N 优先级: 一般 and removed x:question 标签: 需要更多信息 labels May 8, 2021
@Him188 Him188 added this to the Backlog milestone May 8, 2021
@Him188
Copy link
Member

Him188 commented May 8, 2021

现在可以临时以 path 从 group.filesRoot resolve 得到

@Nambers
Copy link
Contributor Author

Nambers commented May 8, 2021

现在可以临时以 path 从 group.filesRoot resolve 得到

就相当于重新获取一次? 可是如果按path的话不是随机取个同名的文件?
还是用path取FileList然后id判断

@Karlatemp
Copy link
Member

Karlatemp commented May 8, 2021

uploadFile 没有往群发送消息因此服务器判断还没有上传完成, 属于正常现象, 请使用 sendFile

@Karlatemp Karlatemp added z:as-designed 状态: 一个正常的行为 and removed N 优先级: 一般 t:bug 类型: bug labels May 8, 2021
@Nambers
Copy link
Contributor Author

Nambers commented May 8, 2021

解决方法
在upload后要sendto

@Karlatemp Karlatemp removed this from the Backlog milestone May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
z:as-designed 状态: 一个正常的行为
Projects
None yet
Development

No branches or pull requests

3 participants