silent.tin 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #nop 做一个安静的客户端。;
  2. #nop 「隐藏自己,做好清理。」—— 《三体·黑暗森林》;
  3. #nop 命令白名单。;
  4. #nop 只有纯小写字母,空格,减号组成的命令无需再加白名单。这里只维护例外;
  5. #var silent-WhiteList {
  6. chat; chat*; qq; qq*;
  7. helpme; helpme*; tt; tt*;
  8. rumor; rumor*; tell; say;
  9. bd; bd*; group; group*;
  10. nation; nation*; ask; i2;
  11. buy; list; node; fullme;
  12. shu; dang; verify; perform;
  13. register; check; answer; reply;
  14. amber_alert; status_me; set; unset;
  15. };
  16. #nop 文字表情;
  17. #cat silent-WhiteList {
  18. ...; :)..; :D; :P; ?;
  19. ??; @@; ad.;
  20. };
  21. #var silent-LastCmd {};
  22. #alias {^%*{|ID=paotin/silent}$} {
  23. #local cmd {%0};
  24. #if { {$cmd} === {} } {
  25. #return;
  26. };
  27. #local ok {@silent.Check{$cmd}};
  28. #if { $ok } {
  29. #var silent-LastCmd {};
  30. xtt.Send {$cmd};
  31. #return;
  32. };
  33. #echo {<169>命令「<139>$cmd<169>」不是一个合法的 MUD 命令,如果确认是,请更新白名单。<099>};
  34. #if { {$cmd} !== {$silent-LastCmd} } {
  35. #echo {<169>本次命令<119>已被抑制<169>。如果你确认命令没问题,可以先<139>回车重复<169>一次本命令,将临时通过一次。<099>};
  36. #var silent-LastCmd {$cmd};
  37. };
  38. #else {
  39. #var silent-LastCmd {};
  40. xtt.Send {%0};
  41. };
  42. } {9.999};
  43. #func {silent.Check} {
  44. #local cmd {%0};
  45. #replace {cmd} {^%S{| (.*)}$} {
  46. {cmd}{&1}
  47. {args}{&3}
  48. };
  49. #local cmd {$cmd};
  50. #nop 这个是 chat;
  51. #if { {$cmd[cmd]} == {'%*} } {
  52. #return 1;
  53. };
  54. #nop 白名单通行;
  55. #if { {$silent-WhiteList[$cmd[cmd]]} == {true} } {
  56. #return 1;
  57. };
  58. #nop 否则只接受指定格式的命令;
  59. #if { {$cmd[cmd]} != {{[a-z0-9_]{1,10}}} } {
  60. #return 0;
  61. };
  62. #nop 参数不允许有特殊字符;
  63. #var silent-check-retcode {};
  64. #regex {$cmd[args]} {{*UTF8}{^([a-z0-9. -]|\p{Han})*$}} {
  65. #var silent-check-retcode {1};
  66. } {
  67. #var silent-check-retcode {0};
  68. };
  69. #local retcode {$silent-check-retcode};
  70. #unvar silent-check-retcode;
  71. #return $retcode;
  72. };
  73. #alias {silent.Init} {
  74. #local list {$silent-WhiteList};
  75. #local cmd {};
  76. #var silent-WhiteList {};
  77. #foreach {$list} {cmd} {
  78. #var {silent-WhiteList[$cmd]} {true};
  79. };
  80. };
  81. silent.Init;