Skip to content

Commit 9fe61a1

Browse files
committed
1. 添加hello, type方法
1 parent 2eea542 commit 9fe61a1

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ class Friendship (wechaty: Wechaty):Accessory(wechaty){
3333
return contact
3434
}
3535

36+
fun hello(): String {
37+
if (this.payload == null) {
38+
throw Exception("no payload")
39+
}
3640

41+
return this.payload!!.hello ?: ""
42+
}
3743
fun add(contact: Contact, hello:String){
3844
log.debug("add contact: {} hello: {}",contact,hello)
3945
wechaty.getPuppet().friendshipAdd(contact.id!!,hello).get()
@@ -78,7 +84,15 @@ class Friendship (wechaty: Wechaty):Accessory(wechaty){
7884

7985
}
8086

81-
87+
fun type(): FriendshipType? {
88+
val result = if (this.payload != null) {
89+
this.payload!!.type
90+
}
91+
else {
92+
FriendshipType.Unknown
93+
}
94+
return result
95+
}
8296
companion object{
8397
private val log = LoggerFactory.getLogger(Friendship::class.java)
8498
}

0 commit comments

Comments
 (0)