__main__.tin 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. #nop vim: set filetype=tt:;
  2. /*
  3. 本文件属于 PaoTin++ 的一部分
  4. ===========
  5. PaoTin++ © 2020~2023 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 享有并保留一切法律权利
  6. 你可以在遵照 GPLv3 协议的基础之上使用、修改及重新分发本程序。
  7. ===========
  8. */
  9. #var quest_answer[META] {
  10. {NAME} {答问如流}
  11. {DESC} {解析问题和选项,答题期间提供捷键简化输入,会在超时前默认自动答 c}
  12. {AUTHOR} {担子炮}
  13. {NOTE} {本文件属于 PaoTin++ 的一部分}
  14. };
  15. #nop 答题每天早八点和晚八点开始。;
  16. #nop -------------- 答题 API ---------------------;
  17. VAR {当前问题} answer.question {};
  18. VAR {简单题库} answer.question-bank {};
  19. ///=== {
  20. // ## answer.Enable
  21. // 开启答题。
  22. // 这样服务器就会给你推送题目。
  23. //
  24. // ## answer.Disable
  25. // 关闭答题。
  26. // 让服务器不再给你推送题目。
  27. // };
  28. #alias {answer.Enable} {env.Set answer_question};
  29. #alias {answer.Disable} {env.UnSet answer_question};
  30. ///=== {
  31. // ## answer.MapABCD
  32. // 创建选项快捷键。用小写字母 a/b/c/d 一键式答题,不用再输入 answer 命令。
  33. // };
  34. #alias {answer.MapABCD} {
  35. #class answer.select open;
  36. #alias {a} {answer.select a manual};
  37. #alias {b} {answer.select b manual};
  38. #alias {c} {answer.select c manual};
  39. #alias {d} {answer.select d manual};
  40. #class answer.select close;
  41. okLog 已经创建别名,你可以用 a/b/c/d 选择选项。如果在计时结束前仍未选择,将自动答 C。;
  42. };
  43. #nop -------------- 答题的核心流程 ---------------------;
  44. #action {^【答问如流】答问如流活动,答题许可即将开始推送。$E} {
  45. answerLog %99;
  46. infoLog <169> 答题之前准备好几件事:;
  47. infoLog <169> * finger;
  48. infoLog <169> * who -pro -l;
  49. infoLog <169> * who -l;
  50. infoLog <169> * ask bai xiaosheng about 大势;
  51. infoLog <169> * 准备好道德经;
  52. infoLog <169> * 准备好古诗文;
  53. infoLog <169> * 打开 QQ,关注群里 MUD 消息发送的 emoji;
  54. infoLog <169> * 打开浏览器,准备好搜索引擎;
  55. answer.ask-dashi false;
  56. prompt.Set {{dati}{<119>等待图片验证<299>(60)}};
  57. } {4};
  58. #nop 你获得了答问如流许可,有效期到Wed May 1 20:26:17 2024。;
  59. #action {^你获得了答问如流许可,有效期到%*。$E} {
  60. answerLog %99;
  61. prompt.Set {{dati}{<129>图片验证成功<299>}};
  62. } {4};
  63. #action {^【答问如流】答问如流活动答题许可推送完毕,1分钟后活动正式开始。$E} {
  64. answerLog %99;
  65. prompt.Set {{dati}{<139>等待正式开始<299>(60)}};
  66. answer.MapABCD;
  67. } {4};
  68. #action {^【答问如流】现在是第%*题,请用命令answer回答,答题期限为%*秒。%*$E} {
  69. answerLog %99;
  70. #local timeout {%2};
  71. #var answer.question {
  72. {idx} {@math.ParseCN{%1}}
  73. {time} {@time.Now{}}
  74. {timeout} {$timeout}
  75. {chat} {}
  76. };
  77. math.Inc timeout -3;
  78. prompt.Set {{dati}{<134>等待选择<299>($timeout)}};
  79. #delay answer.select {answer.select c default} $timeout;
  80. #class answer.parse.chat open;
  81. #action {^【闲聊】%*(%*): %u$} {
  82. #var answer.question[chat] {$answer.question[chat]@str.Trim{%%3}};
  83. } {4};
  84. #class answer.parse.chat close;
  85. } {4};
  86. #action {^【答问如流】下面是附加题,%*级以上玩家可选答,答题期限为%*秒。$E} {
  87. answerLog %99;
  88. } {4};
  89. #action {^【答问如流】%*$E} {
  90. answerLog %99;
  91. #class answer.parse.chat kill;
  92. answer.set-question {%1};
  93. } {4.5};
  94. #alias {answer.set-question} {
  95. #local text {@str.Trim{%1}};
  96. #replace text {【答问如流】} {};
  97. #var answer.question[text] {$text};
  98. };
  99. #action {^【备选答案】A.%*%sB.%*%sC.%*%sD.%*$E} {
  100. answerLog %99;
  101. #class answer.gather-all-lines kill;
  102. #var answer.question[options][a] {@str.Trim{%1}};
  103. #var answer.question[options][b] {@str.Trim{%3}};
  104. #var answer.question[options][c] {@str.Trim{%5}};
  105. #var answer.question[options][d] {@str.Trim{%7}};
  106. #showme {【请作答】$answer.question[text]};
  107. } {4};
  108. #action {^你选择了%.,恭喜你!答对了。$E} {
  109. answerLog %99;
  110. #undelay answer.select;
  111. };
  112. #action {^你选择了%.,很遗憾,这不是正确答案。$E} {
  113. answerLog %99;
  114. #undelay answer.select;
  115. };
  116. #action {^本次答对你被奖励了%*点经验,%*点潜能。$E} {
  117. answerLog %99;
  118. };
  119. #action {^连续答对%*题后,你的答题奖励系数为%*%,本次答对你被奖励了%*点经验,%*点潜能。$E} {
  120. answerLog %99;
  121. };
  122. #action {^【答问如流】本次问答活动结束,谢谢各位的参与。{| 祝各位周末愉快 \^_\^}$E} {
  123. answerLog %99;
  124. #class answer.select kill;
  125. prompt.Set {{dati}{}};
  126. } {4};
  127. #nop 这一条触发不是服务器发送的,而是本地模拟的文字,目的是为了插件式写触发。;
  128. #action {^【请作答】%*$E} {
  129. #line gag;
  130. #local question {%1};
  131. #replace question {{?|:|}$} {};
  132. #local value {$answer.question-bank[$question]};
  133. #if { "$value" == "" } {
  134. answerLog <139>不认识的新题目:<299> %1;
  135. answer.dump-question;
  136. #return;
  137. };
  138. answer.select-by-pattern $value;
  139. } {4.1};
  140. #nop -------------- 工具触发 ---------------------;
  141. #alias {answer.gather-all-lines} {
  142. #class answer.gather-all-lines open;
  143. #action {^%*$} {
  144. answerLog %%99;
  145. #list answer.question[colorLines] add {{%%99}};
  146. #list answer.question[plainLines] add {{%%0}};
  147. } {5.5};
  148. #class answer.gather-all-lines close;
  149. };
  150. #alias {answer.select-by-pattern} {
  151. #local pattern {%1};
  152. #local option {};
  153. #foreach {a;b;c;d} {option} {
  154. #if { "$answer.question[options][$option]" == "$pattern" } {
  155. answer.select $option pattern $pattern;
  156. #break;
  157. };
  158. };
  159. };
  160. #alias {answer.select-by-number} {
  161. #local number {%1};
  162. #local option {};
  163. #foreach {a;b;c;d} {option} {
  164. #if { "$answer.question[options][$option]" == "$number" } {
  165. answer.select $option number $number;
  166. #break;
  167. };
  168. };
  169. };
  170. #alias {answer.dump-question} {
  171. #line quiet #line capture tmp #var answer.question;
  172. #local id {};
  173. #loop 1 &tmp[] {id} {answerLog $tmp[+$id]};
  174. };
  175. #alias {answer.select} {
  176. #local option {@default{%1;c}};
  177. #local source {%2};
  178. #local value {%3};
  179. #switch {"$source"} {
  180. #case {"default"} {answerLog 默认选择了 $option};
  181. #case {"pattern"} {answerLog 基于答案 $value,自动选择了 $option};
  182. #case {"number"} {answerLog 基于答案 $value,自动选择了 $option};
  183. #case {"manual"} {answerLog 手动选择了 $option};
  184. };
  185. answer $option;
  186. };