0.1.9 • Published 3 years ago

@dousha99/mirai-api-http-ts v0.1.9

Weekly downloads
1
License
AGPL-3.0-or-later
Repository
github
Last release
3 years ago

mirai-api-http-ts - Simple and Intuitive TypeScript Wrapper for mira-api-http

简体中文 | English

Note: This is an ongoing project. We will try our best to keep backward compatibility, but breaking changes can occur. The version number conforms to SemVer as compatibility reference.

Motivation

I just need a good enough TypeScript library for my bot. I guess you might need it too.

Usage

Get the library:

$ yarn add @dousha99/mirai-api-http-ts
- or -
$ npm i --save @dousha99/mirai-api-http-ts

Documentation in progress...

Examples

See examples/ for working examples. Here is a simple echo bot example:

import { MiraiClient, OutboundMessageChiain, MessageType } from '@dousha99/mirai-api-http-ts';

const mirai = new MiraiClient({
	connection: {
		tls: false,
		host: 'localhost',
		httpPort: 8080,
		websocketPort: 8080,
		useWebsocket: true,
		pollPeriod: 5000,
		pollCount: 5,
	},
	account: {
		authKey: process.env['AUTH_KEY']!,
		account: Number(process.env['QQ']!),
	},
});

mirai.on(MessageType.FRIEND_MESSAGE, msg => {
	if (msg.isPlainTextMessage()) {
		const text = msg.extractPlainText();
		msg.reply(OutboundMessageChain.ofText(text)).catch(e => console.error(e));
		if (text.trim() === 'stophammertime') {
			mirai.close();
		}
	}
});

mirai.on('connect', () => {
	console.log('Ready');
});
0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.4

3 years ago

0.1.5

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago