jdpro icon indicating copy to clipboard operation
jdpro copied to clipboard

bark 请求可以从get改成post么

Open scccy opened this issue 1 year ago • 22 comments

get 请求body过大 多用户下无法推送

scccy avatar Jul 01 '24 05:07 scccy

@scccy 哪个?就是post的呀

6dylan6 avatar Jul 01 '24 12:07 6dylan6

这是HTTPError: Response code 431 (Request Header Fields Too Large) 然后我去看了sendNotify.js跟sendNotify.py

scccy avatar Jul 01 '24 13:07 scccy

def bark(title, content): print("\n") if BARK: try: response = requests.get( f"""https://api.day.app/{BARK}/{title}/{urllib.parse.quote_plus(content)}""").json() if response['code'] == 200: print('推送成功!') else: print('推送失败!') except: print('推送失败!') if BARK_PUSH: try: response = requests.get( f"""{BARK_PUSH}/{title}/{urllib.parse.quote_plus(content)}""").json() if response['code'] == 200: print('推送成功!') else: print('推送失败!') except: print('推送失败!') print("bark服务启动") if BARK=='' and BARK_PUSH=='': print("bark服务的bark_token未设置!!\n取消推送") return

scccy avatar Jul 01 '24 13:07 scccy

Bark APP发送通知调用API失败!!

HTTPError: Response code 431 (Request Header Fields Too Large) at Request. (/ql/node_modules/.pnpm/[email protected]/node_modules/got/dist/source/as-promise/index.js:118:42) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { code: 'ERR_NON_2XX_3XX_RESPONSE', timings: { start: 1719809593488, socket: 1719809593489, lookup: 1719809593553, connect: 1719809593553, secureConnect: undefined, upload: 1719809593553, response: 1719809593557, end: 1719809593558, error: undefined, abort: undefined, phases: { wait: 1, dns: 64, tcp: 0, tls: undefined, request: 0, firstByte: 4, download: 1, total: 70 } } } 这是推送报错

scccy avatar Jul 01 '24 13:07 scccy

@scccy 分段吧,太多post也不行

6dylan6 avatar Jul 01 '24 13:07 6dylan6

@scccy 分段吧,太多post也不行

这个需要我在用户端修改吗

scccy avatar Jul 01 '24 13:07 scccy

@scccy 什么通知报的

6dylan6 avatar Jul 01 '24 13:07 6dylan6

资产统计还有农场 现在jd的推送我都收不到了

scccy avatar Jul 01 '24 13:07 scccy

@scccy 看readme里,分组通知等用法参考[notify.md]

6dylan6 avatar Jul 01 '24 15:07 6dylan6

@6dylan6 改成post能解决大部分问题。 前阵子我去青龙项目反馈过,已经改成了post推送,当时把改后的脚本替换本项目的推送脚本都可以用了。这两天发现没有推送,查了下应该是订阅自动更新导致脚本又变回去了。

Rebuilding127 avatar Jul 16 '24 02:07 Rebuilding127

@6dylan6 另外青龙项目的通知脚本好像已经重构了,本项目的好像还是延用之前的脚本文件内容,是否考虑更新一下?

Rebuilding127 avatar Jul 16 '24 02:07 Rebuilding127

是的我记得是17版本好想说已经改成post了

获取 Outlook for iOShttps://aka.ms/o0ukef


