Skip to content

Commit 1170012

Browse files
committed
1. Contact.kt添加friend方法
2. Message.kt添加age方法 3. MemoryCard.kt添加getName()fangfa
1 parent a9d0ad2 commit 1170012

File tree

7 files changed

+14
-15
lines changed

7 files changed

+14
-15
lines changed

wechaty-puppet/src/main/kotlin/io/github/wechaty/memorycard/MemoryCard.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
package io.github.wechaty.memorycard
22

33
import io.github.wechaty.utils.JsonUtils
4-
import kotlinx.coroutines.*
54
import org.slf4j.LoggerFactory
6-
import java.lang.Exception
7-
import java.util.concurrent.ArrayBlockingQueue
8-
import java.util.concurrent.CompletableFuture
9-
import java.util.concurrent.Future
10-
import javax.xml.bind.JAXBElement
11-
import kotlin.math.abs
125

136
const val NAMESPACE_MULTIPLEX_SEPRATOR = "\r"
147
const val NAMESPACE_KEY_SEPRATOR = "\n"
@@ -348,6 +341,9 @@ class MemoryCard {
348341
return VERSION
349342
}
350343

344+
fun getName(): String? {
345+
return this.name
346+
}
351347
// 会将当前的类作为parent, 后面那个为namespace
352348
fun multiplex(nameSpace: String): MemoryCard {
353349
log.info("MemoryCard, multiplex({})", nameSpace)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ open class Contact(wechaty: Wechaty,val id:String) : Sayable, Accessory(wechaty)
9393
return (payload != null && StringUtils.isNotEmpty(payload!!.name))
9494
}
9595

96+
fun friend(): Boolean? {
97+
return payload?.friend
98+
}
99+
96100
fun name():String{
97101
return payload?.name ?: ""
98102
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class ContactSelf(wechaty: Wechaty,id: String) : Contact(wechaty,id){
7070
if (this.id !== puppetId) {
7171
throw Exception("only can get qrcode for the login userself")
7272
}
73-
73+
// maybe
7474
return this.puppet.contactSelfSignature(signature)
7575
}
7676

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Friendship (wechaty: Wechaty):Accessory(wechaty){
4040

4141
return this.payload!!.hello ?: ""
4242
}
43+
4344
fun add(contact: Contact, hello:String){
4445
log.debug("add contact: {} hello: {}",contact,hello)
4546
wechaty.getPuppet().friendshipAdd(contact.id!!,hello).get()
@@ -77,11 +78,8 @@ class Friendship (wechaty: Wechaty):Accessory(wechaty){
7778
wechaty.getPuppet().friendshipAccept(this.id!!).get()
7879

7980
val contact = contact()
80-
8181
contact.ready()
82-
8382
contact.sync()
84-
8583
}
8684

8785
fun type(): FriendshipType? {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ open class Message(wechaty: Wechaty,val id: String) : Sayable, Accessory(wechaty
131131
return Date(payload.timestamp!! * 1000)
132132
}
133133

134+
fun age(): Long {
135+
val ageMilliseconds = Date().time - this.date().time
136+
val ageSeconds = Math.floor(ageMilliseconds / 1000.0).toLong()
137+
return ageSeconds
138+
}
134139
fun forward(to: Any): Future<Void> {
135140
log.debug("Message, forward({})", to)
136141
when(to) {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ class Room(wechaty: Wechaty, val id: String) : Accessory(wechaty), Sayable {
5858
message.ready().get()
5959
return@supplyAsync message
6060
}
61-
6261
return@supplyAsync null
63-
6462
}
6563
}
6664

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,4 @@ class RoomInvitation(wechaty: Wechaty,val id:String) : Accessory(wechaty){
7171
private val log = LoggerFactory.getLogger(RoomInvitation::class.java)
7272
}
7373

74-
75-
7674
}

0 commit comments

Comments
 (0)