chat.tin 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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}{chatLog} {gag}{true}}
  21. {{pattern}{%!{江湖|任务|交易}} {action}{jhLog} {gag}{true}}
  22. {{pattern}{%!{本地|区域|亡灵}} {action}{bdLog} {gag}{true}}
  23. {{pattern}{私聊} {action}{tellLog} {gag}{false}}
  24. };
  25. VAR {五绝名号} chat-wujue-title {};
  26. VAR {帮派名称} chat-group-name {};
  27. load-lib storage;
  28. load-lib alert;
  29. #func {lib_ui_chat.Init} {
  30. #var chat-wujue-title {@storage.GetGlobal{五绝名号}};
  31. load-file {etc/ui-chat.tin};
  32. #return true;
  33. };
  34. #nop 普通聊天信息;
  35. #action {~^%c【%+2..5u%c】%c%*%+1..10u%c({[a-z A-Z]+})%c: %*$E} {
  36. chat.log {%2} {%0};
  37. } {4.994};
  38. #nop 单行的 emote 表情;
  39. #action {~{*UTF8}{?:^}%c【%c{\p{Han}{2,5}}%c】%*(%+1..S{| \S+}%s||%s{\S+ |}%+1..S)%s%c{|◆\p{Han}+◆}%c$E} {
  40. chat.log {%3} {%0};
  41. } {4.994};
  42. #nop 多行的 emote 表情;
  43. #action {~^%c【%+2..5u】%*$E} {
  44. chat.log-multi-line {%2} {%0};
  45. } {4.995};
  46. #alias {chat.log} {
  47. #local type {%1};
  48. #local text {%2};
  49. #if { "$type/$text" == "江湖/%*据闻如今的五绝是%*" } {
  50. #local wujue {@str.Plain{%2}};
  51. #replace wujue {%*【江湖】据闻如今的五绝是: %*} {&2};
  52. #replace wujue {、} {;};
  53. #var chat-wujue-title {};
  54. #local title {};
  55. #foreach {$wujue} {title} {
  56. #replace {title} {{*UTF8}{东.|西.|南.|北.|中..|}%*} {&1};
  57. #if { "$title" != "" } {
  58. #var chat-wujue-title {@sset.Add{{$chat-wujue-title};$title}};
  59. };
  60. };
  61. storage.SetGlobal 五绝名号 {$chat-wujue-title};
  62. };
  63. #if { "$type" != "{求助|北侠QQ群|闲聊|副本|谣言|门派|帮派|队伍|江湖|任务|交易|本地|区域|亡灵|表决|醒目|答问如流|备选答案|私聊}" } {
  64. #if { @sset.Contains{{$chat-wujue-title};$type} } {
  65. #local type 闲聊;
  66. };
  67. #elseif { @sset.Contains{{$chat-group-name};$type} } {
  68. #local type 帮派;
  69. };
  70. #elseif { "$char-menpai-id[$type]" != "" } {
  71. #local type 门派;
  72. };
  73. };
  74. #local id {};
  75. #loop {1} {&chat-channel[]} {id} {
  76. #local pattern {$chat-channel[$id][pattern]};
  77. #local action {$chat-channel[$id][action]};
  78. #local gag {$chat-channel[$id][gag]};
  79. #if { "$type" == "$pattern" } {
  80. $action $text;
  81. #if { "$gag" == "true" } {
  82. #line gag;
  83. };
  84. #return;
  85. };
  86. };
  87. };
  88. #alias {chat.log-multi-line} {
  89. #local type {%1};
  90. #local text {%2};
  91. chat.log {$type} {$text};
  92. #if { "$type" == "本地" } {
  93. #if { {$text} == {%*天空中突然闪出一道绚丽的火花%*} } {
  94. #class chat.log open;
  95. #action {~^%*{|ID=chat.log}$} {
  96. chat.log {%1} {%%0};
  97. } {4.993};
  98. #action {~^%c{\e\[2;37;0m|}\e[36m{|\e\[2;37;0m }{|\e\[0m}{|ID=chat.log}$} {
  99. chat.log {%1} {%%0};
  100. #class chat.log kill;
  101. } {4.992};
  102. #delay chat.log {#class chat.log kill} 0;
  103. #class chat.log close;
  104. };
  105. };
  106. #if { {$text} == {%*上次争胜后各门派完成主流任务统计:%*} } {
  107. #class chat.log open;
  108. #action {~^%*{|ID=chat.log}$} {
  109. chat.log {%1} {%%0};
  110. } {4.993};
  111. #action {~^%*次。%*$} {
  112. chat.log {%1} {%%0};
  113. #class chat.log kill;
  114. } {4.992};
  115. #delay chat.log {#class chat.log kill} 0;
  116. #class chat.log close;
  117. #return;
  118. };
  119. #if { "$type" == "江湖" } {
  120. #if { {$text} == {%*以下是江湖中{的|}%*排行榜%*} } {
  121. #class chat.log open;
  122. #action {~^%*{|ID=chat.log}$} {
  123. chat.log {%1} {%%0};
  124. } {4.993};
  125. #action {~^%c{[' -]+}%c{|ID=chat.log}$} {
  126. chat.log {%1} {%%0};
  127. #class chat.log kill;
  128. } {4.992};
  129. #delay chat.log {#class chat.log kill} 0;
  130. #class chat.log close;
  131. };
  132. #elseif { {$text} == {%*以下是最近一小时之内死于非命的江湖儿女。%*} } {
  133. #line multishot 4 #action {~^%*{|ID=chat.log}$} {
  134. chat.log {%1} {%%0};
  135. } {4.993};
  136. };
  137. #elseif { {$text} == {%*{[^m )]}\e[0m} } {
  138. #local lines {1};
  139. #if { {$text} == {%*请大家挖泥之余去各大BBS和论坛宣传北大侠客行,宣传内容详见%*} } {
  140. #local lines {2};
  141. };
  142. #line multishot $lines #action {~^%*{|ID=chat.log}$} {
  143. chat.log {%1} {%%0};
  144. } {4.993};
  145. };
  146. #return;
  147. };
  148. #if { "$type" != "{闲聊|求助|谣言}" } {
  149. #return;
  150. };
  151. #if { "$type" == "{闲聊|谣言}" && {$text} == {%* {\e\[0m}} } {
  152. #return;
  153. };
  154. #if { {$text} == {%c【求助】{我是大高手|大高手告诉|大高手说}%*} } {
  155. #return;
  156. };
  157. #if { {$text} == {%c【谣言】某人: 我看到了!!就是%*造的谣!!%c} } {
  158. #return;
  159. };
  160. #class chat.log open;
  161. #action {~^%*{|ID=chat.log}$} {
  162. chat.log {%1} {%%0};
  163. } {4.993};
  164. #action {~^%*(%w%s||%s{\S+ |}%+1..S)%c{|ID=chat.log}$} {
  165. chat.log {%1} {%%0};
  166. #class chat.log kill;
  167. } {4.992};
  168. #if { "$type" == "{闲聊|谣言}" } {
  169. #action {~^%*{\S \e\[0m}{|ID=chat.log}$} {
  170. chat.log {%1} {%%0};
  171. #class chat.log kill;
  172. } {4.992};
  173. };
  174. #delay chat.log {#class chat.log kill} 0;
  175. #class chat.log close;
  176. };
  177. #action {~^%c%u%c(%w)告诉你:%*$} {alert.Add 有私聊; chat.log 私聊 {%0}} {9.999};
  178. #action {~^%c%u%c回答你:%*$} {alert.Add 有私聊; chat.log 私聊 {%0}} {9.999};
  179. #action {~^%c你告诉%c%u%c:%*$} {chat.log 私聊 {%0}} {9.997};
  180. #action {~^%c你回答%c%u%c:%*$} {chat.log 私聊 {%0}} {9.997};
  181. #var chat-open-channels {UNKNOWN};
  182. #var chat-todo-channels {};
  183. ///=== {
  184. // ## chat.TuneOff <频道ID> [...]
  185. // 关闭聊天频道。参数为一个或多个频道 ID。
  186. // 可用的频道 ID 有:
  187. // - 常用: chat rumor qq rw jh helpme
  188. // - 不常用: bd fb tt group nation qy jy mp
  189. // };
  190. #alias {chat.TuneOff} {
  191. #info arguments save;
  192. #unvar info[ARGUMENTS][0];
  193. #local chans {@sset.Create{$info[ARGUMENTS][]}};
  194. #local chan {};
  195. #if { "$chat-open-channels" == "UNKNOWN" } {
  196. #foreach {$chans} {chan} {
  197. #var chat-todo-channels[$chan] {off};
  198. };
  199. };
  200. #else {
  201. #local todo {@sset.Intersection{{$chans};{$chat-open-channels}}};
  202. #foreach {$todo} {chan} {
  203. tune channel $chan;
  204. };
  205. };
  206. #return;
  207. };
  208. ///=== {
  209. // ## chat.TuneOn <频道ID> [...]
  210. // 打开聊天频道。参数为一个或多个频道 ID。
  211. // 可用的频道 ID 有:
  212. // - 常用: chat rumor qq rw jh helpme
  213. // - 不常用: bd fb tt group nation qy jy mp
  214. // };
  215. #alias {chat.TuneOn} {
  216. #info arguments save;
  217. #unvar info[ARGUMENTS][0];
  218. #local chans {@sset.Create{$info[ARGUMENTS][]}};
  219. #local chan {};
  220. #if { "$chat-open-channels" == "UNKNOWN" } {
  221. #foreach {$chans} {chan} {
  222. #var chat-todo-channels[$chan] {on};
  223. };
  224. };
  225. #else {
  226. #local todo {@sset.Diff{{$chans};{$chat-open-channels}}};
  227. #foreach {$todo} {chan} {
  228. tune channel $chan;
  229. };
  230. };
  231. #return;
  232. };
  233. ///=== {
  234. // ## chat.OpenAll
  235. // 打开所有聊天频道。
  236. // };
  237. #alias {chat.OpenAll} {
  238. tune channel;
  239. chat.TuneOn bd chat fb group helpme jh jy mp nation qq qy rumor rw tt;
  240. };
  241. ///=== {
  242. // ## chat.CloseAll
  243. // 关闭所有聊天频道。
  244. // };
  245. #alias {chat.CloseAll} {
  246. tune channel;
  247. chat.TuneOff bd chat fb group helpme jh jy mp nation qq qy rumor rw tt;
  248. };
  249. #nop 你现在打开的频道:bd, fb, group, helpme, jh, jy, mp, nation, qq, qy, rumor, rw, tt。;
  250. #action {^你现在打开的频道:%*。{|ID=paotin/chat}$} {
  251. #local channels {%1};
  252. #replace channels {, } {;};
  253. #var chat-open-channels {@sset.Create{$channels}};
  254. chat.tune;
  255. };
  256. #action {^你现在并没有打开任何频道。{|ID=paotin/chat}$} {
  257. #var chat-open-channels {};
  258. chat.tune;
  259. };
  260. #alias {chat.tune} {
  261. #local chan {};
  262. #foreach {*chat-todo-channels[]} {chan} {
  263. #local todo {$chat-todo-channels[$chan]};
  264. #local set {$chat-open-channels};
  265. #if { "$todo" == "on" && !@sset.Contains{{$set};$chan} } {
  266. tune channel $chan;
  267. };
  268. #elseif { "$todo" == "off" && @sset.Contains{{$set};$chan} } {
  269. tune channel $chan;
  270. };
  271. #unvar chat-todo-channels[$chan];
  272. };
  273. };
  274. event.HandleOnce {user-online} {chat/init} {ui/chat} {
  275. tune channel;
  276. set learn_emote 1;
  277. };