@juzi/wechaty
Version:
Wechaty is a RPA SDK for Chatbot Makers.
116 lines • 4.28 kB
TypeScript
/**
* Wechaty Chatbot SDK - https://github.com/wechaty/wechaty
*
* @copyright 2016 Huan LI (李卓桓) <https://github.com/huan>, and
* Wechaty Contributors <https://github.com/wechaty>.
*
* 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 type * as PUPPET from '@juzi/wechaty-puppet';
import type { FileBoxInterface } from 'file-box';
import type { Constructor } from 'clone-class';
import { ContactImpl } from './contact.js';
import type { RoomInterface } from './room.js';
declare const MixinBase: ((abstract new (...args: any[]) => {}) & {
_pool?: Map<string, ContactSelfInterface> | undefined;
readonly pool: Map<string, ContactSelfInterface>;
load<L extends import("clone-class/dist/esm/src/constructor.js").ClassInterface<{}> & {
new (...args: any[]): ContactSelfInterface;
prototype: ContactSelfInterface;
} & import("../user-mixins/poolify.js").PoolifyMixin<ContactSelfInterface>>(this: L, id: string): ContactSelfInterface;
}) & typeof ContactImpl;
/**
* Bot itself will be encapsulated as a ContactSelf.
*
* > Tips: this class is extends Contact
* @example
* const bot = new Wechaty()
* await bot.start()
* bot.on('login', (user: ContactSelf) => {
* console.log(`user ${user} login`)
* })
*/
declare class ContactSelfMixin extends MixinBase {
static find(query: string | PUPPET.filters.Contact): Promise<undefined | ContactSelfInterface>;
avatar(): Promise<FileBoxInterface>;
avatar(file: FileBoxInterface): Promise<void>;
/**
* Get bot qrcode
*
* @returns {Promise<string>}
*
* @example
* import { generate } from 'qrcode-terminal'
* bot.on('login', (user: ContactSelf) => {
* console.log(`user ${user} login`)
* const qrcode = await user.qrcode()
* console.log(`Following is the bot qrcode!`)
* generate(qrcode, { small: true })
* })
*/
qrcode(): Promise<string>;
/**
* Change bot name
*
* @param name The new name that the bot will change to
*
* @example
* bot.on('login', async user => {
* console.log(`user ${user} login`)
* const oldName = user.name()
* try {
* await user.name(`${oldName}-${new Date().getTime()}`)
* } catch (e) {
* console.error('change name failed', e)
* }
* })
*/
name(): string;
name(name: string): Promise<void>;
realName(): string;
realName(realName: string): Promise<void>;
aka(): string;
aka(aka: string): Promise<void>;
/**
* Change bot signature
*
* @param signature The new signature that the bot will change to
*
* @example
* bot.on('login', async user => {
* console.log(`user ${user} login`)
* try {
* await user.signature(`Signature changed by wechaty on ${new Date()}`)
* } catch (e) {
* console.error('change signature failed', e)
* }
* })
*/
signature(signature: string): Promise<void>;
roomAlias(room: RoomInterface, alias?: string): Promise<void | string>;
}
declare const ContactSelfImpl_base: {
new (...args: any[]): {};
valid: (o: any) => o is ContactSelfInterface;
validInstance: (target: any) => target is ContactSelfMixin;
validInterface: (target: any) => target is ContactSelfInterface;
} & typeof ContactSelfMixin;
declare class ContactSelfImpl extends ContactSelfImpl_base {
}
interface ContactSelfInterface extends ContactSelfImpl {
}
declare type ContactSelfConstructor = Constructor<ContactSelfInterface, Omit<typeof ContactSelfImpl, 'load'>>;
export type { ContactSelfConstructor, ContactSelfInterface, };
export { ContactSelfImpl, };
//# sourceMappingURL=contact-self.d.ts.map