class Contact extends Conversation with LoggerSupport
All wechat contacts(friend) will be encapsulated as a Contact.
[Examples/Contact-Bot]https://github.com/wechaty/wechaty/blob/1523c5e02be46ebe2cc172a744b2fbe53351540e/examples/contact-bot.ts
- Since
2020-06-03
- Alphabetic
- By Inheritance
- Contact
- LoggerSupport
- Conversation
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new Contact(contactId: String)(implicit resolver: PuppetResolver)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
alias(newAlias: String): String
GET / SET / DELETE the alias for a contact
GET / SET / DELETE the alias for a contact
Tests show it will failed if set alias too frequently(60 times in one minute).
GET the alias for a contact, return {(Promise const alias = await contact.alias() if (alias === null) { console.log('You have not yet set any alias for contact ' + contact.name()) } else { console.log('You have already set an alias for contact ' + contact.name() + ':' + alias) })} , SET the alias for a contact try { await contact.alias('lijiarui') console.log(change ${contact.name()}'s alias successfully!
) } catch (e) { console.log(failed to change ${contact.name()} alias!
) } , DELETE the alias for a contact try { const oldAlias = await contact.alias(null) console.log(delete ${contact.name()}'s alias successfully!
) console.log('old alias is ${oldAlias}) } catch (e) { console.log(
failed to delete ${contact.name()}'s alias!) }
Examples: -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- def avatar: ResourceBox
-
def
city(): String
Get the region 'city' from a contact
Get the region 'city' from a contact
const city = contact.city()
Example: -
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
debug(message: String, args: Any*): Unit
- Attributes
- protected
- Definition Classes
- LoggerSupport
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
error(message: String, e: Throwable): Unit
- Attributes
- protected
- Definition Classes
- LoggerSupport
-
def
error(message: String, args: Any*): Unit
- Attributes
- protected
- Definition Classes
- LoggerSupport
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
friend(): Boolean
Check if contact is friend
Check if contact is friend
> Tips: This function is depending on the Puppet Implementation, see [puppet-compatible-table](https://github.com/wechaty/wechaty/wiki/Puppet#3-puppet-compatible-table)
const isFriend = contact.friend()
Example: -
def
gender(): Type
Contact gender > Tips: ContactGender is enum here.
Contact gender > Tips: ContactGender is enum here.
const gender = contact.gender() === bot.Contact.Gender.Male
Example: -
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
val
id: String
- Definition Classes
- Conversation
-
def
info(message: String, args: Any*): Unit
- Attributes
- protected
- Definition Classes
- LoggerSupport
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isReady(): Boolean
-
val
logger: Logger
- Attributes
- protected
- Definition Classes
- LoggerSupport
-
def
name: String
Get the name from a contact
Get the name from a contact
const name = contact.name()
Example: -
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def payload: ContactPayload
-
def
province(): String
Get the region 'province' from a contact
Get the region 'province' from a contact
const province = contact.province()
Example: -
def
ready(forceSync: Boolean = false): Unit
ready()
is For FrameWork ONLY!ready()
is For FrameWork ONLY!Please not to use
ready()
at the user land. If you want to sync data, uysesync()
instead. -
def
say(something: MiniProgram): Message
- Definition Classes
- Conversation
-
def
say(something: UrlLink): Message
- Definition Classes
- Conversation
-
def
say(something: Contact): Message
- Definition Classes
- Conversation
-
def
say(something: String): Message
- Definition Classes
- Conversation
-
def
self(): Boolean
Check if contact is self
Check if contact is self
const isSelf = contact.self()
Example: -
def
star(): Boolean
const isStar = contact.star()
Example: -
def
sync(): Unit
Force reload data for Contact, Sync data from lowlevel API again.
Force reload data for Contact, Sync data from lowlevel API again.
await contact.sync()
Example: -
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
tags(): Array[Tag]
Get all tags of contact
Get all tags of contact
const tags = await contact.tags()
Example: -
def
toString(): String
- Definition Classes
- Contact → AnyRef → Any
-
def
type(): Type
Return the type of the Contact > Tips: ContactType is enum here.
Return the type of the Contact > Tips: ContactType is enum here.
const bot = new Wechaty() await bot.start() const isOfficial = contact.type() === bot.Contact.Type.Official
Example: -
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
warn(message: String, args: Any*): Unit
- Attributes
- protected
- Definition Classes
- LoggerSupport
-
def
weixin(): String
Get the weixin number from a contact.
Get the weixin number from a contact.
Sometimes cannot get weixin number due to weixin security mechanism, not recommend.
const weixin = contact.weixin()
Example:
Deprecated Value Members
-
def
stranger(): Boolean
- Deprecated