friend-request.ts 1.5 KB
Newer Older
1
/**
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
2
 *   Wechaty - https://github.com/chatie/wechaty
3
 *
4
 *   @copyright 2016-2017 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,
Huan (李卓桓)'s avatar
merge  
Huan (李卓桓) 已提交
24 25
}               from './config'
import Contact  from './contact'
26

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

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

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

45
    if (!config.puppetInstance()) {
Huan (李卓桓)'s avatar
Huan (李卓桓) 已提交
46
      throw new Error('no Config.puppetInstance() instanciated')
47 48 49
    }
  }

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

}
Huan (李卓桓)'s avatar
merge  
Huan (李卓桓) 已提交
54 55

export default FriendRequest