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