friend-request.ts 1.6 KB
Newer Older
1
/**
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
2
 *   Wechaty - https://github.com/chatie/wechaty
3
 *
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
4
 *   @copyright 2016-2018 Huan LI <zixia@zixia.net>
5
 *
6 7 8
 *   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
9
 *
10 11 12 13 14 15 16
 *       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.
L
lijiarui 已提交
17
 *   @ignore
18 19 20
 *
 */

Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
21
import {
22
  // config,
L
lijiarui 已提交
23
  log,
24 25 26
}                       from './config'
import Contact          from './contact'
import PuppetAccessory  from './puppet-accessory'
27

L
lijiarui 已提交
28 29 30 31 32 33 34
/**
 * Send, receive friend request, and friend confirmation events.
 *
 * 1. send request
 * 2. receive request(in friend event)
 * 3. confirmation friendship(friend event)
 *
35
 * [Examples/Friend-Bot]{@link https://github.com/Chatie/wechaty/blob/master/examples/friend-bot.ts}
L
lijiarui 已提交
36
 */
37
export abstract class FriendRequest extends PuppetAccessory {
38 39 40

  public contact: Contact
  public hello: string
41
  public type: 'send' | 'receive' | 'confirm'
42

43
  constructor() {
44
    super()
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
45 46
    log.verbose('FriendRequest', 'constructor()')

47 48 49
    // if (!config.puppetInstance()) {
    //   throw new Error('no Config.puppetInstance() instanciated')
    // }
50 51
  }

52 53
  public abstract send(contact: Contact, hello: string): Promise<boolean>
  public abstract accept(): Promise<boolean>
54 55

}
Huan (李卓桓)'s avatar
merge  
Huan (李卓桓) 已提交
56 57

export default FriendRequest