BT.Next.tcl 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. #########################################################################
  2. ## BlackTools - The Ultimate Channel Control Script ##
  3. ## One TCL. One smart Eggdrop ##
  4. #########################################################################
  5. ############################# NEXT TCL ##############################
  6. #########################################################################
  7. ## ##
  8. ## BlackTools : http://blacktools.tclscripts.net ##
  9. ## Bugs report : http://www.tclscripts.net/ ##
  10. ## GitHub page : https://github.com/tclscripts/BlackToolS-TCL ##
  11. ## Online Help : irc://irc.undernet.org/tcl-help ##
  12. ## #TCL-HELP / UnderNet ##
  13. ## You can ask in english or romanian ##
  14. ## ##
  15. #########################################################################
  16. proc black:next:join {nick host hand chan} {
  17. global black
  18. set counter 0
  19. set time [unixtime]
  20. set handle [nick2hand $nick]
  21. set lang [setting:get $chan lang]
  22. if {$lang == ""} { set lang [string tolower $black(default_lang)] }
  23. if {[setting:get $chan next]} {
  24. if {[matchattr $hand $black(exceptflags) $chan]} {
  25. pushmode $chan +v $nick
  26. return
  27. }
  28. if {[string equal -nocase $nick $black(chanserv)]} {
  29. return
  30. }
  31. if {[isbotnick $nick]} {
  32. black:next:joincheck $chan
  33. return
  34. }
  35. if {[info exists black(next:$chan:list)]} {
  36. if {[lsearch -exact [string tolower [split $black(next:$chan:list)]] [string tolower $nick]] == -1} {
  37. set black(next:$chan:list) "$black(next:$chan:list) $nick"
  38. set black(next:$chan:$nick:time) $time
  39. } else {
  40. set black(next:$chan:$nick:time) $time
  41. }
  42. } else {
  43. set black(next:$chan:list) $nick
  44. set black(next:$chan:$nick:time) $time
  45. }
  46. set counter [llength [split $black(next:$chan:list)]]
  47. set replace(%counter%) $counter
  48. set replace(%nick%) $nick
  49. set replace(%chan%) $chan
  50. set text1 [black:color:set "" $black(say.$lang.next.6)]
  51. set reply1 [join $text1]
  52. set text2 [black:color:set "" $black(say.$lang.next.1)]
  53. set reply2 [join $text2]
  54. set message [string map [array get replace] $reply1]
  55. puthelp "NOTICE @$chan :$message"
  56. set message [string map [array get replace] $reply2]
  57. puthelp "NOTICE $nick :$message"
  58. }
  59. }
  60. proc black:next:clear:all {nick chan mode} {
  61. global black
  62. if {[info exists black(next:$chan:list)]} {
  63. if {[lsearch -exact [string tolower [split $black(next:$chan:list)]] [string tolower $nick]] > -1} {
  64. set position [lsearch -exact [string tolower [split $black(next:$chan:list)]] [string tolower $nick]]
  65. set black(next:$chan:list) [join [lreplace [split $black(next:$chan:list)] $position $position]]
  66. }
  67. }
  68. if {$mode == "0"} {
  69. if {[info exists black(next:$chan:served)]} {
  70. if {[lsearch -exact [string tolower [split $black(next:$chan:served)]] [string tolower $nick]] > -1} {
  71. set position [lsearch -exact [string tolower [split $black(next:$chan:served)]] [string tolower $nick]]
  72. set black(next:$chan:served) [join [lreplace [split $black(next:$chan:served)] $position $position]]
  73. }
  74. }
  75. }
  76. if {[info exists black(next:$chan:$nick:time)]} {
  77. unset black(next:$chan:$nick:time)
  78. }
  79. if {[info exists black(next:$chan:served)]} {
  80. if {$black(next:$chan:served) == ""} {
  81. unset black(next:$chan:served)
  82. }
  83. }
  84. if {[info exists black(next:$chan:list)]} {
  85. if {$black(next:$chan:list) == ""} {
  86. unset black(next:$chan:list)
  87. }
  88. }
  89. }
  90. proc black:next:clear {nick chan} {
  91. global black
  92. if {[info exists black(next:$chan:list)]} {
  93. if {[lsearch -exact [string tolower [split $black(next:$chan:list)]] [string tolower $nick]] > -1} {
  94. set position [lsearch -exact [string tolower [split $black(next:$chan:list)]] [string tolower $nick]]
  95. set black(next:$chan:list) [join [lreplace [split $black(next:$chan:list)] $position $position]]
  96. }
  97. }
  98. if {[info exists black(next:$chan:$nick:time)]} {
  99. unset black(next:$chan:$nick:time)
  100. }
  101. }
  102. proc black:next:joincheck {chan} {
  103. global black
  104. if {[info exists black(next:$chan:list)]} {
  105. foreach user $black(next:$chan:list) {
  106. if {(![onchan $user $chan]) || [isop $user $chan]} {
  107. black:next:clear:all $user $chan 0
  108. }
  109. }
  110. }
  111. }
  112. proc black:next:part {nick host hand chan arg} {
  113. global black
  114. if {![validchan $chan]} { return }
  115. if {[setting:get $chan next]} {
  116. if {![info exists black(next:$chan:list)] && ![info exists black(next:$chan:served)]} {
  117. return
  118. }
  119. black:next:clear:all $nick $chan 0
  120. }
  121. }
  122. proc black:next:sign {nick host hand chan arg} {
  123. global black
  124. if {[setting:get $chan next]} {
  125. if {![info exists black(next:$chan:list)] && ![info exists black(next:$chan:served)]} {
  126. return
  127. }
  128. black:next:clear:all $nick $chan 0
  129. }
  130. }
  131. proc black:next:split {nick host hand chan args} {
  132. global black
  133. if {[setting:get $chan next]} {
  134. if {![info exists black(next:$chan:list)] && ![info exists black(next:$chan:served)]} {
  135. return
  136. }
  137. black:next:clear:all $nick $chan 0
  138. }
  139. }
  140. proc black:next:kick {nick host hand chan kicked arg} {
  141. global black
  142. if {[setting:get $chan next]} {
  143. if {![info exists black(next:$chan:list)] && ![info exists black(next:$chan:served)]} {
  144. return
  145. }
  146. black:next:clear:all $kicked $chan 0
  147. }
  148. }
  149. proc black:next:mode {nick host hand chan moded mod_nick} {
  150. global black
  151. if {[setting:get $chan next]} {
  152. if {($moded == "+v") || ($moded == "+o")} {
  153. if {![info exists black(next:$chan:list)] && ![info exists black(next:$chan:served)]} {
  154. return
  155. }
  156. black:next:clear:all $mod_nick $chan 1
  157. }
  158. }
  159. }
  160. proc black:next:chnick {nick host hand chan newnick} {
  161. global black
  162. if {![validchan $chan]} {
  163. return
  164. }
  165. if {[setting:get $chan next]} {
  166. if {[info exists black(next:$chan:served)]} {
  167. if {[lsearch -exact [string tolower [split $black(next:$chan:served)]] [string tolower $nick]] > -1} {
  168. set position [lsearch -exact [string tolower [split $black(next:$chan:served)]] [string tolower $nick]]
  169. set black(next:$chan:served) [join [lreplace [split $black(next:$chan:served)] $position $position]]
  170. set black(next:$chan:served) [linsert $black(next:$chan:served) $position $newnick]
  171. }
  172. }
  173. if {[info exists black(next:$chan:list)]} {
  174. if {[lsearch -exact [string tolower [split $black(next:$chan:list)]] [string tolower $nick]] > -1} {
  175. set position [lsearch -exact [string tolower [split $black(next:$chan:list)]] [string tolower $nick]]
  176. set black(next:$chan:list) [join [lreplace [split $black(next:$chan:list)] $position $position]]
  177. set black(next:$chan:list) [linsert $black(next:$chan:list) $position $newnick]
  178. set black(next:$chan:$newnick:time) $black(next:$chan:$nick:time)
  179. }
  180. }
  181. }
  182. }
  183. proc nextpublic:process {nick host hand chan chan1 option} {
  184. global black
  185. if {![setting:get $chan next]} {
  186. return
  187. }
  188. set cmd_status [btcmd:status $chan $hand "next" 0]
  189. if {$cmd_status == "1"} {
  190. return
  191. }
  192. if {$option != ""} {
  193. switch -exact -- [string tolower $option] {
  194. list {
  195. set counter 0
  196. if {![info exists black(next:$chan:list)]} {
  197. blacktools:tell $nick $host $hand $chan $chan1 next.8 none
  198. return
  199. }
  200. if {$black(next:$chan:list) == ""} {
  201. blacktools:tell $nick $host $hand $chan $chan1 next.8 none
  202. return
  203. }
  204. blacktools:tell $nick $host $hand $chan $chan1 next.7 none
  205. foreach name [split $black(next:$chan:list)] {
  206. if {$name != ""} {
  207. set get_hand [nick2hand $name]
  208. if {![matchattr $get_hand $black(exceptflags) $chan]} {
  209. set counter [expr $counter + 1]
  210. lappend field_name "\#$counter $name "
  211. }
  212. }
  213. }
  214. if {![info exists field_name]} {
  215. blacktools:tell $nick $host $hand $chan $chan1 next.8 none
  216. return
  217. }
  218. blacktools:tell $nick $host $hand $chan $chan1 next.9 [join $field_name]
  219. }
  220. }
  221. return
  222. }
  223. if {![info exists black(next:$chan:list)]} {
  224. blacktools:tell $nick $host $hand $chan $chan1 next.8 none
  225. return
  226. }
  227. if {[llength [split $black(next:$chan:list)]] < 0} {
  228. blacktools:tell $nick $host $hand $chan $chan1 next.8 none
  229. return
  230. }
  231. set getlang [string tolower [setting:get $chan lang]]
  232. if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
  233. set current_nick [lindex [split [concat $black(next:$chan:list)]] 0]
  234. set time [return_time $getlang [expr [unixtime] - $black(next:$chan:$current_nick:time)]]
  235. set text1 [black:color:set "" $black(say.$getlang.next.2)]
  236. set reply1 [join $text1]
  237. set replace(%nick%) $nick
  238. set message_1 [string map [array get replace] $reply1]
  239. puthelp "NOTICE $current_nick :$message_1"
  240. blacktools:tell $nick $host $hand $chan $chan1 next.3 "$current_nick $time"
  241. black:next:clear $current_nick $chan
  242. if {[setting:get $chan xonly] && [onchan $black(chanserv) $chan]} {
  243. putserv "PRIVMSG $black(chanserv) :voice $chan $current_nick"
  244. } else {
  245. putserv "MODE $chan +v $current_nick"
  246. }
  247. if {[info exists black(next:$chan:served)]} {
  248. if {[lsearch -exact [string tolower [split $black(next:$chan:served)]] [string tolower $current_nick]] == -1} {
  249. set black(next:$chan:served) "$black(next:$chan:served) $current_nick"
  250. }
  251. } else {
  252. set black(next:$chan:served) $current_nick
  253. }
  254. }
  255. proc helpedpublic:process {nick host hand chan chan1 user type} {
  256. global black
  257. set cmd_status [btcmd:status $chan $hand "helped" 0]
  258. if {$cmd_status == "1"} {
  259. return
  260. }
  261. set show_user [split $user]
  262. set handle [nick2hand $user]
  263. set entry_find 0
  264. if {![setting:get $chan next]} {
  265. return
  266. }
  267. if {[isbotnick $user]} { return }
  268. if {[matchattr $handle $black(exceptflags) $chan]} {
  269. return
  270. }
  271. if {$user == ""} {
  272. switch $type {
  273. 0 {
  274. blacktools:tell $nick $host $hand $chan $chan1 gl.instr "next"
  275. }
  276. 1 {
  277. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "next"
  278. }
  279. 2 {
  280. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "next"
  281. }
  282. }
  283. return
  284. }
  285. if {![onchan $user $chan]} {
  286. blacktools:tell $nick $host $hand $chan $chan1 gl.usernotonchan $show_user
  287. return
  288. }
  289. if {[info exists black(next:$chan:list)]} {
  290. if {([lsearch -exact [string tolower [split $black(next:$chan:list)]] [string tolower $user]] > -1)} {
  291. blacktools:tell $nick $host $hand $chan $chan1 next.13 $show_user
  292. return
  293. }
  294. }
  295. if {[info exists black(next:$chan:served)]} {
  296. if {[lsearch -exact [string tolower [split $black(next:$chan:served)]] [string tolower $user]] > -1} {
  297. set entry_find 1
  298. set position [lsearch -exact [string tolower [split $black(next:$chan:served)]] [string tolower $user]]
  299. set black(next:$chan:served) [join [lreplace [split $black(next:$chan:served)] $position $position]]
  300. }
  301. } else {
  302. blacktools:tell $nick $host $hand $chan $chan1 next.14 $show_user
  303. return
  304. }
  305. if {$entry_find == "0"} {
  306. blacktools:tell $nick $host $hand $chan $chan1 next.14 $show_user
  307. return
  308. }
  309. if {[isvoice $user $chan]} {
  310. if {[setting:get $chan xonly] && [onchan $black(chanserv) $chan]} {
  311. putserv "PRIVMSG $black(chanserv) :devoice $chan $user"
  312. } else {
  313. putserv "MODE $chan -v $user"
  314. }
  315. }
  316. set getlang [string tolower [setting:get $chan lang]]
  317. if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
  318. set text1 [black:color:set "" $black(say.$getlang.next.4)]
  319. set reply1 [join $text1]
  320. set replace(%current%) $user
  321. set replace(%chan%) $chan
  322. set message_1 [string map [array get replace] $reply1]
  323. puthelp "NOTICE $user :$message_1"
  324. }
  325. proc noidlepublic:process {nick host hand chan chan1 user type} {
  326. global black
  327. if {![setting:get $chan next]} {
  328. return
  329. }
  330. set cmd_status [btcmd:status $chan $hand "noidle" 0]
  331. if {$cmd_status == "1"} {
  332. return
  333. }
  334. set show_user $user
  335. set handle [nick2hand $user]
  336. if {![setting:get $chan next]} {
  337. return
  338. }
  339. if {[isbotnick $user]} { return }
  340. if {[matchattr $handle $black(exceptflags) $chan]} {
  341. return
  342. }
  343. if {$user == ""} {
  344. switch $type {
  345. 0 {
  346. blacktools:tell $nick $host $hand $chan $chan1 gl.instr "next"
  347. }
  348. 1 {
  349. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "next"
  350. }
  351. 2 {
  352. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "next"
  353. }
  354. }
  355. return
  356. }
  357. if {![onchan $user $chan]} {
  358. blacktools:tell:h $nick $host $hand $chan $chan1 gl.usernotonchan $user
  359. return
  360. }
  361. if {[info exists black(next:$chan:list)]} {
  362. if {([lsearch -exact [string tolower [split $black(next:$chan:list)]] [string tolower $user]] > -1)} {
  363. blacktools:tell:h $nick $host $hand $chan $chan1 next.13 $user
  364. return
  365. }
  366. }
  367. if {[info exists black(next:$chan:served)]} {
  368. if {([lsearch -exact [string tolower [split $black(next:$chan:served)]] [string tolower $user]] > -1)} {
  369. blacktools:tell:h $nick $host $hand $chan $chan1 next.17 $user
  370. return
  371. }
  372. }
  373. blacktools:banner:2 $user "NEXT" $chan $chan1 [getchanhost $user $chan] "0" ""
  374. who:chan $chan
  375. }
  376. proc skippublic:process {nick host hand chan chan1 user type} {
  377. global black
  378. if {![setting:get $chan next]} {
  379. return
  380. }
  381. set cmd_status [btcmd:status $chan $hand "skip" 0]
  382. if {$cmd_status == "1"} {
  383. return
  384. }
  385. if {$user == ""} {
  386. switch $type {
  387. 0 {
  388. blacktools:tell $nick $host $hand $chan $chan1 gl.instr "next"
  389. }
  390. 1 {
  391. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "next"
  392. }
  393. 2 {
  394. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "next"
  395. }
  396. }
  397. return
  398. }
  399. if {![onchan $user $chan]} {
  400. blacktools:tell:h $nick $host $hand $chan $chan1 gl.usernotonchan $user
  401. return
  402. }
  403. if {[info exists black(next:$chan:list)]} {
  404. if {[lsearch -exact [string tolower [split $black(next:$chan:list)]] [string tolower $user]] > -1} {
  405. set position [lsearch -exact [string tolower [split $black(next:$chan:list)]] [string tolower $user]]
  406. set black(next:$chan:list) [join [lreplace [split $black(next:$chan:list)] $position $position]]
  407. set black(next:$chan:list) "$black(next:$chan:list) $user"
  408. } else {
  409. blacktools:tell:h $nick $host $hand $chan $chan1 next.14 $user
  410. return
  411. }
  412. } else {
  413. blacktools:tell $nick $host $hand $chan $chan1 next.8 none
  414. return
  415. }
  416. blacktools:tell:h $nick $host $hand $chan $chan1 next.19 $user
  417. }
  418. ##############
  419. #########################################################################
  420. ## END ##
  421. #########################################################################