Skip to content

[New Feature] Room.{create,addMember,delMember,quit,modTopic} support #32

@huan

Description

@huan

according to the original issue #14

Room Factory of WxApp

type ChatroomResponse {
  BaseResponse: {
    Ret: number
  }
  , ChatRoomName: string
}

class chatroomFactory {
  create(e: userId[]): Promise<{BaseResponse.Ret:number}>

  addMember(roomId, userList: UserName[].join(','), cb: ({BaseResponse.Ret:number}) => void )
  delMember(roomId, userList: string)
  quit(roomId) // un-implenment?
  modTopic(roomId, newTopic)
}

type ContactQuery = {
  filterContacts: UserName[]
  , noHeader: boolean
  , showFriendHeader: boolean
  , isWithoutStar: boolean
  , isWithoutBrand: boolean 
  , isSaved: boolean
}

type PickQuery = {
  all?: ContactQuery
  , friend?: ContactQuery
  , star?: ContactQuery
  , brand?: ContactQuery
}

class contactFactory {
  pictContacts(typeList: string[], query: PickQuery, clone: boolean): Contact[]
  getAllChatroomContact(query: ContactQuery)
  getAllFriendContact(query: ContactQuery)
  getContact(query: ContactQuery)
}

Room Class of Wechaty

type Query = { name: string|Regex }
Room.find(query : Query) : Room | null
Room.findAll(query : Query) : Room[]

1. static Room.find(query: Query): Promise<Room|null>

2. static Room.findAll(query: Query): Promise<Room[]>

3. static Room.create(contactList: Contact[]): Promise

4. Room.add(contact: Contact): Promise

const friend = message.get('from')
const room = Room.find({ name: 'Group Name' })
if (room) {
  room.add(friend)
}

5. Room.del(contact: Contact): void

6. Room.topic(newTopic?: string): string

7. Room.nick(contact: Contact): string

8. Room.has(contact Contact): boolean

10. Room.on('join', (invitee, inviter) => void)

Event join: Room New Member

room.on('join', (invitee, inviter) => {
  console.log(`user ${invitee} joined the room ${room}, invited by ${inviter}`)
})

11. Room.on('leave', (leaver) => void)

12. Room.refresh(): Promise

13. Room.owner(): Contact|null

14. Room.member(name: string): Contact|null

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions