Explorar el Código

Merge branch 'koishi-production' into mediaonly-koishi

Mike L hace 3 años
padre
commit
c2380ba7a5
Se han modificado 4 ficheros con 18 adiciones y 8 borrados
  1. 8 3
      dist/command.js
  2. 1 1
      dist/twitter.js
  3. 8 3
      src/command.ts
  4. 1 1
      src/twitter.ts

+ 8 - 3
dist/command.js

@@ -170,16 +170,21 @@ function view(chat, args, reply) {
     if (args.length === 0 || !args[0]) {
         return reply('找不到要查看的链接或表达式。');
     }
-    const match = /^(last(?:|-\d+)@[^\/?#]+)$/.exec(args[0]) ||
+    const match = /^(last(?:|-(\d+))@[^\/?#]+)$/.exec(args[0]) ||
         /^(?:.*twitter.com\/[^\/?#]+\/status\/)?(\d+)/.exec(args[0]);
     if (!match) {
         return reply(`链接或表达式格式有误。
 示例:
-https://twitter.com/TomoyoKurosawa/status/1294613494860361729
+https://twitter.com/TomoyoKurosawa/status/1486136914864345092
+1486136914864345092
+(注:直接查看指定推文时并不会区分其媒体属性)
 last@TomoyoKurosawa
-last-2@sunflower930316,noreps=off,norts=on
+last-1@sunflower930316,noreps=off,norts=on
 (表达式筛选参数详见 /help twitterpic_query)`);
     }
+    if (Math.abs(Number(match[2])) >= 50) {
+        return reply('表达式中指定的回溯数量超出取值范围。');
+    }
     let forceRefresh;
     for (const arg of args.slice(1)) {
         const optMatch = /^(force|refresh)=(.*)/.exec(arg);

+ 1 - 1
dist/twitter.js

@@ -348,7 +348,7 @@ class default_1 {
             const match = /^last(|-\d+)@([^\/?#,]+)((?:,no.*?=[^,]*)*)$/.exec(idOrQuery);
             const query = () => this.queryTimeline({
                 username: match[2],
-                count: 0 - Number(match[1] || -1),
+                count: 1 - Number(match[1]),
                 noreps: { on: true, off: false }[match[3].replace(/.*,noreps=([^,]*).*/, '$1')],
                 norts: { on: true, off: false }[match[3].replace(/.*,norts=([^,]*).*/, '$1')],
             }).then(tweets => tweets.slice(-1)[0].id_str);

+ 8 - 3
src/command.ts

@@ -182,16 +182,21 @@ function view(chat: IChat, args: string[], reply: (msg: string) => any): void {
     return reply('找不到要查看的链接或表达式。');
   }
   const match =
-    /^(last(?:|-\d+)@[^\/?#]+)$/.exec(args[0]) ||
+    /^(last(?:|-(\d+))@[^\/?#]+)$/.exec(args[0]) ||
     /^(?:.*twitter.com\/[^\/?#]+\/status\/)?(\d+)/.exec(args[0]);
   if (!match) {
     return reply(`链接或表达式格式有误。
 示例:
-https://twitter.com/TomoyoKurosawa/status/1294613494860361729
+https://twitter.com/TomoyoKurosawa/status/1486136914864345092
+1486136914864345092
+(注:直接查看指定推文时并不会区分其媒体属性)
 last@TomoyoKurosawa
-last-2@sunflower930316,noreps=off,norts=on
+last-1@sunflower930316,noreps=off,norts=on
 (表达式筛选参数详见 /help twitterpic_query)`);
   }
+  if (Math.abs(Number(match[2])) >= 50) {
+    return reply('表达式中指定的回溯数量超出取值范围。');
+  }
   let forceRefresh: boolean;
   for (const arg of args.slice(1)) {
     const optMatch = /^(force|refresh)=(.*)/.exec(arg);

+ 1 - 1
src/twitter.ts

@@ -159,7 +159,7 @@ export default class {
       const match = /^last(|-\d+)@([^\/?#,]+)((?:,no.*?=[^,]*)*)$/.exec(idOrQuery);
       const query = () => this.queryTimeline({
           username: match[2],
-          count: 0 - Number(match[1] || -1),
+          count: 1 - Number(match[1]),
           noreps: {on: true, off: false}[match[3].replace(/.*,noreps=([^,]*).*/, '$1')],
           norts: {on: true, off: false}[match[3].replace(/.*,norts=([^,]*).*/, '$1')],
         }).then(tweets => tweets.slice(-1)[0].id_str);