Skip to content

Commit

Permalink
fix #11
Browse files Browse the repository at this point in the history
  • Loading branch information
MrXiaoM committed Jan 10, 2024
1 parent 381fb72 commit a6e3ac7
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,20 @@ class Overflow : IMirai, CoroutineScope, LowLevelApiAccessor, OverflowAPI {
"female" -> UserProfile.Sex.FEMALE
else -> UserProfile.Sex.UNKNOWN
}

val age = strangerInfo?.age ?:
// TODO: 不确定 birthday 的单位是毫秒还是秒
if (data.birthday > 0) ((currentTimeSeconds() - data.birthday) / 365.daysToSeconds).toInt() else 0

return UserProfileImpl(age, data.mail, 0, data.name, data.level, sex, data.hobbyEntry)
} else {
TODO()
val data = bot.asOnebot.impl.getStrangerInfo(targetId, false).data ?: throw IllegalStateException("Can not fetch stranger info (profile card).")
val sex = when(data.sex.lowercase()) {
"male" -> UserProfile.Sex.MALE
"female" -> UserProfile.Sex.FEMALE
else -> UserProfile.Sex.UNKNOWN
}
return UserProfileImpl(data.age, "", 0, data.nickname, data.level, sex, "")
}
}
override suspend fun getOnlineOtherClientsList(bot: Bot, mayIncludeSelf: Boolean): List<OtherClientInfo> {
Expand Down

0 comments on commit a6e3ac7

Please sign in to comment.