Skip to content

Commit 7cab211

Browse files
committed
full impl
1 parent ceec37a commit 7cab211

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

wechaty/src/main/kotlin/io/github/wechaty/user/ContactSelf.kt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,27 @@ import io.github.wechaty.filebox.FileBox
55
import java.util.concurrent.CompletableFuture
66
import java.util.concurrent.Future
77

8-
class ContactSelf(wechaty: Wechaty,id: String) : Contact(wechaty,id){
8+
class ContactSelf(wechaty: Wechaty, id: String) : Contact(wechaty, id) {
99

10-
override fun avatar(): Future<FileBox> {
11-
return super.avatar()
10+
fun avatar(fileBox: FileBox) {
11+
puppet.setContactAvatar(super.id, fileBox)
1212
}
1313

14-
fun avatar(fileBox:FileBox):Future<Void>{
15-
return CompletableFuture.supplyAsync {
16-
puppet.setContactAvatar(super.id, fileBox)
17-
null
14+
fun setName(name:String){
15+
puppet.contactSelfName(name).get()
16+
sync()
17+
}
18+
19+
fun signature(signature:String){
20+
21+
var puppetId:String? = puppet.selfId()
22+
23+
let{
24+
puppetId != null
25+
}.run {
26+
puppet.contactSelfSignature(signature).get()
27+
sync()
1828
}
1929

2030
}
21-
2231
}

wechaty/src/main/kotlin/io/github/wechaty/user/Room.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,25 @@ class Room(wechaty: Wechaty, val id: String) : Accessory(wechaty), Sayable {
356356
return payload != null
357357
}
358358

359+
fun owner():Contact?{
360+
val ownerId = payload?.ownerId
361+
362+
return if(ownerId.isNullOrBlank()){
363+
null
364+
}else{
365+
return wechaty.contactManager.load(ownerId)
366+
}
367+
}
368+
369+
fun avatar():FileBox{
370+
log.debug("avatar:{}",avatar())
371+
return puppet.roomAvatar(this.id).get()
372+
}
373+
359374
companion object {
360375
private val log = LoggerFactory.getLogger(Room::class.java)
361376
}
377+
362378
}
363379

364380
val ROOM_EVENT_DICT = mapOf(

0 commit comments

Comments
 (0)