-
Notifications
You must be signed in to change notification settings - Fork 17
/
moremsg.ts
57 lines (51 loc) · 1.71 KB
/
moremsg.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//简单的登录,请参考 ./basic.ts 此处不再赘述
//#region 简单的登录
import { uin, pwd, sign_api_addr, groupID, masterID } from "./config";
import { Client, createClient, segment } from "../src/index";
const client: Client = createClient({ sign_api_addr: sign_api_addr });
client.login(uin, pwd);
client
.on("system.online", () => {
console.log("账号登录成功");
})
.on("system.login.slider", (event) => {
console.log(`这是要访问滑块验证网站的url地址:${event.url}`);
process.stdin.once("data", (input) => {
client.submitSlider(String(input));
});
})
.on("system.login.device", () => {
client.sendSmsCode();
process.stdin.once("data", (data) => {
client.submitSmsCode(data.toString());
});
})
.on("system.login.error", (event) => {
console.log(`登录遇到错误,错误代码:${event.code}`);
console.log(`登录遇到错误,错误信息:${event.message}`);
process.exit();
});
//#endregion
/**
* 更多类型的消息由segment创建
*/
client.on("system.online", () => {
//at消息 我们在群里面at某个人
client.sendGroupMsg(groupID, segment.at(masterID));
//或者把一个at和其他类型的消息组合, 使用消息数组
client.sendGroupMsg(groupID, [
segment.at(masterID),
"我是其他类型的消息中的纯文本消息",
]);
//发送图片
client.sendGroupMsg(
groupID,
segment.image(`https://maohaoji.com/image标签.gif`)
);
//当然图片也可以组合其他类型的消息发送
client.sendGroupMsg(groupID, [
segment.at(masterID),
segment.image(`https://maohaoji.com/image标签.gif`),
]);
//更多内容请查看文档或者去浏览segment的d.ts文件
});