Skip to content

Commit

Permalink
Add room member (wechaty#2147)
Browse files Browse the repository at this point in the history
* 0.29.3

* Merge master (#18)

* update puppeteer puppet

* 0.31.18

* upgrade to wechaty-puppet@0.20

* 0.31.19

* upgrade puppet configs

* 0.31.20

* dep upgrade & clean (wechaty#1917)

* 0.31.21

* upgrade eslint-config (wechaty#1917)

* 0.31.22

* use green version of powered by wechaty badge

* 0.31.23

* use NODE_AUTH_TOKEN instead of NPM_TOKEN

* 0.31.24

* use bright green for badge

* 0.31.25

* restore pkg-jq

* 0.31.26

* Upgrade docker base image & node.js (wechaty#1920)

* 0.32.1

* fix scan status for padplus (wechaty/wechaty-puppet-padplus#161)

* 0.32.2

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* merge master (#20)

* 0.45.3

* 0.45.4

* upgrade puppet to use async-map-like memory-card

* upgrade puppet

* 0.45.5

* build onbuild docker image

* 0.45.6

* test for onbuild home dir

* 0.45.7

* deploy wechaty/onbuld

* fix test for both wechaty & /bot

* 0.45.8

* publish to wechaty/wechatyh

* 0.45.9

* build with onbuld

* 0.45.10

* rename zixia/wechaty -> wechaty/wechaty

* 0.45.11

* fix typo

* 0.45.12

* fix onbuild npm run

* 0.45.13

* update official example

* Update README.md

* fix asscessory tests, and protect user class constructor from public to private

* Increase MaxListener for Wechaty

* 0.45.14

* add plugin uninstaller logic

* 0.45.15

* fix race condition for plugin uninstallation

* 0.45.16

* template clean

* 0.45.17

* upgrade puppet

* 0.46.0

* 0.46.1

* add new puppet for official account

* 0.46.2

* Wechaty is a Conversational SDK for Chatbot Makers

* fix bio

* 0.46.3

* clean log message

* 0.46.4

* upgrade hostie

* 0.45.6

* 0.46.5

* 0.47.0

* 0.47.1

* support onbuild:version

* 0.47.2

* use artifact image name

* 0.47.3

* clean version & tag

* 0.47.4

* 0.47.5

* fix hostie start bug

* 0.47.6

* clean

* 0.46.5

* 0.47.7

* add svg logos

* use wechaty.js.org host

* 0.47.7

* 0.47.8

* update

* 0.47.9

* use docker for changelog

* 0.47.10

* update changelog

* 0.47.11

* use wechaty.js.org/qrcode/ to replace wechaty.github.io/qrcode/

* 0.47.12

* Update README.md

* feat: add scoped wxwork puppet into puppet config (wechaty#2043)

* add scoped wxwork puppet into puppet config

* skip install scoped puppet

* 0.47.13

* add phone method in contact class (wechaty#2039)

* add phone method in contact class

* 0.47.13

* 0.47.14

* update wechaty-puppet version

* add jsdoc for contact.phone

* use puppet.dirtyPayload (wechaty/puppet-service#43)

* 0.47.15

* fix dirty exception

* 0.47.16

* TODO: implement the dirty logic (wechaty/puppet-service#43)

* 0.47.17

* TODO: implement the dirty logic (wechaty/puppet-service#43)

* 0.47.18

* implement the dirty logic (wechaty/puppet-service#43)

* 0.47.19

* clean

* 0.47.20

* remove deprecated methods (wechaty#2049)

* 0.47.21

* Upgrade to TypeScript 4.0!

* 0.47.22

* feat: add more methods into contact class (wechaty#2048)

* add more methods into contact class

* fix code with new wechaty-puppet

* 0.47.21

* 0.47.23

* throw a nice error message when we call user module before start wechaty

* 0.47.24

* 0.48.0 (wechaty#2050)

* bump hostie version to be the stable one (wechaty#2051)

* bump hostie version to be the stable one

* 0.48.1

* link images to wechaty.js.org

* update links

* 0.48.2

* update jsdocs

* 0.48.3

* add gitter puppet

* 0.48.4

* fix typo

* 0.48.5

* add location user module

* 0.47.25

* 0.48.6

* clean

* 0.48.7

* add telegram channel for wechaty

* 0.48.8

* add bibtex cite code

* 0.48.9

* add star history badge

* 0.48.10

* Split to trunks when making requests of room.findAll() and room.ready() (wechaty#2067)

* add pagination on room.findAll() and room.ready()

* 0.48.11

* fix wechaty#2073 (wechaty#2074)

* fix wechaty#2073

* 0.48.12

* 0.48.13

* Bump minor 49 (wechaty#2078)

* 0.49.0

* update hostie version to take advantage of the new stream grpc methods

* fix io client qrcode by encodeURIComponent

* 0.48.11

* upgrade deps

* 0.49.1

* upgrade puppet to v0.33

* 0.49.2

* 0.49.3

* 0.49.4

* fix typos

* 0.49.5

* clean

* Update README.md

* add credit link

* fix typo

* upgrade json-rpc-peer to v0.17

* 0.49.7

* 0.49.8

* Update Dockerfile (wechaty#2079)

按照 wechaty#1986 的方法用docker创建Hostie Token时,docker端报错。加入libxtst6库后可以完美运行。

* 0.50.0

* 0.50.1

* clean scan payload after login

* 0.50.2

* enable io sync message botie support

* 0.50.3

* use source for botie payload

* 0.50.4

* add whatsapp to official puppet names (wechaty/puppet-whatsapp#1)

* 0.50.5

* use a helper function for better FileBox instance check (wechaty/puppet-service#99)

* 0.50.6

* loost Puppet instance type checking (wechaty#2024)

* 0.50.7

* create looseInstanceOfClass (wechaty#2090) (wechaty#2091)

* create looseInstanceOfClass (wechaty#2090)

* 0.50.8

* 0.51.0

* 0.51.1

* fix file-box

* fix file-box

* 0.51.2

* rename from -> talker (wechaty#2094)

* 0.51.3

* add gitter & deprecate padplus

* strict typing check for typescript v4

* 0.51.4

* Update contact.ts (wechaty#2095)

fix: return payload friend

* rename from() to talker() from message

* 0.51.5

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* add wechaty-puppet-padlocal to the puppet config (wechaty#2102)

* 0.51.6

* 0.51.7

* remove padplus from smoke testing (wechaty#2087)

* 0.51.8

* add url link unit test

* 0.51.9

* add strict check

* clean

* 0.51.10

* Update room-invitation.ts (wechaty#2104)

topic() returns a Promise<string> instead of Promise<Contact>. The document is incorrect.

* add puppet event to emitter typing

* 0.51.11

* add puppet to wechaty event names

* Working on RxJS related deps

* 0.53.1

* Rename NODE_AUTH_TOKEN -> NPM_TOKEN

* Use Debian instead of Ubuntu for our Docker (wechaty#2114)

* 0.53.2

* Update Node.js v12 -> v14 (wechaty#2115)

* 0.53.3

* RPA SDK

* RPA SDK

* use cache to speed up github action

* use cache for node & npm

* 0.53.4

* node v15 not support grpc yet

* 0.53.5

* Update package.json

* Upgrade pkg-jq

* use better cache for gh actions

* 0.53.6

* 0.53.7

* Update README.md (wechaty#2118)

change puppet service provider link

* use naive hashFile

* 0.53.8

* fix typo

* 0.53.9

* rename wechaty-puppet-hostie -> wechaty-puppet-service (wechaty#2124)

* add deprecate warning message for WECHATY_HOSTIE_PORT (wechaty#2122)

* 0.55.1

* 0.56.0

* 0.56.1

* Changelog for v0.56

* compatible with wechaty-puppet-hostie module name (wechaty/puppet-service#118)

* 0.56.2

* use node v12 instead of v14 in docker image for maximum compatibility. (e.g. huggingface/tokenizers#603)

* 0.56.3

* 0.57.0

* default puppet: service (wechaty#2127)

* 0.57.1

* upgrade wechaty-puppet to v0.34

* 0.57.2

* change default puppet to puppet-service

* 0.57.3

* upgrade deps

* 0.57.4

* fix docker deploy for branches

* 0.57.5

* pass custom server host to io server (wechaty#2138)

* pass custom server host to io server

* fix test

* modify code according to comments

* 0.57.6

* support puppet lark (wechaty/puppet-lark#4)

* 0.57.7

* clean

* 0.57.8

* use npm-run-all

* 0.57.9

* specific puppet versions

* 0.57.10

* upgrade upppeteer version

* 0.57.11

Co-authored-by: Huan LI (李卓桓) <zixia@zixia.net>
Co-authored-by: Yuan Gao <wind.memory.cn@gmail.com>
Co-authored-by: 陶鑫 <i@yesxin.com>
Co-authored-by: lijiarui <ruiruibupt@gmail.com>
Co-authored-by: profthecopyright <54515051+profthecopyright@users.noreply.github.com>

* feat: modify friendshipAdd for support add room member be friends

* 0.57.14

* refactor

* fix: bump wechaty-puppet version

* fix: add warn message for using hello params in Friendship.add()

* 0.57.18

* fix: bump wechaty-puppet-service@0.17.0

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>
Co-authored-by: Yuan Gao <wind.memory.cn@gmail.com>
Co-authored-by: 陶鑫 <i@yesxin.com>
Co-authored-by: lijiarui <ruiruibupt@gmail.com>
Co-authored-by: profthecopyright <54515051+profthecopyright@users.noreply.github.com>
  • Loading branch information
6 people authored Mar 19, 2021
1 parent 64d6d63 commit 9b38538
Showing 1 changed file with 40 additions and 9 deletions.
49 changes: 40 additions & 9 deletions src/user/friendship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
} from '../helper-functions/mod'

import {
FriendshipAddOptions as PuppetFriendshipAddOptions,
FriendshipPayload,
FriendshipType,
FriendshipSearchQueryFilter,
Expand All @@ -44,6 +45,18 @@ import {
Contact,
} from './contact'

import {
Room,
} from './room'

interface FriendshipAddOptionsObject {
room?: Room,
contact?: Contact,
hello?: string,
}

type FriendshipAddOptions = string | FriendshipAddOptionsObject

/**
* Send, receive friend request, and friend confirmation events.
*
Expand Down Expand Up @@ -75,7 +88,7 @@ class Friendship extends EventEmitter implements Acceptable {
* Search a Friend by phone or weixin.
*
* The best practice is to search friend request once per minute.
* Remeber not to do this too frequently, or your account may be blocked.
* Remember not to do this too frequently, or your account may be blocked.
*
* @param {FriendshipSearchCondition} condition - Search friend by phone or weixin.
* @returns {Promise<Contact>}
Expand All @@ -89,12 +102,12 @@ class Friendship extends EventEmitter implements Acceptable {
*
*/
public static async search (
queryFiter : FriendshipSearchQueryFilter,
queryFilter : FriendshipSearchQueryFilter,
): Promise<null | Contact> {
log.verbose('Friendship', 'static search("%s")',
JSON.stringify(queryFiter),
JSON.stringify(queryFilter),
)
const contactId = await this.wechaty.puppet.friendshipSearch(queryFiter)
const contactId = await this.wechaty.puppet.friendshipSearch(queryFilter)

if (!contactId) {
return null
Expand All @@ -112,24 +125,42 @@ class Friendship extends EventEmitter implements Acceptable {
* Remeber not to do this too frequently, or your account may be blocked.
*
* @param {Contact} contact - Send friend request to contact
* @param {string} hello - The friend request content
* @param {FriendshipAddOptions} options - The friend request content
* @returns {Promise<void>}
*
* @example
* const contact = await bot.Friendship.search({phone: '13112341234'})
* await bot.Friendship.add(contact, 'Nice to meet you! I am wechaty bot!')
*
* const memberList = await room.memberList()
* for (let i = 0; i < memberList.length; i++) {
* await bot.Friendship.add(member, 'Nice to meet you! I am wechaty bot!')
* await bot.Friendship.add(member, {
* room: room,
* hello: `Nice to meet you! I am wechaty bot from room: ${await room.topic()}!`,
* })
* }
*
*/
public static async add (
contact : Contact,
hello : string,
options : FriendshipAddOptions,
): Promise<void> {
log.verbose('Friendship', 'static add(%s, %s)',
contact.id,
hello,
typeof options === 'string' ? options : options.hello,
)
await this.wechaty.puppet.friendshipAdd(contact.id, hello)

if (typeof options === 'string') {
log.warn('Friendship', 'the params hello is deprecated in the next version, please put the attr hello into options object, e.g. { hello: "xxxx" }')
await this.wechaty.puppet.friendshipAdd(contact.id, { hello: options })
} else {
const friendOption: PuppetFriendshipAddOptions = {
contactId: options?.contact?.id,
hello: options.hello,
roomId: options.room && options.room.id,
}
await this.wechaty.puppet.friendshipAdd(contact.id, friendOption)
}
}

public static async del (
Expand Down

0 comments on commit 9b38538

Please sign in to comment.