BT.Next.tcl 13 KB

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