BT.Next.tcl 14 KB

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