/** * Wechaty - https://github.com/chatie/wechaty * * Copyright 2016-2017 Huan LI * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ import { EventEmitter } from 'events' import { StateSwitch } from 'state-switch' import { Sayable, log, } from './config' import Contact from './contact' import { Message, MediaMessage, } from './message' import Room from './room' // type ContactGetterFunc = { // (id: string): Promise // } /** * Abstract Puppet Class */ export abstract class Puppet extends EventEmitter implements Sayable { public userId: string | null public user: Contact | null public abstract getContact(id: string): Promise public state = new StateSwitch<'live', 'dead'>('Puppet', 'dead', log) constructor() { super() } public abstract async init(): Promise public abstract self(): Contact public abstract send(message: Message | MediaMessage): Promise public abstract say(content: string): Promise public abstract reset(reason?: string): void public abstract logout(): Promise public abstract quit(): Promise public abstract ding(): Promise /** * FriendRequest */ public abstract friendRequestSend(contact: Contact, hello?: string): Promise public abstract friendRequestAccept(contact: Contact, ticket: string): Promise /** * Room */ public abstract roomAdd(room: Room, contact: Contact): Promise public abstract roomDel(room: Room, contact: Contact): Promise public abstract roomTopic(room: Room, topic: string): Promise public abstract roomCreate(contactList: Contact[], topic?: string): Promise public abstract roomFind(filterFunc: string): Promise /** * Contact */ public abstract contactFind(filterFunc: string): Promise public abstract contactAlias(contact: Contact, alias: string|null): Promise } export default Puppet