chat.tin 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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 { "$type" == "江湖" } {
  79. #if { {$text} == {%*神力和纵跃排行榜%*} } {
  80. #class chat.log open;
  81. #action {~^%*{|ID=chat.log}$} {
  82. chat.log {%1} {%%0};
  83. } {4.993};
  84. #action {~^%c{[' -]+}%c{|ID=chat.log}$} {
  85. chat.log {%1} {%%0};
  86. #class chat.log kill;
  87. } {4.992};
  88. #delay chat.log {#class chat.log kill} 0;
  89. #class chat.log close;
  90. };
  91. #elseif { {$text} == {%*{[^m )]}\e[0m} } {
  92. #local lines {1};
  93. #if { {$text} == {%*请大家挖泥之余去各大BBS和论坛宣传北大侠客行,宣传内容详见%*} } {
  94. #local lines {2};
  95. };
  96. #line multishot $lines #action {~^%*{|ID=chat.log}$} {
  97. chat.log {%1} {%%0};
  98. } {4.993};
  99. };
  100. #return;
  101. };
  102. #if { "$type" != "{闲聊|求助|谣言}" } {
  103. #return;
  104. };
  105. #if { "$type" == "{闲聊|谣言}" && {$text} == {%* {\e\[0m}} } {
  106. #return;
  107. };
  108. #if { {$text} == {%c【求助】{我是大高手|大高手告诉|大高手说}%*} } {
  109. #return;
  110. };
  111. #if { {$text} == {%c【谣言】某人: 我看到了!!就是%*造的谣!!%c} } {
  112. #return;
  113. };
  114. #class chat.log open;
  115. #action {~^%*{|ID=chat.log}$} {
  116. chat.log {%1} {%%0};
  117. } {4.993};
  118. #action {~^%*(%w%s||%s{\S+ |}%+1..S)%c{|ID=chat.log}$} {
  119. chat.log {%1} {%%0};
  120. #class chat.log kill;
  121. } {4.992};
  122. #if { "$type" == "{闲聊|谣言}" } {
  123. #action {~^%*{\S \e\[0m}{|ID=chat.log}$} {
  124. chat.log {%1} {%%0};
  125. #class chat.log kill;
  126. } {4.992};
  127. };
  128. #delay chat.log {#class chat.log kill} 0;
  129. #class chat.log close;
  130. };
  131. #action {~^%c%u%c(%w)告诉你:%*$} {alert.Add 有私聊; chat.log 私聊 {%0}} {9.999};
  132. #action {~^%c%u%c回答你:%*$} {alert.Add 有私聊; chat.log 私聊 {%0}} {9.999};
  133. #action {~^%c你告诉%c%u%c:%*$} {chat.log 私聊 {%0}} {9.997};
  134. #action {~^%c你回答%c%u%c:%*$} {chat.log 私聊 {%0}} {9.997};
  135. #var chat-open-channels {UNKNOWN};
  136. #var chat-todo-channels {};
  137. ///=== {
  138. // ## chat.TuneOff <频道ID> [...]
  139. // 关闭聊天频道。参数为一个或多个频道 ID。
  140. // 可用的频道 ID 有:
  141. // - 常用: chat rumor qq rw jh helpme
  142. // - 不常用: bd fb tt group nation qy jy mp
  143. // };
  144. #alias {chat.TuneOff} {
  145. #info arguments save;
  146. #unvar info[ARGUMENTS][0];
  147. #local chans {@sset.Create{$info[ARGUMENTS][]}};
  148. #local chan {};
  149. #if { "$chat-open-channels" == "UNKNOWN" } {
  150. #foreach {$chans} {chan} {
  151. #var chat-todo-channels[$chan] {off};
  152. };
  153. };
  154. #else {
  155. #local todo {@sset.Intersection{{$chans};{$chat-open-channels}}};
  156. #foreach {$todo} {chan} {
  157. tune channel $chan;
  158. };
  159. };
  160. #return;
  161. };
  162. ///=== {
  163. // ## chat.TuneOn <频道ID> [...]
  164. // 打开聊天频道。参数为一个或多个频道 ID。
  165. // 可用的频道 ID 有:
  166. // - 常用: chat rumor qq rw jh helpme
  167. // - 不常用: bd fb tt group nation qy jy mp
  168. // };
  169. #alias {chat.TuneOn} {
  170. #info arguments save;
  171. #unvar info[ARGUMENTS][0];
  172. #local chans {@sset.Create{$info[ARGUMENTS][]}};
  173. #local chan {};
  174. #if { "$chat-open-channels" == "UNKNOWN" } {
  175. #foreach {$chans} {chan} {
  176. #var chat-todo-channels[$chan] {on};
  177. };
  178. };
  179. #else {
  180. #local todo {@sset.Diff{{$chans};{$chat-open-channels}}};
  181. #foreach {$todo} {chan} {
  182. tune channel $chan;
  183. };
  184. };
  185. #return;
  186. };
  187. ///=== {
  188. // ## chat.OpenAll
  189. // 打开所有聊天频道。
  190. // };
  191. #alias {chat.OpenAll} {
  192. tune channel;
  193. chat.TuneOn bd chat fb group helpme jh jy mp nation qq qy rumor rw tt;
  194. };
  195. ///=== {
  196. // ## chat.CloseAll
  197. // 关闭所有聊天频道。
  198. // };
  199. #alias {chat.CloseAll} {
  200. tune channel;
  201. chat.TuneOff bd chat fb group helpme jh jy mp nation qq qy rumor rw tt;
  202. };
  203. #nop 你现在打开的频道:bd, fb, group, helpme, jh, jy, mp, nation, qq, qy, rumor, rw, tt。;
  204. #action {^你现在打开的频道:%*。{|ID=paotin/chat}$} {
  205. #local channels {%1};
  206. #replace channels {, } {;};
  207. #var chat-open-channels {@sset.Create{$channels}};
  208. chat.tune;
  209. };
  210. #action {^你现在并没有打开任何频道。{|ID=paotin/chat}$} {
  211. #var chat-open-channels {};
  212. chat.tune;
  213. };
  214. #alias {chat.tune} {
  215. #local chan {};
  216. #foreach {*chat-todo-channels[]} {chan} {
  217. #local todo {$chat-todo-channels[$chan]};
  218. #local set {$chat-open-channels};
  219. #if { "$todo" == "on" && !@sset.Contains{{$set};$chan} } {
  220. tune channel $chan;
  221. };
  222. #elseif { "$todo" == "off" && @sset.Contains{{$set};$chan} } {
  223. tune channel $chan;
  224. };
  225. #unvar chat-todo-channels[$chan];
  226. };
  227. };
  228. event.HandleOnce {user-online} {chat/init} {ui/chat} {
  229. tune channel;
  230. set learn_emote 1;
  231. };