| Revision | a7ea60106d30345d5b632b5cd4a4d7f2d62a3379 (tree) |
|---|---|
| Time | 2012-11-11 03:07:56 |
| Author | spoon <spoon78@user...> |
| Commiter | spoon |
Ver.0.6.0 -r/--range, -m/--max を追加
| @@ -13,21 +13,21 @@ using System.Net; | ||
| 13 | 13 | /**************** 00:00:00.00 集計ツール ****************/ |
| 14 | 14 | |
| 15 | 15 | [assembly: System.Reflection.AssemblyTitle("00:00:00.00 集計ツール")] |
| 16 | -[assembly: System.Reflection.AssemblyFileVersion("0.5.1")] | |
| 16 | +[assembly: System.Reflection.AssemblyFileVersion("0.6.0")] | |
| 17 | 17 | |
| 18 | 18 | /***** USAGE ***** |
| 19 | - * ex. url => http://ex14.vip2ch.com/test/read.cgi/news4vip/1292079479/ | |
| 20 | - * > 00.00.00.00 http://ex14.vip2ch.com/test/read.cgi/news4vip/1292079479/ | |
| 21 | - * > 00.00.00.00 1292079479 ex14.vip2ch.com | |
| 19 | + * ex. url => http://hayabusa.2ch.net/test/read.cgi/news4vip/1234567890/ | |
| 20 | + * > 00.00.00.00 http://hayabusa.2ch.net/test/read.cgi/news4vip/1234567890/ | |
| 21 | + * > 00.00.00.00 1234567890 hayabusa.2ch.net | |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | 24 | namespace Vip { |
| 25 | 25 | static class Rank00 { |
| 26 | - const string VERSION = "0.5.1"; | |
| 26 | + const string VERSION = "0.6.0"; | |
| 27 | 27 | |
| 28 | 28 | static string dat, server = "hayabusa.2ch.net", board = "news4vip"; |
| 29 | 29 | static string url; |
| 30 | - static int range = 1, rankMax = 20, from = 1, count, countRange = 10; | |
| 30 | + static int range = 1, rankMax = 20, from = 1, count, countRange = 5; | |
| 31 | 31 | static string[] ngId; |
| 32 | 32 | static bool local = false; |
| 33 | 33 | static string localPath; |
| @@ -82,17 +82,58 @@ namespace Vip { | ||
| 82 | 82 | |
| 83 | 83 | // * NGID |
| 84 | 84 | // 除外したい ID:*** をカンマ区切りで指定 |
| 85 | - // ex. -ng oBJccH+E0,7DnAJlQ/P | |
| 86 | - index = Array.IndexOf<string>(args, "--ngid"); | |
| 85 | + // ex. --ngid oBJccH+E0,7DnAJlQ/P | |
| 86 | + index = Array.IndexOf<string>(args, "-n"); | |
| 87 | + if (index == -1) index = Array.IndexOf<string>(args, "--ngid"); | |
| 87 | 88 | if (index != -1) { |
| 88 | 89 | if (args.Length == index + 1) { |
| 89 | - Console.Error.WriteLine("Error: --ngid の値が正しくありません"); | |
| 90 | + Console.Error.WriteLine("Error: -n / --ngid の値が正しくありません"); | |
| 90 | 91 | return; |
| 91 | 92 | } |
| 92 | 93 | ngId = args[index + 1].Split(','); |
| 93 | 94 | args[index + 1] = "-"; |
| 94 | 95 | } |
| 95 | 96 | |
| 97 | + // * 集計対象 / 参加人数の対象範囲 | |
| 98 | + // ±(range)秒以内を集計対象に (デフォルト値: 1) | |
| 99 | + // ±(countRange)秒以内を参加人数の対象に (デフォルト値: 5) | |
| 100 | + index = Array.IndexOf<string>(args, "-r"); | |
| 101 | + if (index == -1) index = Array.IndexOf<string>(args, "--range"); | |
| 102 | + if (index != -1) { | |
| 103 | + if (args.Length == index + 1) { | |
| 104 | + Console.Error.WriteLine("Error: -r / --range の値が正しくありません"); | |
| 105 | + return; | |
| 106 | + } | |
| 107 | + if (args[index + 1].Contains(",")) { | |
| 108 | + string[] pair = args[index + 1].Split(','); | |
| 109 | + if (pair.Length != 2 | |
| 110 | + || !int.TryParse(pair[0], out range) || range < 1 | |
| 111 | + || !int.TryParse(pair[1], out countRange) || countRange < range) { | |
| 112 | + Console.Error.WriteLine("Error: -r / --range の値が正しくありません"); | |
| 113 | + return; | |
| 114 | + } | |
| 115 | + } else { | |
| 116 | + if (!int.TryParse(args[index + 1], out range) || range < 1) { | |
| 117 | + Console.Error.WriteLine("Error: -r / --range の値が正しくありません"); | |
| 118 | + return; | |
| 119 | + } | |
| 120 | + if (countRange < range) countRange = range; | |
| 121 | + } | |
| 122 | + args[index + 1] = "-"; | |
| 123 | + } | |
| 124 | + | |
| 125 | + // * 最大順位 | |
| 126 | + // 表示する最大の順位を指定 | |
| 127 | + index = Array.IndexOf<string>(args, "-m"); | |
| 128 | + if (index == -1) index = Array.IndexOf<string>(args, "--max"); | |
| 129 | + if (index != -1) { | |
| 130 | + if (args.Length == index + 1 || !int.TryParse(args[index + 1], out rankMax) || rankMax < 1) { | |
| 131 | + Console.Error.WriteLine("Error: -m / --max の値が正しくありません"); | |
| 132 | + return; | |
| 133 | + } | |
| 134 | + args[index + 1] = "-"; | |
| 135 | + } | |
| 136 | + | |
| 96 | 137 | // * ローカルdat利用 |
| 97 | 138 | // ローカルのdatを利用する |
| 98 | 139 | // (指定されない場合は、datをダウンロードする) |
| @@ -191,7 +232,7 @@ namespace Vip { | ||
| 191 | 232 | } else if (e.Status == WebExceptionStatus.NameResolutionFailure) { |
| 192 | 233 | Console.Error.WriteLine("Error: DNSエラー URLを確認してください (NameResolutionFailure)"); |
| 193 | 234 | } else { |
| 194 | - Console.Error.WriteLine("Error: エラーが発生しました ({0})", e.Status); | |
| 235 | + Console.Error.WriteLine("Error: ダウンロード中にエラーが発生しました ({0})", e.Status); | |
| 195 | 236 | } |
| 196 | 237 | return; |
| 197 | 238 | } |
| @@ -283,7 +324,7 @@ namespace Vip { | ||
| 283 | 324 | else if (duration == lastDuration) |
| 284 | 325 | rankString = " "; |
| 285 | 326 | else { |
| 286 | - if (i >= rankMax) break; | |
| 327 | + if (i >= rankMax) break; // 最大順位オーバー | |
| 287 | 328 | rankString = (i < 9 ? ". " : null) + (i + 1) + "位 "; |
| 288 | 329 | lastDuration = duration; |
| 289 | 330 | } |
| @@ -318,16 +359,16 @@ namespace Vip { | ||
| 318 | 359 | "#{arr[2]} (#{device})#{" おめでとう!" if arr[1].zero?}" |
| 319 | 360 | */ |
| 320 | 361 | |
| 321 | - Console.WriteLine("±1秒以内に入った人: {0} 人 本日の参加者: {1} 人 (±{2}秒)", | |
| 322 | - resList.Count, | |
| 362 | + Console.WriteLine("±{0}秒以内に入った人: {1} 人 本日の参加者: {2} 人 (±{3}秒)", | |
| 363 | + range, resList.Count, | |
| 323 | 364 | count, countRange); |
| 324 | 365 | |
| 325 | 366 | } |
| 326 | 367 | |
| 327 | 368 | private static void ShowUsage() { |
| 328 | 369 | Console.Error.WriteLine(@"引数: 00.00.00.00 (<dat> [<server> [<board>]] | <url>) [--from <n>] |
| 329 | - [(-i | --ngid) <id>[,<id>...]] [--local <path> | --dl] | |
| 330 | - [-h | -?] | |
| 370 | + [(-n | --ngid) <id>[,<id>...]] [(-r | --range) <sec>[,<sec2>]] | |
| 371 | + [(-m | --max) <rank>] [--local <path> | --dl] [-h | -?] | |
| 331 | 372 | |
| 332 | 373 | <dat> URLの10桁の数字 |
| 333 | 374 | <server> URLのドメインの部分 |
| @@ -335,9 +376,14 @@ namespace Vip { | ||
| 335 | 376 | <url> URLを直接指定 (http://<server>/test/read.cgi/<board>/<dat>/) |
| 336 | 377 | |
| 337 | 378 | --from <n>レス目以降を判定に利用 |
| 338 | - -i, --ngid 除外したい ID:<id> を , で区切って指定 (ex. oBJccH+E0,7DnAJlQ/P) | |
| 379 | + -n, --ngid 除外したい ID:<id> を , で区切って指定 (ex. oBJccH+E0,7DnAJlQ/P) | |
| 380 | + -r, --range 集計対象となる範囲を±<sec>秒で指定 (デフォルト値: 1) | |
| 381 | + オプションで参加人数の対象になる範囲を±<sec2>秒で指定できる | |
| 382 | + (デフォルト値: 5) ※ <sec> は <sec2> 以下であること | |
| 383 | + -m, --max 表示する最大の順位(<rank>位まで)を指定 | |
| 339 | 384 | --local ローカルのdatを利用する datへのパスを<path>で指定 |
| 340 | - --dl datをダウンロードして利用する (両方未指定なら --dl を指定として扱う) | |
| 385 | + --dl datをダウンロードして利用する (両方未指定なら --dl を指定したと | |
| 386 | + して扱う) | |
| 341 | 387 | -h, -? この引数一覧を表示する |
| 342 | 388 | |
| 343 | 389 | Example: 00.00.00.00 1234567890 |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | ************************************************************ |
| 2 | - 00:00:00.00 集計ツール Ver.0.5.1 | |
| 2 | + 00:00:00.00 集計ツール Ver.0.6.0 | |
| 3 | 3 | ************************************************************ |
| 4 | 4 | |
| 5 | 5 | 某巨大掲示板群のとある板にて毎日開催されている、書き込み時刻で00:00:00.00にどれだけ |