-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
48 lines (44 loc) · 1.39 KB
/
app.js
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
const { createClient } = require('oicq')
const request = require('request');
const fs = require('fs');
const path = require('path')
app_config = {
log_level: "info",
platform: 5,
auto_server: true,
ignore_self: true,
resend: true,
cache_group_member: true,
reconn_interval: 5,
data_dir: path.join(process.cwd(), "data"),
}
const config_file = fs.readFileSync('config.json');
const config = JSON.parse(config_file);
const client = createClient(config.account, app_config)
if(config.password === "none") {
client.on("system.login.qrcode", function (e) {
//扫码后按回车登录
process.stdin.once("data", () => {
this.login()
})
}).login()
client.on("system.online", () => console.log("Logged in!"))
}
else {
client.on("system.login.slider", function (e) {
console.log("输入ticket:")
process.stdin.once("data", ticket => this.submitSlider(String(ticket).trim()))
}).login(config.password)
}
client.on("message", msg => {
message = msg.toString()
if(message[0] === '!') {
message.replace('!', ' ')
request.post({url: 'https://cialloo.com/api/chatgpt', body: {'message': message}, json: true}, (err, res, body) => {
let temp = ""
for(let i = 2; i < body.message.length; i++)
temp += body.message[i]
msg.reply(temp, true)
})
}
})