chat.tin 9.4 KB

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