Ninzore / Wecab

最好的订阅制QQbot
GNU General Public License v3.0
204 stars 18 forks source link

[BUG] pixiv需要代理 #59

Open Miuzarte opened 2 years ago

Miuzarte commented 2 years ago

发送看看p站+PID的时候机器人没有反应, 日志无任何输出 error-1.log中也找不到pixiv功能暂停的字样 其他功能都正常 梯子正常

Ninzore commented 2 years ago

来个id,我试试

Miuzarte commented 2 years ago

来个id,我试试

93918985

Ninzore commented 2 years ago

我这边没有问题,建议先检查后端的输出,是否有风控问题(一般都是这个)

Miuzarte commented 2 years ago

我这边没有问题,建议先检查后端的输出,是否有风控问题(一般都是这个)

gocq也是没反应

Miuzarte commented 2 years ago

我这边没有问题,建议先检查后端的输出,是否有风控问题(一般都是这个)

我这个号基本不会有风控问题,天天隔壁cqps来色图没出过事(

Miuzarte commented 2 years ago

https://cowtransfer.com/s/43cb9b87fa384e kwv30y 这个是我npm i npm i -g pm2出来的, 你跑这个试试

Ninzore commented 2 years ago

你都部署成功了我不需要看你安装过程吧...

Miuzarte commented 2 years ago

你都部署成功了我不需要看你安装过程吧...

那这问题咋解决,我提供不了更多信息了

Miuzarte commented 2 years ago

你都部署成功了我不需要看你安装过程吧...

啊这个不是过程,是npm i之后的项目,你跑这个看看能不能复现

Ninzore commented 2 years ago

我用你的项目试了,可以用

Ninzore commented 2 years ago

你现在把gocq的log level 改成info或debug,确定是不是真的没有问题

Ninzore commented 2 years ago

我自己也重新安装了一次,没有出现问题

Miuzarte commented 2 years ago
[2021-11-06 06:57:05] [INFO]: 当前版本:v1.0.0-beta7-fix2 
[2021-11-06 06:57:05] [INFO]: 用户交流群: 721829413 
[2021-11-06 06:57:05] [INFO]: 将使用 device.json 内的设备信息运行Bot. 
[2021-11-06 06:57:05] [INFO]: 开始尝试登录并同步消息... 
[2021-11-06 06:57:05] [INFO]: 使用协议: iPad 
[2021-11-06 06:57:06] [INFO]: Protocol -> connect to server: 109.244.128.48:8080 
[2021-11-06 06:57:09] [INFO]: 登录成功 欢迎使用:  
[2021-11-06 06:57:09] [INFO]: 开始加载好友列表... 
[2021-11-06 06:57:09] [INFO]: 共加载 42 个好友. 
[2021-11-06 06:57:09] [INFO]: 开始加载群列表... 
[2021-11-06 06:57:10] [INFO]: 共加载 7 个群. 
[2021-11-06 06:57:10] [INFO]: 信息数据库初始化完成. 
[2021-11-06 06:57:10] [INFO]: 资源初始化完成, 开始处理信息. 
[2021-11-06 06:57:10] [INFO]: アトリは、高性能ですから! 
[2021-11-06 06:57:10] [INFO]: CQ WebSocket 服务器已启动: 127.0.0.1:6700 
[2021-11-06 06:57:10] [INFO]: CQ WebSocket 服务器已启动: 127.0.0.1:6701 
[2021-11-06 06:57:10] [INFO]: 正在检查更新. 
[2021-11-06 06:57:11] [INFO]: 检查更新完成. 当前已运行最新版本. 
[2021-11-06 06:57:12] [INFO]: 接受 WebSocket 连接: 127.0.0.1:41476 (/event) 
[2021-11-06 06:57:13] [INFO]: 接受 WebSocket 连接: 127.0.0.1:41478 (/api) 
[2021-11-06 06:57:13] [INFO]: 接受 WebSocket 连接: 127.0.0.1:42570 (/api) 
[2021-11-06 06:57:13] [INFO]: 接受 WebSocket 连接: 127.0.0.1:42572 (/event) 
[2021-11-06 06:57:14] [INFO]: 发送好友 qq(qq)  的消息: 已上线#3 (2076844156) 
[2021-11-06 06:57:14] [INFO]: 发送好友 qq(qq)  的消息: 已上线#3 (214765802) 
[2021-11-06 06:57:17] [INFO]: 收到群 pan.tencent.com(group) 内 rurudo单推(qq) 的消息: 看看p站93918985 (145680620) 
[2021-11-06 06:57:38] [INFO]: 收到群 pan.tencent.com(gourp) 内 rurudo单推(qq) 的消息: 看看陈睿b站 (2141837434) 
[2021-11-06 06:57:39] [INFO]: 发送群 pan.tencent.com(group) 的消息: 陈睿的B站动态
19 ... (-705600050) 

trace等级的日志 两个已上线是因为还开了个cqps 真的啥也没有啊

Miuzarte commented 2 years ago

Screenshot_2021-11-06-07-02-24-128_com.termux.jpg

Ninzore commented 2 years ago

虽然不知道是什么问题,你先把plugin/pixivImage.js这样弄一下吧,重启然后看看有没啥输出

import axios from "axios";

const deleteMsg = global.config.pixiv.deleteMsg;

function pixivCheck(context, replyFunc, bot) {
    console.log(111)
    if (/^看看p站.?/i.test(context.message)) {
        let pic_id = /\d+/.exec(context.message);
        console.log(222,pic_id)
        if (pic_id != null) singleArtwork(pic_id[0], replyFunc, context, bot);
        return true;
    }
    else return false;
}

async function checkImage(url, method = 'HEAD') {
    return axios({
        url,
        method
    }).catch(err => {return err.response});
}

function imageCQcode(pic_id) {
    return `[CQ:image,,cache=0,file=https://pixiv.cat/${pic_id}.jpg]`;
}

async function singleArtwork(pic_id, replyFunc, context, bot) {
    let payload = "";
    let url = `https://pixiv.cat/${pic_id}.jpg`
    let res = await checkImage(url, "GET");
    let delete_flag = true;
    console.log(333)
    if (res.status == 404) {
        if (/這個作品ID中有 (\d{1,2}) 張圖片/.test(res.data)) {
            const num_img = parseInt(/這個作品ID中有 (\d{1,2}) 張圖片/.exec(res.data)[1]);
            for (let i = 1; i < num_img + 1; i++) {
                payload += imageCQcode(`${pic_id}-${i}`);
            }
        }
        else if (/這個作品ID中有多張圖片/.test(res.data)) {
            let i = 1;
            do {
                let url = `https://pixiv.cat/${pic_id}-${i}.jpg`;
                res = await checkImage(url);
                if (res.status != 200) break;
                else payload += imageCQcode(`${pic_id}-${i}`);
                i++;
            }
            while (res != false);
        }
        else {
            payload = "图可能被删了";
            delete_flag = false;
        }
    }
    else payload = imageCQcode(pic_id);
    sender(replyFunc, context, payload, bot, delete_flag);
}

function sender(replyFunc, context, payload, bot, delete_flag) {
    console.log(444, payload)
    replyFunc(context, payload).then(res => {
        console.log(555)
        if (deleteMsg && delete_flag && res && res.data && res.data.message_id)
            setTimeout(() => {
                bot('delete_msg', {
                    message_id : res.data.message_id,
                });
            }, 60 * 1000);
    })
    .catch(err => {
        console.error(`${new Date().toLocaleString()} [error] delete msg\n${err}`);
    });
}

export default {pixivCheck};
Miuzarte commented 2 years ago

虽然不知道是什么问题,你先把plugin/pixivImage.js这样弄一下吧,重启然后看看有没啥输出

import axios from "axios";

const deleteMsg = global.config.pixiv.deleteMsg;

function pixivCheck(context, replyFunc, bot) {
    console.log(111)
    if (/^看看p站.?/i.test(context.message)) {
        let pic_id = /\d+/.exec(context.message);
        console.log(222,pic_id)
        if (pic_id != null) singleArtwork(pic_id[0], replyFunc, context, bot);
        return true;
    }
    else return false;
}

async function checkImage(url, method = 'HEAD') {
    return axios({
        url,
        method
    }).catch(err => {return err.response});
}

function imageCQcode(pic_id) {
    return `[CQ:image,,cache=0,file=https://pixiv.cat/${pic_id}.jpg]`;
}

async function singleArtwork(pic_id, replyFunc, context, bot) {
    let payload = "";
    let url = `https://pixiv.cat/${pic_id}.jpg`
    let res = await checkImage(url, "GET");
    let delete_flag = true;
    console.log(333)
    if (res.status == 404) {
        if (/這個作品ID中有 (\d{1,2}) 張圖片/.test(res.data)) {
            const num_img = parseInt(/這個作品ID中有 (\d{1,2}) 張圖片/.exec(res.data)[1]);
            for (let i = 1; i < num_img + 1; i++) {
                payload += imageCQcode(`${pic_id}-${i}`);
            }
        }
        else if (/這個作品ID中有多張圖片/.test(res.data)) {
            let i = 1;
            do {
                let url = `https://pixiv.cat/${pic_id}-${i}.jpg`;
                res = await checkImage(url);
                if (res.status != 200) break;
                else payload += imageCQcode(`${pic_id}-${i}`);
                i++;
            }
            while (res != false);
        }
        else {
            payload = "图可能被删了";
            delete_flag = false;
        }
    }
    else payload = imageCQcode(pic_id);
    sender(replyFunc, context, payload, bot, delete_flag);
}

function sender(replyFunc, context, payload, bot, delete_flag) {
    console.log(444, payload)
    replyFunc(context, payload).then(res => {
        console.log(555)
        if (deleteMsg && delete_flag && res && res.data && res.data.message_id)
            setTimeout(() => {
                bot('delete_msg', {
                    message_id : res.data.message_id,
                });
            }, 60 * 1000);
    })
    .catch(err => {
        console.error(`${new Date().toLocaleString()} [error] delete msg\n${err}`);
    });
}

export default {pixivCheck};
1|wecab  | 2021-11-06T07:42:23: 222 [ '93918985', index: 4, input: '看看p站93918985', groups: undefined ]

wecab是绿色 gocq日志没动静

Ninzore commented 2 years ago

只有111和222是吗,没到3?

Miuzarte commented 2 years ago

只有111和222是吗,没到3?

确实

1|wecab  | 2021-11-06T07:42:23: 111
1|wecab  | 2021-11-06T07:42:23: 222 [ '93918985', index: 4, input: '看看p站93918985', groups: undefined ]
1|wecab  | 2021-11-06T07:42:50: twitter subs less than 1
1|wecab  | 2021-11-06T07:44:33: Error code null, retry times = 2

1|wecab  | 2021-11-06T07:45:21: 111
1|wecab  | 2021-11-06T07:45:21: 222 [ '93918985', index: 4, input: '看看p站93918985', groups: undefined ]
1|wecab  | 2021-11-06T07:45:34: 111
1|wecab  | 2021-11-06T07:45:34: 222 [ '9391898', index: 4, input: '看看p站9391898', groups: undefined ]
Ninzore commented 2 years ago

那现在中间部分改成这样

async function checkImage(url, method = 'HEAD') {
    console.log(22)
    return axios({
        url,
        method
    }).catch(err => {return err.response});
}

function imageCQcode(pic_id) {
    return `[CQ:image,,cache=0,file=https://pixiv.cat/${pic_id}.jpg]`;
}

async function singleArtwork(pic_id, replyFunc, context, bot) {
    console.log(21)
    let payload = "";
    let url = `https://pixiv.cat/${pic_id}.jpg`
    let res = await checkImage(url, "GET");
    let delete_flag = true;
    console.log(333, res)
    if (res.status == 404) {
        if (/這個作品ID中有 (\d{1,2}) 張圖片/.test(res.data)) {
            const num_img = parseInt(/這個作品ID中有 (\d{1,2}) 張圖片/.exec(res.data)[1]);
            for (let i = 1; i < num_img + 1; i++) {
                payload += imageCQcode(`${pic_id}-${i}`);
            }
        }
Miuzarte commented 2 years ago

那现在中间部分改成这样

async function checkImage(url, method = 'HEAD') {
    console.log(22)
    return axios({
        url,
        method
    }).catch(err => {return err.response});
}

function imageCQcode(pic_id) {
    return `[CQ:image,,cache=0,file=https://pixiv.cat/${pic_id}.jpg]`;
}

async function singleArtwork(pic_id, replyFunc, context, bot) {
    console.log(21)
    let payload = "";
    let url = `https://pixiv.cat/${pic_id}.jpg`
    let res = await checkImage(url, "GET");
    let delete_flag = true;
    console.log(333, res)
    if (res.status == 404) {
        if (/這個作品ID中有 (\d{1,2}) 張圖片/.test(res.data)) {
            const num_img = parseInt(/這個作品ID中有 (\d{1,2}) 張圖片/.exec(res.data)[1]);
            for (let i = 1; i < num_img + 1; i++) {
                payload += imageCQcode(`${pic_id}-${i}`);
            }
        }
1|wecab  | 2021-11-06T08:08:11: 111
1|wecab  | 2021-11-06T08:08:11: 222 [ '9391898', index: 4, input: '看看p站9391898', groups: undefined ]
1|wecab  | 2021-11-06T08:08:11: 21
1|wecab  | 2021-11-06T08:08:11: 22
Ninzore commented 2 years ago

emmmm, 你试试服务器直接访问 https://pixiv.cat/93918985.jpg呢,crul wget都行,是不是连不上但是也不会有error,只能等timeout?你是用的腾讯云?

Miuzarte commented 2 years ago

emmmm, 你试试直接访问 https://pixiv.cat/93918985.jpg呢,是不是不行?你是用的腾讯云?

机子是上海腾讯云,梯子挂的香港腾讯云 在香港那边实测能curl到,手机开梯也能加载 难不成pixiv没走代理 上海curl不动

Ninzore commented 2 years ago

pixiv.cat这个代理站之前国内是可以直连的,看来现在麻了。那先做成走代理吧,之后不用代理站走主站了

Miuzarte commented 2 years ago

啥时候能用上呢(

Yubainc commented 2 years ago

pixiv.cat这个代理站之前国内是可以直连的,看来现在麻了。那先做成走代理吧,之后不用代理站走主站了

可以将 pixiv.cat 改为 pixiv.re