chat.tin 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. #nop vim: set filetype=tt:;
  2. /*
  3. 本文件属于 PaoTin++ 的一部分。
  4. PaoTin++ © 2020~2023 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 享有并保留一切法律权利
  5. 你可以在遵照 GPLv3 协议的基础之上使用、修改及重新分发本程序。
  6. */
  7. ///=== {
  8. ///// chat 模块用来分类聊天记录,分别存放到单独的日志文件里。
  9. // };
  10. #var lib_ui_chat[META] {
  11. {NAME} {聊天日志}
  12. {DESC} {抓取聊天信息,分置到不同的日志文件里去}
  13. {AUTHOR} {担子炮}
  14. };
  15. #var chat-channel {};
  16. #list chat-channel create {
  17. {{pattern}{求助} {action}{helpmeLog} {gag}{true}}
  18. {{pattern}{北侠QQ群} {action}{qqLog} {gag}{true}}
  19. {{pattern}{%!{闲聊|副本|谣言}} {action}{chatLog} {gag}{true}}
  20. {{pattern}{%!{江湖|任务|交易}} {action}{jhLog} {gag}{true}}
  21. {{pattern}{%!{队伍|门派|本地|区域}} {action}{bdLog} {gag}{true}}
  22. {{pattern}{私聊} {action}{tellLog} {gag}{false}}
  23. {{pattern}{%*} {action}{groupLog} {gag}{true}}
  24. };
  25. load-lib storage;
  26. load-lib alert;
  27. #func {lib_ui_chat.Init} {
  28. load-file {etc/ui-chat.tin};
  29. #return true;
  30. };
  31. #nop 普通聊天信息;
  32. #action {~^%c【%+2..5u】%c%*%+1..10u%c({[a-z A-Z]+})%c: %*$E} {
  33. chat.log {%2} {%0};
  34. } {4.994};
  35. #nop 单行的 emote 表情;
  36. #action {~{*UTF8}{?:^}%c【{\p{Han}{2,5}}】%*(%+1..S{| \S+}%s||%s{\S+ |}%+1..S)%c{|◆\p{Han}+◆}%c$E} {
  37. chat.log {%2} {%0};
  38. } {4.994};
  39. #nop 多行的 emote 表情;
  40. #action {~^%c【%+2..5u】%*$E} {
  41. chat.log-multi-line {%2} {%0};
  42. } {4.995};
  43. #alias {chat.log} {
  44. #local type {%1};
  45. #local text {%2};
  46. #local id {};
  47. #loop {1} {&chat-channel[]} {id} {
  48. #local pattern {$chat-channel[$id][pattern]};
  49. #local action {$chat-channel[$id][action]};
  50. #local gag {$chat-channel[$id][gag]};
  51. #if { "$type" == "$pattern" } {
  52. $action $text;
  53. #if { "$gag" == "true" } {
  54. #line gag;
  55. };
  56. #return;
  57. };
  58. };
  59. };
  60. #alias {chat.log-multi-line} {
  61. #local type {%1};
  62. #local text {%2};
  63. chat.log {$type} {$text};
  64. #if { "$type" == "本地" } {
  65. #if { {$text} == {%*天空中突然闪出一道绚丽的火花%*} } {
  66. #class chat.log open;
  67. #action {~^%*{|ID=chat.log}$} {
  68. chat.log {%1} {%%0};
  69. } {4.993};
  70. #action {~^%c{\e\[2;37;0m|}\e[36m{|\e\[2;37;0m }{|\e\[0m}{|ID=chat.log}$} {
  71. chat.log {%1} {%%0};
  72. #class chat.log kill;
  73. } {4.992};
  74. #delay chat.log {#class chat.log kill} 0;
  75. #class chat.log close;
  76. };
  77. };
  78. #if { {$text} == {%*上次争胜后各门派完成主流任务统计:%*} } {
  79. #class chat.log open;
  80. #action {~^%*{|ID=chat.log}$} {
  81. chat.log {%1} {%%0};
  82. } {4.993};
  83. #action {~^%*次。%*$} {
  84. chat.log {%1} {%%0};
  85. #class chat.log kill;
  86. } {4.992};
  87. #delay chat.log {#class chat.log kill} 0;
  88. #class chat.log close;
  89. #return;
  90. };
  91. #if { "$type" == "江湖" } {
  92. #if { {$text} == {%*神力和纵跃排行榜%*} } {
  93. #class chat.log open;
  94. #action {~^%*{|ID=chat.log}$} {
  95. chat.log {%1} {%%0};
  96. } {4.993};
  97. #action {~^%c{[' -]+}%c{|ID=chat.log}$} {
  98. chat.log {%1} {%%0};
  99. #class chat.log kill;
  100. } {4.992};
  101. #delay chat.log {#class chat.log kill} 0;
  102. #class chat.log close;
  103. };
  104. #elseif { {$text} == {%*以下是最近一小时之内死于非命的江湖儿女。%*} } {
  105. #line multishot 4 #action {~^%*{|ID=chat.log}$} {
  106. chat.log {%1} {%%0};
  107. } {4.993};
  108. };
  109. #elseif { {$text} == {%*{[^m )]}\e[0m} } {
  110. #local lines {1};
  111. #if { {$text} == {%*请大家挖泥之余去各大BBS和论坛宣传北大侠客行,宣传内容详见%*} } {
  112. #local lines {2};
  113. };
  114. #line multishot $lines #action {~^%*{|ID=chat.log}$} {
  115. chat.log {%1} {%%0};
  116. } {4.993};
  117. };
  118. #return;
  119. };
  120. #if { "$type" != "{闲聊|求助|谣言}" } {
  121. #return;
  122. };
  123. #if { "$type" == "{闲聊|谣言}" && {$text} == {%* {\e\[0m}} } {
  124. #return;
  125. };
  126. #if { {$text} == {%c【求助】{我是大高手|大高手告诉|大高手说}%*} } {
  127. #return;
  128. };
  129. #if { {$text} == {%c【谣言】某人: 我看到了!!就是%*造的谣!!%c} } {
  130. #return;
  131. };
  132. #class chat.log open;
  133. #action {~^%*{|ID=chat.log}$} {
  134. chat.log {%1} {%%0};
  135. } {4.993};
  136. #action {~^%*(%w%s||%s{\S+ |}%+1..S)%c{|ID=chat.log}$} {
  137. chat.log {%1} {%%0};
  138. #class chat.log kill;
  139. } {4.992};
  140. #if { "$type" == "{闲聊|谣言}" } {
  141. #action {~^%*{\S \e\[0m}{|ID=chat.log}$} {
  142. chat.log {%1} {%%0};
  143. #class chat.log kill;
  144. } {4.992};
  145. };
  146. #delay chat.log {#class chat.log kill} 0;
  147. #class chat.log close;
  148. };
  149. #action {~^%c%u%c(%w)告诉你:%*$} {alert.Add 有私聊; chat.log 私聊 {%0}} {9.999};
  150. #action {~^%c%u%c回答你:%*$} {alert.Add 有私聊; chat.log 私聊 {%0}} {9.999};
  151. #action {~^%c你告诉%c%u%c:%*$} {chat.log 私聊 {%0}} {9.997};
  152. #action {~^%c你回答%c%u%c:%*$} {chat.log 私聊 {%0}} {9.997};
  153. #var chat-open-channels {UNKNOWN};
  154. #var chat-todo-channels {};
  155. ///=== {
  156. // ## chat.TuneOff <频道ID> [...]
  157. // 关闭聊天频道。参数为一个或多个频道 ID。
  158. // 可用的频道 ID 有:
  159. // - 常用: chat rumor qq rw jh helpme
  160. // - 不常用: bd fb tt group nation qy jy mp
  161. // };
  162. #alias {chat.TuneOff} {
  163. #info arguments save;
  164. #unvar info[ARGUMENTS][0];
  165. #local chans {@sset.Create{$info[ARGUMENTS][]}};
  166. #local chan {};
  167. #if { "$chat-open-channels" == "UNKNOWN" } {
  168. #foreach {$chans} {chan} {
  169. #var chat-todo-channels[$chan] {off};
  170. };
  171. };
  172. #else {
  173. #local todo {@sset.Intersection{{$chans};{$chat-open-channels}}};
  174. #foreach {$todo} {chan} {
  175. tune channel $chan;
  176. };
  177. };
  178. #return;
  179. };
  180. ///=== {
  181. // ## chat.TuneOn <频道ID> [...]
  182. // 打开聊天频道。参数为一个或多个频道 ID。
  183. // 可用的频道 ID 有:
  184. // - 常用: chat rumor qq rw jh helpme
  185. // - 不常用: bd fb tt group nation qy jy mp
  186. // };
  187. #alias {chat.TuneOn} {
  188. #info arguments save;
  189. #unvar info[ARGUMENTS][0];
  190. #local chans {@sset.Create{$info[ARGUMENTS][]}};
  191. #local chan {};
  192. #if { "$chat-open-channels" == "UNKNOWN" } {
  193. #foreach {$chans} {chan} {
  194. #var chat-todo-channels[$chan] {on};
  195. };
  196. };
  197. #else {
  198. #local todo {@sset.Diff{{$chans};{$chat-open-channels}}};
  199. #foreach {$todo} {chan} {
  200. tune channel $chan;
  201. };
  202. };
  203. #return;
  204. };
  205. ///=== {
  206. // ## chat.OpenAll
  207. // 打开所有聊天频道。
  208. // };
  209. #alias {chat.OpenAll} {
  210. tune channel;
  211. chat.TuneOn bd chat fb group helpme jh jy mp nation qq qy rumor rw tt;
  212. };
  213. ///=== {
  214. // ## chat.CloseAll
  215. // 关闭所有聊天频道。
  216. // };
  217. #alias {chat.CloseAll} {
  218. tune channel;
  219. chat.TuneOff bd chat fb group helpme jh jy mp nation qq qy rumor rw tt;
  220. };
  221. #nop 你现在打开的频道:bd, fb, group, helpme, jh, jy, mp, nation, qq, qy, rumor, rw, tt。;
  222. #action {^你现在打开的频道:%*。{|ID=paotin/chat}$} {
  223. #local channels {%1};
  224. #replace channels {, } {;};
  225. #var chat-open-channels {@sset.Create{$channels}};
  226. chat.tune;
  227. };
  228. #action {^你现在并没有打开任何频道。{|ID=paotin/chat}$} {
  229. #var chat-open-channels {};
  230. chat.tune;
  231. };
  232. #alias {chat.tune} {
  233. #local chan {};
  234. #foreach {*chat-todo-channels[]} {chan} {
  235. #local todo {$chat-todo-channels[$chan]};
  236. #local set {$chat-open-channels};
  237. #if { "$todo" == "on" && !@sset.Contains{{$set};$chan} } {
  238. tune channel $chan;
  239. };
  240. #elseif { "$todo" == "off" && @sset.Contains{{$set};$chan} } {
  241. tune channel $chan;
  242. };
  243. #unvar chat-todo-channels[$chan];
  244. };
  245. };
  246. event.HandleOnce {user-online} {chat/init} {ui/chat} {
  247. tune channel;
  248. set learn_emote 1;
  249. };