BT.Next.tcl 15 KB

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