发件人: Rebuilding127 @.> 发送时间: Tuesday, July 16, 2024 10:19:26 AM 收件人: 6dylan6/jdpro @.> 抄送: scccy @.>; Mention @.> 主题: Re: [6dylan6/jdpro] bark 请求可以从get改成post么 (Issue #344)

@6dylan6https://github.com/6dylan6 改成post能解决大部分问题。 前阵子我去青龙项目反馈过,已经改成了post推送,当时把改后的脚本替换本项目的推送脚本都可以用了。这两天发现没有推送,查了下应该是订阅自动更新导致脚本又变回去了。

― Reply to this email directly, view it on GitHubhttps://github.com/6dylan6/jdpro/issues/344#issuecomment-2229874316, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AG6SAU5F6AUTV57JADQVBHDZMR7K5AVCNFSM6AAAAABKEZZ74SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRZHA3TIMZRGY. You are receiving this because you were mentioned.Message ID: @.***>

scccy avatar Jul 16 '24 02:07 scccy

@Rebuilding127 哪里呀,我上次看的是post的啊

6dylan6 avatar Jul 16 '24 02:07 6dylan6

@Rebuilding127 哪里呀,我上次看的是post的啊

我看本项目中的代码已经是post了,但是我在青龙面板上去看订阅更新后的最新代码,还是get。

青龙面板 - 脚本管理 - 6dylan6_jdpro_main 目录下的 sendNotify.js 文件,另外在该目录下的 function/sendNotify.js 文件又是post,不太理解。

Rebuilding127 avatar Jul 16 '24 03:07 Rebuilding127

@Rebuilding127 你看你用的是不是库里的sendnotify文件,青龙会用自带的覆盖库里的,你要把库里的放到deps防止覆盖

6dylan6 avatar Jul 16 '24 03:07 6dylan6

@Rebuilding127 你看你用的是不是库里的sendnotify文件,青龙会用自带的覆盖库里的,你要把库里的放到deps防止覆盖

两个问题: 1、我怎么确定用的是哪个sendnotify文件?我在脚本管理里搜索看到就3个,根目录下有一个是青龙自带的,订阅目录下有两个,位置我上面说过了。 就看到的代码而言就只有订阅目录下的那个有问题。 2、把库里的放到deps防止覆盖是什么意思?deps目录是在哪里?

Rebuilding127 avatar Jul 16 '24 07:07 Rebuilding127

@Rebuilding127 脚本管理不是可以看到,deps在容器里,web看不到

6dylan6 avatar Jul 16 '24 08:07 6dylan6

@6dylan6 从日志来分析

[🔵info] [2024-07-16 15:50:49]: 	[panel][开始执行任务] 参数 {"name":"京东资产统计","command":"task 6dylan6_jdpro_main/jd_bean_change.js","schedule":"28 8,21 * * *","extraSchedules":null}

资产统计脚本是 6dylan6_jdpro_main/jd_bean_change.js 这个文件,然后我在脚本管理里打开这个文件查看,前几行代码是


const $ = new Env('京东资产统计');
const notify = $.isNode() ? require('./sendNotify') : '';
//Node.js用户请在jdCookie.js处填写京东ck;
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
const dyx = require('./function/dylanx.js');
let NowHour = new Date().getHours();

引入的是同目录下的 sendNotify 文件,那就是我上面说的 6dylan6_jdpro_main/sendNotify.js 文件,目前看到就是这个文件有问题,使用的是 get 方法。

function BarkNotify(text, desp, params = {}) {
  return new Promise((resolve) => {
    if (BARK_PUSH) {
      const options = {
        url: `${BARK_PUSH}/${encodeURIComponent(text)}/${encodeURIComponent(
          desp,
        )}?icon=${BARK_ICON}&sound=${BARK_SOUND}&group=${BARK_GROUP}&level=${BARK_LEVEL}&url=${BARK_URL}&${querystring.stringify(
          params,
        )}`,
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded',
        },
        timeout,
      };
      $.get(options, (err, resp, data) => {
        try {
          if (err) {
            console.log('Bark APP发送通知调用API失败!!\n');
            console.log(err);
          } else {
            data = JSON.parse(data);
            if (data.code === 200) {
              console.log('Bark APP发送通知消息成功🎉\n');
            } else {
              console.log(`${data.message}\n`);
            }
          }
        } catch (e) {
          $.logErr(e, resp);
        } finally {
          resolve();
        }
      });
    } else {
      resolve();
    }
  });
}

Rebuilding127 avatar Jul 16 '24 08:07 Rebuilding127

@Rebuilding127 所以不是我的啊,https://github.com/6dylan6/jdpro/blob/main/sendNotify.js,库里是这个

6dylan6 avatar Jul 16 '24 08:07 6dylan6

@Rebuilding127 所以不是我的啊,https://github.com/6dylan6/jdpro/blob/main/sendNotify.js,库里是这个

我明白你的意思,我前面也说了,我看项目代码里的这个文件是没问题的。但是我也不明白为啥我在脚本管理里面看到的是有问题的,6dylan6_jdpro_main/ 目录下的文件不是随着订阅更新而更新的吗?

Rebuilding127 avatar Jul 16 '24 08:07 Rebuilding127

@Rebuilding127 开始就说了,青龙自带的覆盖了啊,去deps目录替换

6dylan6 avatar Jul 16 '24 08:07 6dylan6

@Rebuilding127 开始就说了,青龙自带的覆盖了啊,去deps目录替换

我去看了下,容器映射的数据目录下有 deps 文件夹,里面有 notify.py sendNotify.js 两个文件,是不是把这两个文件覆盖改成最新的就好了?

Rebuilding127 avatar Jul 16 '24 08:07 Rebuilding127