ソースを参照

add max rewind count for view command

Mike L 3 年 前
コミット
ddc1c5a566
2 ファイル変更8 行追加2 行削除
  1. 4 1
      dist/command.js
  2. 4 1
      src/command.ts

+ 4 - 1
dist/command.js

@@ -170,7 +170,7 @@ 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(`链接或表达式格式有误。
@@ -181,6 +181,9 @@ last@TomoyoKurosawa
 last-2@sunflower930316,noreps=off,norts=on
 (表达式筛选参数详见 /help twitter_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);

+ 4 - 1
src/command.ts

@@ -182,7 +182,7 @@ 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(`链接或表达式格式有误。
@@ -193,6 +193,9 @@ last@TomoyoKurosawa
 last-2@sunflower930316,noreps=off,norts=on
 (表达式筛选参数详见 /help twitter_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);