BT.Next.tcl 14 KB

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