Posted to tcl by sauk at Tue Aug 24 22:06:58 GMT 2021view raw

  1. # --- protection v1.4 beta
  2.  
  3. # --- contact information
  4.  
  5. # Alexander Martin
  6. #
  7. # E-Mail: bugs@dev.alex.ip-am.de
  8. # Homepage: http://fat.egg.irc.ag:1337 {http://dev.alex.ip-am.de}
  9. #
  10. # #xela on iRC.ag {/server -m de.irc.ag 6667 -j #xela}
  11.  
  12. # __ _ _ _ __
  13. # __ _ _ __ ___ / /| || |___ _____| | __ \ \
  14. # / _` | '_ ` _ \ | |_ .. _\ \/ / _ \ |/ _` | |
  15. # | (_| | | | | | | < <|_ _|> < __/ | (_| |> >
  16. # \__,_|_| |_| |_| | | |_||_| /_/\_\___|_|\__,_| |
  17. # \_\ /_/
  18.  
  19. # --- copyright
  20. #
  21. # I made this script, not you, wish to touch the copyright? fuck off :)
  22. #
  23. # This software is copyrighted (c) 2005 by Alexander Martin 'am' #xela.
  24. # All rights reserved. The following terms apply to all files associated with
  25. # the software unless explicitly disclaimed in individual files or
  26. # directories.
  27. #
  28. # The authors hereby grant permission to use, copy, modify, distribute,
  29. # and license this software for any purpose, provided that existing
  30. # copyright notices are retained in all copies and that this notice is
  31. # included verbatim in any distributions. No written agreement, license,
  32. # or royalty fee is required for any of the authorized uses.
  33. # Modifications to this software may be copyrighted by their authors and
  34. # need not follow the licensing terms described here, provided that the
  35. # new terms are clearly indicated on the first page of each file where
  36. # they apply.
  37. #
  38. # IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
  39. # FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  40. # ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
  41. # DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
  42. # POSSIBILITY OF SUCH DAMAGE.
  43. #
  44. # THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
  45. # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  46. # FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
  47. # IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
  48. # NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
  49. # MODIFICATIONS.
  50. #
  51. # GOVERNMENT USE: If you are acquiring this software on behalf of the
  52. # U.S. government, the Government shall have only "Restricted Rights"
  53. # in the software and related documentation as defined in the Federal
  54. # Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
  55. # are acquiring the software on behalf of the Department of Defense, the
  56. # software shall be classified as "Commercial Computer Software" and the
  57. # Government shall have only "Restricted Rights" as defined in Clause
  58. # 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
  59. # authors grant the U.S. Government and others acting in its behalf
  60. # permission to use and distribute the software in accordance with the
  61. # terms specified in this license.
  62. #
  63.  
  64. # --- script information
  65.  
  66. # Punish methode 1 and 2 seems to be buggy, no way to fix it >:(
  67.  
  68. # --- changes
  69.  
  70. # 1.4b Bug fixed (Command: access (19.06.2005 12:15))
  71. # 1.3b Bug fixed (Command: access (16.06.2005 19:28))
  72.  
  73. # --- script settings
  74.  
  75. namespace eval ::protection::settings {
  76.  
  77. # -- variables
  78.  
  79. variable trigger "\?"
  80.  
  81. variable version "1.4b"
  82. variable author "Alexander Martin 'am' \{#xela\}"
  83.  
  84. variable levels
  85. variable required
  86. variable reactions
  87.  
  88. variable available "deopall recover clearchan invite reop unbanall"
  89.  
  90. if {[array exists reactions]} {
  91. array unset reactions
  92. }
  93.  
  94. array set reactions {
  95. "bot-kick" {deopall}
  96. "mass-mode" {deopall}
  97. "mass-kick" {deopall}
  98. "need-invite" {clearchan:invite}
  99. "need-key" {clearchan:invite}
  100. "need-unban" {unbanall:invite}
  101. "need-op" {deopall:reop}
  102. }
  103.  
  104. if {[array exists required]} {
  105. array unset required
  106. }
  107.  
  108. array set required {
  109. "mytrigger" {% 3 4 5 6 7 8 9 10}
  110. "levels" {% 3 4 5 6 7 8 9 10}
  111. "methode" {% 3 4 5 6 7 8 9 10}
  112. "protect" {& 5 6 9 10}
  113. "topicsave" {& 5 6 9 10}
  114. "status" {% 6 10}
  115. "reaction" {& 5 6 9 10}
  116. "adduser" {% 5 6 9 10}
  117. "access" {% 5 6 9 10}
  118. "deluser" {% 10}
  119. "whois" {% 5 6 9 10}
  120. "userlist" {% 5 6 9 10}
  121. "remflags" {& 5 6 9 10}
  122. "banlist" {% 5 6 9 10}
  123. "maxmodes" {& 5 6 9 10}
  124. "maxkicks" {& 5 6 9 10}
  125. "bitchmode" {& 5 6 9 10}
  126. "mode" {% 5 6 9 10}
  127. "punish" {& 5 6 9 10}
  128. "kickmsg" {% 5 6 9 10}
  129. "kick" {% 4 5 6 8 9 10}
  130. "ban" {% 5 6 9 10}
  131. "unban" {% 5 6 9 10}
  132. "autoop" {% 5 6 9 10}
  133. "autovoice" {% 5 6 9 10}
  134. "autolimit" {% 5 6 9 10}
  135. "op" {% 4 5 6 8 9 10}
  136. "voice" {% 3 4 5 6 7 8 9 10}
  137. "deop" {% 4 5 6 8 9 10}
  138. "devoice" {% 3 4 5 6 7 8 9 10}
  139. "topic" {% 5 6 9 10}
  140. "showcommands" {+ 3 4 5 6 7 8 9 10}
  141. "help" {+ 3 4 5 6 7 8 9 10}
  142. "commands" {+ 3 4 5 6 7 8 9 10}
  143. "modechange" {5 6 9 10}
  144. "version" {- 0}
  145. "copyright" {- 0}
  146. }
  147.  
  148. if {[array exists levels]} {
  149. array unset levels
  150. }
  151.  
  152. array set levels {
  153. "0" {-|-}
  154. "1" {-|B}
  155. "2" {-|d}
  156. "3" {-|v}
  157. "4" {-|o}
  158. "5" {-|m}
  159. "6" {-|n}
  160. "7" {v|-}
  161. "8" {o|-}
  162. "9" {m|-}
  163. "10" {n|-}
  164. }
  165.  
  166. # -- setudef {flag:string}
  167.  
  168. # - flag
  169.  
  170. setudef flag protection
  171. setudef flag onjoin-voice
  172. setudef flag onjoin-operator
  173. setudef flag bitchmode
  174. setudef flag topicsave
  175. setudef flag first-use
  176. setudef flag service-prot
  177.  
  178. # - string
  179.  
  180. setudef str kick-id
  181. setudef str kick-message
  182. setudef str protected-modes
  183. setudef str channel-topic
  184. setudef str punish-methode
  185. setudef str remove-flags
  186. setudef str maximal-modes
  187. setudef str maximal-kicks
  188. setudef str autolimit
  189.  
  190. foreach reaction [array names ::protection::settings::reactions] {
  191. setudef str reaction-$reaction
  192. }
  193.  
  194. # -- required module
  195.  
  196. if {[catch { loadmodule blowfish } error]} {
  197. putlog "You can't use this fuckin' nice script dude, blowfish module req. >:("
  198. return
  199. }
  200.  
  201. }
  202.  
  203. # --- bindings
  204.  
  205. # -- quakenet service {join:leave}
  206.  
  207. # - leave
  208.  
  209. bind SIGN -|- {*} ::protection::qnet:service:leave
  210. bind PART -|- {*} ::protection::qnet:service:leave
  211. bind SPLT -|- {*} ::protection::qnet:service:leave:netsplit
  212.  
  213. # - rejoin/join
  214.  
  215. bind JOIN -|- {*} ::protection::qnet:service:join
  216. bind REJN -|- {*} ::protection::qnet:service:join
  217.  
  218. # -- incr kick counter
  219.  
  220. bind KICK -|- {*} ::protection::incr:kickcount
  221.  
  222. # -- timers {autolimit}
  223.  
  224. bind TIME -|- {*} ::protection::auto:limit
  225.  
  226. # -- auto mode on join {operator:voice:ban}
  227.  
  228. bind JOIN -|- {*} ::protection::auto:mode
  229.  
  230. # -- public
  231.  
  232. bind PUBM -|- {*} ::protection::parse:public
  233.  
  234. # -- protection
  235.  
  236. # - topic change
  237.  
  238. bind TOPC -|- {*} ::protection::topic:change
  239.  
  240. # - mode change
  241.  
  242. bind MODE -|- {*} ::protection::mode:change
  243.  
  244. # - kick
  245.  
  246. bind KICK -|- {*} ::protection::user:kick
  247.  
  248. # -- need
  249.  
  250. bind NEED -|- {*} ::protection::need:settings
  251.  
  252. # --- script main source
  253.  
  254. namespace eval ::protection {
  255.  
  256. # --- quakenet service {leave:join}
  257.  
  258. # -- join
  259.  
  260. proc qnet:service:join { nickname hostname handle channel } {
  261. global reop autoop
  262. if {[isbotnick $nickname]} { return }
  263. if {[lsearch -exact [userlist |S $channel] $nickname] > -1 && [channel get $channel "protection"]} {
  264. putserv "PRIVMSG $channel :\001ACTION [lindex "hugs loves kisses misses" [rand 3]] $nickname \\\\\F4\001"
  265. foreach service [userlist |S $channel] {
  266. if {$service == ""} {
  267. continue
  268. }
  269. chattr $service |-S $channel
  270. }
  271. chattr $nickname |+S $channel
  272. if {[info exists reop($channel)] && [botisop $channel]} {
  273. foreach idler $reop($channel) {
  274. if {![onchan $idler $channel]} {
  275. continue
  276. }
  277. pushmode $channel +o $idler
  278. }
  279. flushmode $channel
  280. unset reop($channel)
  281. }
  282. if {[info exists autoop($channel)]} {
  283. unset autoop($channel)
  284. putserv "PRIVMSG $channel :Autoop on join enabled once again."
  285. channel set $channel +onjoin-operator -onjoin-voice
  286. }
  287. }
  288. }
  289.  
  290. # -- leave
  291.  
  292. proc qnet:service:leave:netsplit { nickname hostname handle channel } {
  293. if {[isbotnick $nickname]} { return }
  294. if {[lsearch -exact [userlist |S $channel] $nickname] > -1 && [channel get $channel "protection"]} {
  295. ::protection::qnet:service:leave $nickname $hostname $handle $channel ""
  296. }
  297. }
  298.  
  299. proc qnet:service:leave { nickname hostname handle channel reason } {
  300. global reop autoop
  301. if {[isbotnick $nickname]} { return }
  302. if {[lsearch -exact [userlist |S $channel] $nickname] > -1 && [channel get $channel "protection"]} {
  303. putserv "PRIVMSG $channel :\001ACTION hates $nickname for this :(\001"
  304. if {[channel get $channel "onjoin-operator"]} {
  305. putserv "PRIVMSG $channel :Autoop on join temporary disabled."
  306. channel set $channel -onjoin-operator +onjoin-voice
  307. set autoop($channel) 1
  308. }
  309. if {[channel get $channel "service-prot"] && [botisop $channel]} {
  310. foreach idler [chanlist $channel] {
  311. if {[isbotnick $idler]} {
  312. continue
  313. } elseif {[matchattr [nick2hand $idler] mno|mno $channel]} {
  314. continue
  315. } elseif {![isop $idler $channel]} {
  316. continue
  317. } else {
  318. lappend reop($channel) $idler; pushmode $channel -o $idler
  319. }
  320. }
  321. flushmode $channel
  322. }
  323. }
  324. }
  325.  
  326. # --- auto mode on join {operator:voice:ban}
  327.  
  328. # -- panel
  329.  
  330. proc auto:mode { nickname hostname handle channel } {
  331. global joins utimer
  332. if {![botisop $channel] || [isbotnick $nickname]} { return }
  333. if {[::protection::user:level $handle $channel] == "1"} {
  334. if {[string match "*users.quakenet.org" $hostname]} {
  335. set banmask *!*@[lindex [split $hostname "@"] 1]
  336. } else {
  337. set banmask [maskhost $hostname]
  338. }
  339. set reason "You have been BANNED from this channel."
  340. putserv "MODE $channel -ov+b $nickname $nickname $banmask"
  341. putserv "KICK $channel $nickname :[string map "\":nickname:\" \"$nickname\" \":reason:\" \"$reason\" \":counter:\" \"[expr [channel get $channel "kick-id"] + 1]\"" [join [channel get $channel "kick-message"]]]"
  342. return
  343. }
  344. if {[channel get $channel "onjoin-operator"] && [::protection::user:level $handle $channel] != "2"} {
  345. if {![onchansplit $nickname]} {
  346. if {![info exists joins($channel)]} {
  347. set joins($channel) 1; utimer 1 [list ::protection::unset:variable joins($channel)]
  348. } else {
  349. incr joins($channel) 1
  350. if {$joins($channel) == "5"} {
  351. foreach {id value} [array get utimer "*:$channel"] {
  352. catch { killutimer $utimer($id) }; unset utimer($id)
  353. }
  354. channel set $channel -onjoin-operator; timer [expr $joins($channel) * 5] [list channel set $channel +onjoin-operator]
  355. ::protection::unset:variable joins($channel); ::protection::unset:variable victims($channel)
  356. putquick "PRIVMSG $channel :\001ACTION turned the autoop temporary off ...\001" -next
  357. return
  358. }
  359. }
  360. }
  361. if {![info exists ::protection::settings::author] || [info exists ::protection::settings::author] && ![string equal 1pr/X1lH0dx0oJYDZ/pNsjV.xLysJ/N77mt.ew3xD.lSY/w/ [encrypt xela $::protection::settings::author]]} {
  362. die "Uh, Oh, Yeah, you really think you can use my script without my copyright ???? :D"
  363. }
  364. set utimer($nickname:$channel) [utimer 2 [list pushmode $channel +o $nickname]]
  365. } elseif {[channel get $channel "onjoin-voice"]} {
  366. pushmode $channel +v $nickname
  367. }
  368. }
  369.  
  370. # --- commands
  371.  
  372. # -- parse command {public}
  373.  
  374. # - parse public message
  375.  
  376. proc parse:public { nickname hostname handle channel arguments } {
  377. ::protection::parse $nickname $hostname $handle $arguments $channel
  378. }
  379.  
  380. # - redirect command to proc
  381.  
  382. proc parse { nickname hostname handle arguments channel } {
  383. global botnick botname
  384. global lastnick lastchan lastargs lastcmd lasttrig lasthost
  385. set utrigger [getuser $handle XTRA trigger]
  386. if {[llength $utrigger] < 1} {
  387. set utrigger [join [string trim $::protection::settings::trigger]]
  388. }
  389. if {[lsearch -exact "NOTICE PRIVMSG" [string toupper [getuser $handle XTRA methode]]] < 0} {
  390. setuser $handle XTRA methode NOTICE
  391. }
  392. if {[llength $channel] > 0} {
  393. if {[string equal -nocase $botnick [lindex [split $arguments] 0]]} {
  394. set command [string tolower [lindex [split $arguments] 1]]; set trigger "$botnick $command"
  395. if {[string index [lindex [split $arguments] 2] 0] == "#" && [validchan [lindex [split $arguments] 2]]} {
  396. set channel [lindex [split $arguments] 2]; set arguments [lrange [split $arguments] 3 end]
  397. } else {
  398. set arguments [lrange [split $arguments] 2 end]
  399. }
  400. } elseif {[string equal -nocase [string index [lindex [split $arguments] 0] 0] $utrigger]} {
  401. set trigger [lindex [split $arguments] 0]; set command [string tolower [string range [lindex [split $arguments] 0] 1 end]]
  402. if {[string index [lindex [split $arguments] 1] 0] == "#" && [validchan [lindex [split $arguments] 1]]} {
  403. set channel [lindex [split $arguments] 1]; set arguments [lrange [split $arguments] 2 end]
  404. } else {
  405. set arguments [lrange [split $arguments] 1 end]
  406. }
  407. }
  408. } else {
  409. return
  410. }
  411. if {![info exists command] || [llength $command] < 1} {
  412. return
  413. } elseif {![info exists trigger] || [llength $trigger] < 1} {
  414. return
  415. } elseif {![info exists channel] || ![validchan $channel]} {
  416. return
  417. } elseif {![validuser $handle]} {
  418. return
  419. }
  420. set lastnick $nickname
  421. set lastargs $arguments
  422. set lastchan $channel
  423. set lastcmd $command
  424. set lasttrig $trigger
  425. set lasthost $hostname
  426. set redirect $command
  427. if {[lsearch "op deop voice devoice" $command] > -1} {
  428. set redirect usermode
  429. } elseif {[lsearch "autoop autovoice" $command] > -1} {
  430. set redirect automode
  431. } elseif {[lsearch "copyright version" $command] > -1} {
  432. set redirect authorinfo
  433. } elseif {[lsearch "help commands" $command] > -1} {
  434. set redirect showcommands
  435. }
  436. if {![info exists ::protection::settings::required($command)]} {
  437. return
  438. } elseif {[lsearch -exact "$::protection::settings::required($command)" 0] < 0 && [lsearch -exact "$::protection::settings::required($command)" [::protection::user:level $handle $channel]] < 0} {
  439. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :You are not enough known on this channel \{$channel\} and can't use [string toupper $command]!"; return
  440. } elseif {[string index $::protection::settings::required($command) 0] == "&" && ![channel get $channel "protection"]} {
  441. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :In order to use [string toupper $command] you have to enable the protection script on this channel! \{$channel\}"; return
  442. } elseif {[lsearch -exact "mode kick usermode topic" $redirect] > -1 && ![botisop $channel]} {
  443. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :In order to use [string toupper $command] the bot requires OP on this channel! \{$channel\}"; return
  444. } elseif {![info exists ::protection::settings::author] || [info exists ::protection::settings::author] && ![string equal 1pr/X1lH0dx0oJYDZ/pNsjV.xLysJ/N77mt.ew3xD.lSY/w/ [encrypt xela $::protection::settings::author]]} {
  445. putserv "PRIVMSG $channel :\001ACTION *thinks* my owner tries to touch teh fuckin' copyright >:)\001"; return
  446. }
  447. ::protection::missing:settings $channel; ::protection::command:$redirect $command $nickname $hostname $handle $channel $arguments
  448. }
  449.  
  450. # -- command levels
  451.  
  452. proc command:levels { command nickname hostname handle channel arguments } {
  453. global botnick botname
  454. global lastnick lastchan lastargs lastcmd lasttrig lastuse
  455. foreach level "\{0 Without access\A0\A0\A0\A0\A0\A0\A0\A0\A0\A0\A0\A05 Channel master\} \{1 Channel auto ban list\A0\A0\A0\A0\A0\A0\A0\A0\A0\A0\A0\A06 Channel owner\} \{2 Channel auto deop list\A0\A0\A0\A0\A0\A0\A0\A0\A0\A0\A0\A07 Global auto voice list\} \{3 Channel auto voice list\A0\A0\A0\A0\A0\A0\A0\A0\A0\A0\A0\A08 Global auto operator list\} \{4 Channel auto operator list\A0\A0\A0\A0\A0\A0\A0\A0\A0\A0\A0\A09 Global master\} \{10 Global owner\}" {
  456. if {[string length [lindex [split $level] 0]] == 1} {
  457. set level "\A0$level"
  458. }
  459. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :$level"
  460. }
  461. }
  462.  
  463. # -- command methode
  464.  
  465. proc command:methode { command nickname hostname handle channel arguments } {
  466. global botnick botname
  467. global lastnick lastchan lastargs lastcmd lasttrig lastuse
  468. if {[lsearch -exact "NOTICE PRIVMSG" [string toupper [lindex [split $arguments] 0]]] < 0} {
  469. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :You will receive all bot messages via [string toupper [getuser [nick2hand $lastnick] XTRA methode]]"
  470. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037notice\037|\037privmsg\037"
  471. return
  472. }
  473. setuser $handle XTRA methode [string toupper [lindex [split $arguments] 0]]
  474. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Message methode successfully set to [string toupper [getuser [nick2hand $lastnick] XTRA methode]]"
  475. }
  476.  
  477. # -- command authorinfo
  478.  
  479. proc command:authorinfo { command nickname hostname handle channel arguments } {
  480. global botnick botname
  481. global lastnick lastchan lastargs lastcmd lasttrig lastuse
  482. if {[info exists lastuse($command:$channel)] && [expr [unixtime] - $lastuse($command:$channel)] < 90} {
  483. return
  484. }
  485. set lastuse($command:$channel) [unixtime]
  486. putquick "PRIVMSG $channel :\001ACTION protection script v$::protection::settings::version developed by $::protection::settings::author\001"
  487. putquick "PRIVMSG $channel :Due to the trouble last time on quakenet, I left to my own network /server -m de.irc.ag 6667 -j #xela :)"
  488. }
  489.  
  490. # -- command status
  491.  
  492. proc command:status { command nickname hostname handle channel arguments } {
  493. global botnick botname
  494. global lastnick lastchan lastargs lastcmd lasttrig
  495. switch -exact -- [string tolower [lindex [split $arguments] 0]] {
  496. "on" {
  497. if {[channel get $channel "protection"]} {
  498. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Protection already on."
  499. } else {
  500. if {![validuser Q]} {
  501. adduser Q *!TheQBot@CServe.quakenet.org
  502. chattr Q +afmo
  503. }
  504. if {![validuser L]} {
  505. adduser L *!TheLBot@lightweight.quakenet.org
  506. chattr L +afmo
  507. }
  508. if {[onchan Q $channel]} {
  509. set service Q
  510. } elseif {[onchan L $channel]} {
  511. set service L
  512. } else {
  513. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Quakenet service bot required."
  514. return
  515. }
  516. chattr $service |+S $channel
  517. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Protection turned on."
  518. channel set $channel +protection +autoop +service-prot +autovoice; ::protection::missing:settings $channel
  519. set utrigger [getuser $handle XTRA trigger]
  520. if {[llength $utrigger] < 1} {
  521. set utrigger [join [string trim $::protection::settings::trigger]]
  522. }
  523. if {![channel get $channel "first-use"]} {
  524. channel set $channel +first-use
  525. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Thanks for choosing my protection script, please report bugs to me."
  526. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :To get a complete list with available commands for you please type in: ${utrigger}help"
  527. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :---"
  528. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :v$::protection::settings::version developed by $::protection::settings::author"
  529. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :IRC: /server -m de.irc.ag 6667 -j #xela >:)"
  530. }
  531. }
  532. }
  533. "off" {
  534. if {![channel get $channel "protection"]} {
  535. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Protection already off."
  536. } else {
  537. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Protection turned off."
  538. if {[regexp {[0-9]{1,}} [channel get $channel "autolimit"]] && [string match *l* [lindex [getchanmode $channel] 0]]} {
  539. putquick "MODE $channel -l"; channel set $channel -autolimit
  540. }
  541. channel set $channel -protection
  542. }
  543. }
  544. "default" {
  545. if {[channel get $channel "protection"]} {
  546. set status "Protection is on."
  547. } else {
  548. set status "Protection is off."
  549. }
  550. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :$status Please use: $lasttrig \037?#channel?\037 \037on\037|\037off\037"
  551. }
  552. }
  553. }
  554.  
  555. # -- command punish
  556.  
  557. proc command:punish { command nickname hostname handle channel arguments } {
  558. global botnick botname
  559. global lastnick lastchan lastargs lastcmd lasttrig
  560. if {![regexp -- {[1-3]} [lindex [split $arguments] 0]]} {
  561. set methode [channel get $channel "punish-methode"]
  562. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Current channel punish methode \{$channel\} is: $methode"
  563. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Informatio\037n\037\002:\002 Avaialable methodes are: 1 \{deop\}, 2 \{kick\} and 3 \{kickban\}"
  564. return
  565. }
  566. channel set $channel punish-methode [lindex [split $arguments] 0]
  567. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Channel punish methode \{$channel\} successfully set to: [lindex [split $arguments] 0]"
  568. }
  569.  
  570. # -- command reaction
  571.  
  572. proc command:reaction { command nickname hostname handle channel arguments } {
  573. global botnick botname
  574. global lastnick lastchan lastargs lastcmd lasttrig
  575. set reaction [string tolower [lindex [split $arguments] 0]]
  576. set types [string tolower [join [lrange [split $arguments] 1 end]]]
  577. if {![info exists ::protection::settings::reactions($reaction)] || $reaction == "" || $types == ""} {
  578. if {[info exists ::protection::settings::reactions($reaction)] && [channel get $channel "reaction-$reaction"] != ""} {
  579. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Reactio\037n\037\002:\002 [string toupper $reaction] \{$channel\} -> [join [split [channel get $channel "reaction-$reaction"] ":"] ", "]"; return
  580. }
  581. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037[join [array names ::protection::settings::reactions] "\037|\037"]\037 \037?reactions?\037"
  582. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Informatio\037n\037\002:\002 Available reactions are: [join $::protection::settings::available ", "]"
  583. return
  584. }
  585. foreach option $types {
  586. if {[lsearch -exact $::protection::settings::available $option] < 0} {
  587. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Invalid reaction specified: [string toupper $option]"
  588. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Informatio\037n\037\002:\002 Available reactions are: [join $::protection::settings::available ", "]"
  589. return
  590. }
  591. }
  592. channel set $channel reaction-$reaction [join $types ":"]
  593. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Reaction for [string toupper $reaction] \{$channel\} successfully set to: [join $types ", "]"
  594. }
  595.  
  596. # -- command userlist
  597.  
  598. proc command:userlist { command nickname hostname handle channel arguments } {
  599. global botnick botname
  600. global lastnick lastchan lastargs lastcmd lasttrig
  601. if {[string equal -nocase -global [lindex [split $arguments] 0]]} {
  602. set global 1; set type Global
  603. } else {
  604. set global 0; set type $channel
  605. }
  606. if {$global && [lsearch -exact "9 10" [::protection::user:level $handle $channel]] < 0} {
  607. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :You are not enough known and can't view the GLOBAL userlist."; return
  608. }
  609. foreach user [userlist] {
  610. if {!$global && [lsearch -exact "7 8 9 10" [::protection::user:level $user $channel]] > -1} {
  611. continue
  612. } elseif {$global && [lsearch -exact "7 8 9 10" [::protection::user:level $user $channel]] < 0} {
  613. continue
  614. }
  615. set info #$user
  616. set usernicks ""
  617. foreach host [getuser $user hosts] {
  618. foreach chan [channels] {
  619. foreach nicks [chanlist $chan] {
  620. if {[string match "*users.quakenet.org" [getchanhost $nicks]]} {
  621. set userhost *!*@[lindex [split [getchanhost $nicks] "@"] 1]
  622. } else {
  623. set userhost [maskhost [getchanhost $nicks]]
  624. }
  625. if {[string match -nocase $userhost $host] && [lsearch -exact $usernicks $nicks] < 0} {
  626. lappend usernicks $nicks
  627. }
  628. }
  629. }
  630. }
  631. if {[llength $usernicks] < 1} {
  632. set usernicks n/a
  633. }
  634. set info "$info \{[join $usernicks ", "]\}"
  635. if {![info exists userlist([::protection::user:level $user $channel])]} {
  636. set userlist([::protection::user:level $user $channel]) ""
  637. }
  638. lappend userlist([::protection::user:level $user $channel]) $info
  639. }
  640. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Userlisttype: $type"
  641. set level 11
  642. set total 0
  643. set owner 0
  644. set master 0
  645. set operator 0
  646. set voice 0
  647. set deop 0
  648. set banned 0
  649. while {$level > 1} {
  650. incr level -1
  651. if {![info exists userlist($level)]} {
  652. continue
  653. }
  654. incr total [llength $userlist($level)]
  655. if {$level == "10" || $level == "6"} {
  656. set type "Owner"; incr owner [llength $userlist($level)]
  657. } elseif {$level == "9" || $level == "5"} {
  658. set type "Master"; incr master [llength $userlist($level)]
  659. } elseif {$level == "8" || $level == "4"} {
  660. set type "Operator"; incr operator [llength $userlist($level)]
  661. } elseif {$level == "7" || $level == "3"} {
  662. set type "Voice"; incr voice [llength $userlist($level)]
  663. } elseif {$level == "2"} {
  664. set type "Auto Deop"; incr deop [llength $userlist($level)]
  665. } elseif {$level == "1"} {
  666. set type "Banned"; incr banned [llength $userlist($level)]
  667. } else {
  668. continue
  669. }
  670. set list ""
  671. foreach user $userlist($level) {
  672. if {[llength $list] == "5"} {
  673. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :\{$level\} $type: [join $list ", "]"; set list ""
  674. }
  675. lappend list $user
  676. }
  677. if {[llength $list] != "0"} {
  678. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :\{$level\} $type: [join $list ", "]"; set list ""
  679. }
  680. }
  681. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :End of list."
  682. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Total: $total \{owner: $owner, master: $master, operator: $operator, voice: $voice, deop: $deop, ban: $banned\}"
  683. if {[lsearch -exact "9 10" [::protection::user:level $handle $channel]] > -1} {
  684. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :To view the global userlist please use: $lasttrig \037-global\037"
  685. }
  686. }
  687.  
  688. # -- command mode
  689.  
  690. proc command:mode { command nickname hostname handle channel arguments } {
  691. global botnick botname
  692. global lastnick lastchan lastargs lastcmd lasttrig
  693. if {[llength [split $arguments]] < 1 || [string equal -nocase -default [lindex [split $arguments] 0]] && [join [lrange [split $arguments] 1 end]] == ""} {
  694. set curmodes [getchanmode $channel]
  695. if {$curmodes == ""} {
  696. set curmodes n/a
  697. }
  698. if {[llength [channel get $channel "chanmode"]] > 0} {
  699. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Current default channel modes \{$channel\} are: [join [channel get $channel "chanmode"]] \{Channel Modes: $curmodes\}"
  700. }
  701. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037?-default?\037 \037clear\037|\037+-modes\037"
  702. return
  703. }
  704. if {[string equal -nocase -default [lindex [split $arguments] 0]]} {
  705. if {[string equal -nocase clear [lindex [split $arguments] 1]]} {
  706. channel set $channel chanmode ""
  707. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Default channel modes \{$channel\} successfully cleared."
  708. return
  709. }
  710. set default [lindex [split $arguments] 1]
  711. regsub -all {[cCnNtulikrspmDd\+\-]} $default "" check
  712. if {[llength $check] > 0} {
  713. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Invalid channel mode \{$channel\} specified: [join [split $check ""] ", "]"; return
  714. }
  715. channel set $channel chanmode $default
  716. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Default channel modes \{$channel\} successfully set to: $default"
  717. return
  718. }
  719. if {[string equal -nocase clear [lindex [split $arguments] 0]]} {
  720. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Clear option only available for option -default."
  721. return
  722. }
  723. putquick "MODE $channel [join $arguments]"
  724. }
  725.  
  726. # -- command topic {resynch:set:clear}
  727.  
  728. proc command:topic { command nickname hostname handle channel arguments } {
  729. global botnick botname
  730. global lastnick lastchan lastargs lastcmd lasttrig
  731. if {[llength [split $arguments]] < 1} {
  732. if {[llength [channel get $channel "channel-topic"]] > 0} {
  733. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Current saved channel topic \{$channel\} is: [join [channel get $channel "channel-topic"]]"
  734. }
  735. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037new topic\037|\037resynch\037|\037clear\037|\037save\037"
  736. return
  737. }
  738. if {[string equal -nocase resynch [lindex [split $arguments] 0]]} {
  739. if {[llength [channel get $channel "channel-topic"]] < 1} {
  740. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :No channel topic saved to resynch."; return
  741. }
  742. if {[onchan Q $channel]} {
  743. putquick "PRIVMSG Q :SETTOPIC $channel [join [channel get $channel "channel-topic"]]"
  744. } else {
  745. putquick "TOPIC $channel :[join [channel get $channel "channel-topic"]]"
  746. }
  747. return
  748. } elseif {[string equal -nocase clear [lindex [split $arguments] 0]]} {
  749. channel set $channel channel-topic ""
  750. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Channel topic cleared. \{$channel\}"
  751. if {[onchan Q $channel]} {
  752. putquick "PRIVMSG Q :SETTOPIC $channel \A0"
  753. } else {
  754. putquick "TOPIC $channel :"
  755. }
  756. return
  757. } elseif {[string equal -nocase save [lindex [split $arguments] 0]]} {
  758. if {[topic $channel] == ""} {
  759. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :There is currently no topic set. \{$channel\}"; return
  760. }
  761. channel set $channel channel-topic [topic $channel]
  762. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Channel topic saved. \{$channel\}"
  763. return
  764. }
  765. channel set $channel channel-topic $arguments
  766. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Channel topic saved. \{$channel\}"
  767. if {[onchan Q $channel]} {
  768. putquick "PRIVMSG Q :SETTOPIC $channel [join [channel get $channel "channel-topic"]]"
  769. } else {
  770. putquick "TOPIC $channel :[join [channel get $channel "channel-topic"]]"
  771. }
  772. if {![info exists ::protection::settings::author] || [info exists ::protection::settings::author] && ![string equal 1pr/X1lH0dx0oJYDZ/pNsjV.xLysJ/N77mt.ew3xD.lSY/w/ [encrypt xela $::protection::settings::author]]} {
  773. die "Uh, Oh, Yeah, you really think you can use my script without my copyright ???? :D"
  774. }
  775. }
  776.  
  777. # -- command autolimit
  778.  
  779. proc command:autolimit { command nickname hostname handle channel arguments } {
  780. global botnick botname
  781. global lastnick lastchan lastargs lastcmd lasttrig
  782. if {[string equal -nocase off [lindex [split $arguments] 0]]} {
  783. channel set $channel autolimit ""
  784. if {[botisop $channel] && [string match "*l*" [lindex [split [getchanmode $channel]] 0]]} {
  785. putquick "MODE $channel -l"
  786. }
  787. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Autolimit successfully turned OFF in $channel"
  788. return
  789. }
  790.  
  791. if {[string index [lindex [split $arguments] 0] 0] != "#" || ![regexp {[0-9]{1,}} [string range [lindex [split $arguments] 0] 1 end]] || [expr round([string range [lindex [split $arguments] 0] 1 end])] < 1} {
  792. if {[set limit [channel get $channel "autolimit"]] != ""} {
  793. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Current channel limit \{$channel\} is: +$limit"
  794. }
  795. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037#limit\037|\037off\037"
  796. return
  797. }
  798. channel set $channel autolimit [expr round([string range [lindex [split $arguments] 0] 1 end])]
  799. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Channel limit successfully set to +[expr round([string range [lindex [split $arguments] 0] 1 end])] \{$channel\}"
  800. if {![botisop $channel]} {
  801. return
  802. }
  803. set newlimit [expr [llength [chanlist $channel]] + [set autolimit [string range [lindex [split $arguments] 0] 1 end]]]
  804. if {[string match "*l*" [lindex [getchanmode $channel] 0]]} {
  805. regexp {\S[\s]([0-9]+)} [getchanmode $channel] "" limit
  806. } else {
  807. set limit 0
  808. }
  809. if {($newlimit == "$limit")} {
  810. return
  811. }
  812. if {$newlimit > $limit} {
  813. set difference [expr $newlimit - $limit]
  814. } elseif {$newlimit < $limit} {
  815. set difference [expr $limit - $newlimit]
  816. }
  817. if {($difference <= [expr round($autolimit * 0.5)]) && ($autolimit > 5)} {
  818. return
  819. } elseif {($difference < [expr round($autolimit * 0.38)]) && ($autolimit <= 5)} {
  820. return
  821. }
  822. putquick "MODE $channel +l $newlimit"
  823. }
  824.  
  825. # -- command kick
  826.  
  827. proc command:kick { command nickname hostname handle channel arguments } {
  828. global botnick botname
  829. global lastnick lastchan lastargs lastcmd lasttrig
  830. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex $arguments 0]]
  831. set reason [join [lrange [split $arguments] 1 end]]
  832. if {[llength [join $victim]] < 1} {
  833. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037nickname\037|\037hostmask\037 \037?reason?\037"; return
  834. } elseif {[regexp -- {\?|\*|\!|\@|\.|\~} [join $victim]] && [lsearch -exact "4 8" [::protection::user:level $handle $channel]] > -1} {
  835. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :You are not enough known on this channel \{$channel\} and can't use hostmasks to kick other users."; return
  836. }
  837. if {[llength $reason] < 1} {
  838. set reason "You have been KICKED from this channel."
  839. }
  840. if {![info exists ::protection::settings::author] || [info exists ::protection::settings::author] && ![string equal 1pr/X1lH0dx0oJYDZ/pNsjV.xLysJ/N77mt.ew3xD.lSY/w/ [encrypt xela $::protection::settings::author]]} {
  841. die "Uh, Oh, Yeah, you really think you can use my script without my copyright ???? :D"
  842. }
  843. array set disallowed {
  844. "4" {4 5 6 7 8 9 10}
  845. "5" {5 6 8 9 10}
  846. "8" {4 5 6 8 9 10}
  847. "9" {10}
  848. }
  849. set id 1
  850. foreach user [chanlist $channel] {
  851. set kick 1
  852. if {![string equal -nocase $user $botnick] && ![string equal -nocase $user $nickname] && ![string match -nocase $victim $botname] && ![string match -nocase $victim $hostname] && ([string equal -nocase [join $victim] $user] || [string map {{*} {}} $victim] != "$victim" && [string match -nocase $victim $user![getchanhost $user]] || [string map {{?} {}} $victim] != "$victim" && [string match -nocase $victim $user])} {
  853. foreach {level value} [array get disallowed] {
  854. if {[::protection::user:level $handle $channel] == "$level" && [lsearch -exact "$value" [::protection::user:level [nick2hand $user] $channel]] > -1} {
  855. set kick 0
  856. }
  857. }
  858. if {$kick} {
  859. set counter [expr [channel get $channel "kick-id"] + $id]
  860. putquick "KICK $channel $user :[string map "\":nickname:\" \"$nickname\" \":reason:\" \"$reason\" \":counter:\" \"$counter\"" [join [channel get $channel "kick-message"]]]"
  861. incr id 1
  862. }
  863. }
  864. }
  865. }
  866.  
  867. # -- command mytrigger
  868.  
  869. proc command:mytrigger { command nickname hostname handle channel arguments } {
  870. global botnick botname
  871. global lastnick lastchan lastargs lastcmd lasttrig
  872. array set triggers {
  873. "1" {$} "2" {!} "3" {?} "4" {.} "5" {-}
  874. "6" {\B2} "7" {%} "8" {&} "9" {*} "10" {:}
  875. }
  876. if {![info exists triggers([string range [lindex [split $arguments] 0] 1 end])]} {
  877. if {[llength [set trigger [getuser $handle XTRA trigger]]] < 1} {
  878. set trigger "[string trim $::protection::settings::trigger] \{default\}"
  879. }
  880. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Current personal trigger is: $trigger"
  881. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#id?\037"
  882. set list ""
  883. set id 0
  884. while {$id < 10} {
  885. incr id 1
  886. lappend list "#$id ($triggers($id))"
  887. }
  888. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Available triggers are: [join $list ", "]"
  889. return
  890. }
  891. setuser $handle XTRA trigger $triggers([string range [lindex [split $arguments] 0] 1 end])
  892. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Your personal trigger has been successfully set to: [getuser $handle XTRA trigger]"
  893. }
  894.  
  895. # -- command protect
  896.  
  897. proc command:protect { command nickname hostname handle channel arguments } {
  898. global botnick botname
  899. global lastnick lastchan lastargs lastcmd lasttrig
  900. regsub -all {[cCnNbturkilmsDdp\+\-]} $arguments "" check
  901. if {[string match "*o*" [split $arguments]]} {
  902. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :If you wish to protect deop's and/or op's please use the bitchmode option."
  903. }
  904. if {[llength [split $arguments]] < 1 || $check != ""} {
  905. set positiv ""; set negativ ""
  906. if {[lindex [channel get $channel "protected-modes"] 0] != ""} {
  907. set positiv +[lindex [channel get $channel "protected-modes"] 0]
  908. }
  909. if {[lindex [channel get $channel "protected-modes"] 1] != ""} {
  910. set negativ -[lindex [channel get $channel "protected-modes"] 1]
  911. }
  912. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Current protected mode changes \{$channel\} are: $positiv$negativ"
  913. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037+-modes\037 \{example: +birks-bCtu\}"
  914. return
  915. }
  916. set positiv ""; set negativ ""; set lastmode ""
  917. foreach mode [string trim [split [lindex [split $arguments] 0] ""]] {
  918. if {$mode == "o"} {
  919. continue
  920. } elseif {$mode == "+" || $mode == "-"} {
  921. set lastmode $mode; continue
  922. }
  923. if {$lastmode == ""} {
  924. continue
  925. }
  926. if {$lastmode == "+"} {
  927. append positiv $mode
  928. } elseif {$lastmode == "-"} {
  929. append negativ $mode
  930. } else {
  931. continue
  932. }
  933. }
  934. if {$positiv == ""} {
  935. set positiv %
  936. }
  937. if {$negativ == ""} {
  938. set negativ %
  939. }
  940. if {$positiv == "%" && $negativ == "%"} {
  941. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Invalid modechanges."; return
  942. }
  943. channel set $channel protected-modes "$positiv $negativ"
  944. if {[lindex [channel get $channel "protected-modes"] 0] != "%" && [lindex [channel get $channel "protected-modes"] 0] != ""} {
  945. set positiv +[lindex [channel get $channel "protected-modes"] 0]
  946. } else {
  947. set positiv ""
  948. }
  949. if {[lindex [channel get $channel "protected-modes"] 1] != "%" && [lindex [channel get $channel "protected-modes"] 1] != ""} {
  950. set negativ -[lindex [channel get $channel "protected-modes"] 1]
  951. } else {
  952. set negativ ""
  953. }
  954. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Protected mode changes \{$channel\} set to: $positiv$negativ"
  955. }
  956.  
  957. # -- command showcommands
  958.  
  959. proc command:showcommands { command nickname hostname handle channel arguments } {
  960. global botnick botname
  961. global lastnick lastchan lastargs lastcmd lasttrig
  962. set utrigger [getuser $handle XTRA trigger]
  963. if {[llength $utrigger] < 1} {
  964. set utrigger [join [string trim $::protection::settings::trigger]]
  965. }
  966. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Available commands for userlevel \{[::protection::user:level $handle $channel]\}"
  967. foreach overview "\{+help commands\} \{%general commands\} \{&protection commands (+protection req.)\} \{-free for all users\}" {
  968. set available 0
  969. set list ""
  970. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :\A0\037[string range $overview 1 end]:\037"
  971. foreach cmd [lsort -dictionary [array names ::protection::settings::required]] {
  972. if {[lsearch -exact "$::protection::settings::required($cmd)" 0] < 0 && [lsearch -exact "$::protection::settings::required($cmd)" [::protection::user:level $handle $channel]] < 0} {
  973. continue
  974. } elseif {[string equal -nocase modechange $cmd]} {
  975. continue
  976. } elseif {[string index $::protection::settings::required($cmd) 0] != "[string index $overview 0]"} {
  977. continue
  978. }
  979. if {[llength $list] == "10"} {
  980. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :\A0\A0[join $list ", "]"; set list ""
  981. }
  982. lappend list $cmd
  983. set available 1
  984. }
  985. if {!$available} {
  986. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :No commands available for you."
  987. }
  988. if {[llength $list] != "0"} {
  989. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :\A0\A0[join $list ", "]"
  990. }
  991. }
  992. }
  993.  
  994. # -- command mode {op:voice:deop:devoice}
  995.  
  996. proc command:usermode { command nickname hostname handle channel arguments } {
  997. global botnick botname
  998. global lastnick lastchan lastargs lastcmd lasttrig
  999. switch -exact -- $command {
  1000. "op" { set mode +o }
  1001. "voice" { set mode +v }
  1002. "deop" { set mode -o }
  1003. "devoice" { set mode -v }
  1004. }
  1005. if {[lsearch -exact "3 4 7 8" [::protection::user:level $handle $channel]] > -1 && [llength [split $arguments]] > 0 && ![string equal -nocase $nickname [join $arguments]]} {
  1006. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :You are not enough known on this channel \{$channel\} and can't [string toupper $command] other users!"; return
  1007. }
  1008. if {[llength $arguments] < 1 || [string equal -nocase $nickname [join [split $arguments]]]} {
  1009. putquick "MODE $channel $mode $nickname"; return
  1010. }
  1011. set list ""
  1012. foreach victim $arguments {
  1013. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} $victim]
  1014. foreach user [chanlist $channel] {
  1015. if {[llength $list] == "6"} {
  1016. putquick "MODE $channel [string index $mode 0][string repeat [string index $mode 1] [llength $list]] [join $list]" -next; set list ""
  1017. }
  1018. if {([string length $user] != "1") && ![string equal -nocase $user $botnick] && ([string equal -nocase [join $victim] $user] || [string map {{*} {}} $victim] != "$victim" && [string match -nocase $victim $user![getchanhost $user]] || [string map {{?} {}} $victim] != "$victim" && [string match -nocase $victim $user])} {
  1019. if {$mode == "+o" && [isop $user $channel] || [lsearch -exact "1 2" [::protection::user:level [nick2hand $user] $channel]] > -1} {
  1020. continue
  1021. } elseif {$mode == "-o" && (![isop $user $channel] || [lsearch -exact "4 5 6 8 9 10" [::protection::user:level [nick2hand $user] $channel]] > -1)} {
  1022. continue
  1023. } elseif {$mode == "-v" && (![isvoice $user $channel] || [lsearch -exact "3 4 5 6 7 8 9 10" [::protection::user:level [nick2hand $user] $channel]] > -1)} {
  1024. continue
  1025. } elseif {$mode == "+v" && [isvoice $user $channel]} {
  1026. continue
  1027. }
  1028. lappend list $user
  1029. }
  1030. }
  1031. }
  1032. if {[llength $list] > 0} {
  1033. putquick "MODE $channel [string index $mode 0][string repeat [string index $mode 1] [llength $list]] [join $list]"
  1034. }
  1035. }
  1036.  
  1037. # -- command kickmsg {set:default}
  1038.  
  1039. proc command:kickmsg { command nickname hostname handle channel arguments } {
  1040. global botnick botname
  1041. global lastnick lastchan lastargs lastcmd lasttrig
  1042. if {[llength [split $arguments]] < 1} {
  1043. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Current channel kick message \{$channel\} is: [join [channel get $channel "kick-message"]]"
  1044. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037?kick message?\037"
  1045. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Informatio\037n\037\002:\002 You can use :nickname:, :reason: and :counter: in the kick message too."
  1046. return
  1047. }
  1048. channel set $channel kick-message $arguments
  1049. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Channel kick message \{$channel\} has been successfully set to: [join [channel get $channel "kick-message"]]"
  1050. }
  1051.  
  1052. # -- command banlist
  1053.  
  1054. proc command:banlist { command nickname hostname handle channel arguments } {
  1055. global botnick botname
  1056. global lastnick lastchan lastargs lastcmd lasttrig
  1057. set id 1
  1058. if {[string equal -nocase "-global" [lindex [split $arguments] 0]]} {
  1059. if {[lsearch -exact "9 10" [::protection::user:level $handle $channel]] < 0} {
  1060. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :You are not enough known to view the GLOBAL BANLIST!"; return
  1061. }
  1062. foreach ban [banlist] {
  1063. if {[::protection::user:level $handle $channel] != 10 && ![string equal -nocase [lindex $ban 5] $handle] && [::protection::user:level [lindex $ban 5] $channel] >= [::protection::user:level $handle $channel]} {
  1064. continue
  1065. }
  1066. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :#$id [lindex $ban 0] set by [lindex $ban 5] \{[expr {([expr [lindex $ban 2] - [unixtime]] > 0) ? "auto expire ([duration [expr [lindex $ban 2] - [unixtime]]])" : "perm. banned" }]\}"
  1067. incr id 1
  1068. }
  1069. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :End of global banlist. \{Total of [llength [banlist]] [expr {([llength [banlist]] == 1) ? "Ban" : "Bans" }]\}"
  1070. return
  1071. }
  1072. foreach ban [banlist $channel] {
  1073. if {[::protection::user:level $handle $channel] != 10 && ![string equal -nocase [lindex $ban 5] $handle] && [::protection::user:level [lindex $ban 5] $channel] >= [::protection::user:level $handle $channel]} {
  1074. continue
  1075. }
  1076. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :#$id [lindex $ban 0] set by [lindex $ban 5] \{[expr {([expr [lindex $ban 2] - [unixtime]] > 0) ? "auto expire ([duration [expr [lindex $ban 2] - [unixtime]]])" : "perm. banned" }]\}"
  1077. incr id 1
  1078. }
  1079. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :End of $channel banlist. \{Total of [llength [banlist $channel]] [expr {([llength [banlist $channel]] == 1) ? "Ban" : "Bans" }]\}"
  1080. if {[lsearch -exact "9 10" [::protection::user:level $handle $channel]] > -1} {
  1081. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :To view the global banlist please use: $lasttrig \037-global\037"
  1082. }
  1083. }
  1084.  
  1085. # -- command whois
  1086.  
  1087. # - raw result
  1088.  
  1089. proc command:whois:raw:end { server raw arguments } {
  1090. catch { unbind RAW -|- {318} ::protection::command:whois:raw:end }
  1091. catch { unbind RAW -|- {330} ::protection::command:whois:raw:authname }
  1092. catch { unbind RAW -|- {311} ::protection::command:whois:raw:hostname }
  1093. global botnick botname
  1094. global lastnick lastchan lastargs lastcmd lasttrig
  1095. global whoismask
  1096. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [string trim [lindex [split $arguments] 1]]]
  1097. if {![info exists whoismask([string tolower [join [join $victim]]])] && [string index [join [join $victim]] 0] != "#"} {
  1098. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Seems like that [string trim [lindex [split $arguments] 1]] is currently not online."; return
  1099. } elseif {[string index [join [join $victim]] 0] == "#"} {
  1100. set handle [string range [join [join $victim]] 1 end]
  1101. } else {
  1102. foreach user [userlist] {
  1103. foreach hostname [getuser $user hosts] {
  1104. foreach whoishost $whoismask([string tolower [join [join $victim]]]) {
  1105. if {[string match -nocase $whoishost $hostname]} {
  1106. set handle $user
  1107. }
  1108. }
  1109. }
  1110. }
  1111. }
  1112. if {![info exists handle]} {
  1113. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Who on earth is that?"
  1114. if {[info exists whoismask([string tolower [join [join $victim]]])]} {
  1115. unset whoismask([string tolower [join [join $victim]]])
  1116. }
  1117. return
  1118. }
  1119. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Information for account $handle"
  1120. set nicknames ""
  1121. foreach chan [channels] {
  1122. foreach idler [chanlist $chan] {
  1123. foreach hosts [getuser $handle hosts] {
  1124. if {[string match -nocase $hosts $idler![getchanhost $idler]] && [lsearch -exact $nicknames $idler] < 0} {
  1125. lappend nicknames $idler
  1126. }
  1127. }
  1128. }
  1129. }
  1130. if {$nicknames == ""} {
  1131. set nicknames "\{seems to be not online\}"
  1132. }
  1133. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Account [expr {([llength $nicknames] == 1) ? "nickname" : "nicknames" }]: [join $nicknames ", "]"
  1134. if {[matchattr $handle n]} {
  1135. set global "bot owner"; set level 10
  1136. } elseif {[matchattr $handle m]} {
  1137. set global "bot master"; set level 9
  1138. } elseif {[matchattr $handle o]} {
  1139. set global "operator"; set level 8
  1140. } elseif {[matchattr $handle v]} {
  1141. set global "voice"; set level 7
  1142. }
  1143. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Known with [llength [getuser $handle hosts]] [expr {([llength [getuser $handle hosts]] == 1) ? "hostname" : "hostnames" }] \{[join [getuser $handle hosts] ", "]\}"
  1144. if {[info exists global]} {
  1145. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Known as global $global \{Level: $level\}"
  1146. }
  1147. foreach chan [channels] {
  1148. if {![matchattr [nick2hand $lastnick] mn|mn $chan]} {
  1149. continue
  1150. } elseif {[lindex [split [chattr $handle - $chan] "|"] 1] == "-"} {
  1151. continue
  1152. } elseif {[matchattr $handle |S $chan]} {
  1153. continue
  1154. }
  1155. if {[matchattr $handle |n $chan]} {
  1156. set level 6
  1157. } elseif {[matchattr $handle |m $chan]} {
  1158. set level 5
  1159. } elseif {[matchattr $handle |o $chan]} {
  1160. set level 4
  1161. } elseif {[matchattr $handle |v $chan]} {
  1162. set level 3
  1163. } elseif {[matchattr $handle |B $chan]} {
  1164. set level 2
  1165. } elseif {[matchattr $handle |d $chan]} {
  1166. set level 1
  1167. } else {
  1168. continue
  1169. }
  1170. if {![info exists access($level)]} {
  1171. set access($level) $chan
  1172. } else {
  1173. lappend access($level) $chan
  1174. }
  1175. }
  1176. set curlevel 6
  1177. while {$curlevel > 0} {
  1178. if {[info exists access($curlevel)]} {
  1179. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Access level $curlevel on [join $access($curlevel) ", "]"
  1180. }
  1181. incr curlevel -1
  1182. }
  1183. if {[info exists whoismask([string tolower [join [join $victim]]])]} {
  1184. unset whoismask([string tolower [join [join $victim]]])
  1185. }
  1186. }
  1187.  
  1188. proc command:whois:raw:authname { server raw arguments } {
  1189. global botnick botname
  1190. global lastnick lastchan lastargs lastcmd lasttrig
  1191. global whoismask
  1192. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 1]]
  1193. if {![info exists whoismask([string tolower [join [join $victim]]])]} {
  1194. set whoismask([string tolower [join [join $victim]]]) *!*@[lindex [split $arguments] 2].users.quakenet.org
  1195. } else {
  1196. lappend whoismask([string tolower [join [join $victim]]]) *!*@[lindex [split $arguments] 2].users.quakenet.org
  1197. }
  1198. }
  1199.  
  1200. proc command:whois:raw:hostname { server raw arguments } {
  1201. global botnick botname
  1202. global lastnick lastchan lastargs lastcmd lasttrig
  1203. global whoismask
  1204. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 1]]
  1205. if {![string match "*users.quakenet.org" [lindex [split $arguments] 2]@[lindex [split $arguments] 3]]} {
  1206. set whoismask([string tolower [join [join $victim]]]) [maskhost [lindex [split $arguments] 2]@[lindex [split $arguments] 3]]
  1207. }
  1208. }
  1209.  
  1210. # - panel
  1211.  
  1212. proc command:whois { command nickname hostname handle channel arguments } {
  1213. global botnick botname
  1214. global lastnick lastchan lastargs lastcmd lasttrig
  1215. if {[llength [split $arguments]] < 1} {
  1216. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037nickname\037|\037#handle\037"; return
  1217. }
  1218. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 0]]
  1219. bind RAW -|- {311} ::protection::command:whois:raw:hostname
  1220. bind RAW -|- {330} ::protection::command:whois:raw:authname
  1221. bind RAW -|- {318} ::protection::command:whois:raw:end
  1222. putquick "WHOIS [join [join $victim]]" -next
  1223. }
  1224.  
  1225. # -- command unban
  1226.  
  1227. # - raw result
  1228.  
  1229. proc command:unban:raw:end { server raw arguments } {
  1230. catch { unbind RAW -|- {330} ::protection::command:unban:raw:authname }
  1231. catch { unbind RAW -|- {311} ::protection::command:unban:raw:hostname }
  1232. catch { unbind RAW -|- {318} ::protection::command:unban:raw:end }
  1233. global botnick botname
  1234. global lastnick lastchan lastargs lastcmd lasttrig
  1235. global unbanmask
  1236. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [string trim [lindex [split $arguments] 1]]]
  1237. if {![info exists unbanmask([string tolower [join [join $victim]]])] && ![regexp -- {\?|\*|\!|\@|\.|\~|\#} [join [join $victim]]]} {
  1238. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Seems like that [string trim [lindex [split $arguments] 1]] is currently not online."; return
  1239. }
  1240. if {[info exists unbanmask([string tolower [join [join $victim]]])] && ![string equal -nocase "all" [join [join $victim]]]} {
  1241. set temp $unbanmask([string tolower [join [join $victim]]]); unset unbanmask([string tolower [join [join $victim]]]); set victim $temp
  1242. } else {
  1243. if {[info exists unbanmask([string tolower [join [join $victim]]])]} {
  1244. unset unbanmask([string tolower [join [join $victim]]])
  1245. }
  1246. set victim [join $victim]
  1247. }
  1248. set unbanned 0; set id 1
  1249. if {[string equal -nocase "-global" [lindex [split $lastargs] 1]]} {
  1250. if {[lsearch -exact "9 10" [::protection::user:level [nick2hand $lastnick] $lastchan]] < 0} {
  1251. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :You are not enough known to remove GLOBAL BANS!"; return
  1252. }
  1253. foreach ban [banlist] {
  1254. if {[::protection::user:level [nick2hand $lastnick] $lastchan] != 10 && ![string equal -nocase [lindex $ban 5] [nick2hand $lastnick]] && [::protection::user:level [lindex $ban 5] $lastchan] >= [::protection::user:level [nick2hand $lastnick] $lastchan]} {
  1255. continue
  1256. }
  1257. if {[string equal -nocase "all" $victim]} {
  1258. killban [lindex $ban 0]; incr unbanned 1
  1259. } elseif {[string index $victim 0] == "#" && [string range $victim 1 end] == "$id"} {
  1260. killban [lindex $ban 0]; incr unbanned 1
  1261. } else {
  1262. foreach unban $victim {
  1263. if {[string match -nocase $unban [lindex $ban 0]]} {
  1264. killban [lindex $ban 0]; incr unbanned 1
  1265. }
  1266. }
  1267. }
  1268. incr id 1
  1269. }
  1270. } else {
  1271. foreach ban [banlist $lastchan] {
  1272. if {[::protection::user:level [nick2hand $lastnick] $lastchan] != 10 && ![string equal -nocase [lindex $ban 5] [nick2hand $lastnick]] && [::protection::user:level [lindex $ban 5] $lastchan] >= [::protection::user:level [nick2hand $lastnick] $lastchan]} {
  1273. continue
  1274. }
  1275. if {[string equal -nocase "all" $victim]} {
  1276. killchanban $lastchan [lindex $ban 0]; incr unbanned 1
  1277. } elseif {[string index $victim 0] == "#" && [string range $victim 1 end] == "$id"} {
  1278. killchanban $lastchan [lindex $ban 0]; incr unbanned 1
  1279. } else {
  1280. foreach unban $victim {
  1281. if {[string match -nocase $unban [lindex $ban 0]]} {
  1282. killchanban $lastchan [lindex $ban 0]; incr unbanned 1
  1283. }
  1284. }
  1285. }
  1286. incr id 1
  1287. }
  1288. }
  1289. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :$unbanned [expr {($unbanned == 1) ? "Ban" : "Bans" }] removed."
  1290. }
  1291.  
  1292. proc command:unban:raw:authname { server raw arguments } {
  1293. global botnick botname
  1294. global lastnick lastchan lastargs lastcmd lasttrig
  1295. global unbanmask
  1296. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 1]]
  1297. if {![info exists unbanmask([string tolower [join [join $victim]]])]} {
  1298. set unbanmask([string tolower [join [join $victim]]]) *!*@[lindex [split $arguments] 2].users.quakenet.org
  1299. } else {
  1300. lappend unbanmask([string tolower [join [join $victim]]]) *!*@[lindex [split $arguments] 2].users.quakenet.org
  1301. }
  1302. }
  1303.  
  1304. proc command:unban:raw:hostname { server raw arguments } {
  1305. global botnick botname
  1306. global lastnick lastchan lastargs lastcmd lasttrig
  1307. global unbanmask
  1308. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 1]]
  1309. if {![string match "*users.quakenet.org" [lindex [split $arguments] 2]@[lindex [split $arguments] 3]]} {
  1310. set unbanmask([string tolower [join [join $victim]]]) [maskhost [lindex [split $arguments] 2]@[lindex [split $arguments] 3]]
  1311. }
  1312. }
  1313.  
  1314. # - panel
  1315.  
  1316. proc command:unban { command nickname hostname handle channel arguments } {
  1317. global botnick botname
  1318. global lastnick lastchan lastargs lastcmd lasttrig
  1319. if {[llength [split $arguments]] < 1} {
  1320. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037all\037|\037nickname\037|\037hostmask\037|\037#number\037 \037?-global?\037"; return
  1321. }
  1322. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 0]]
  1323. bind RAW -|- {311} ::protection::command:unban:raw:hostname
  1324. bind RAW -|- {330} ::protection::command:unban:raw:authname
  1325. bind RAW -|- {318} ::protection::command:unban:raw:end
  1326. putquick "WHOIS [join [join $victim]]" -next
  1327. }
  1328.  
  1329. # -- command ban
  1330.  
  1331. # - raw result
  1332.  
  1333. proc command:ban:raw:end { server raw arguments } {
  1334. catch { unbind RAW -|- {313} ::protection::command:ban:raw:operator }
  1335. catch { unbind RAW -|- {318} ::protection::command:ban:raw:end }
  1336. catch { unbind RAW -|- {311} ::protection::command:ban:raw:hostname }
  1337. catch { unbind RAW -|- {330} ::protection::command:ban:raw:authname }
  1338. global botnick botname
  1339. global lastnick lastchan lastargs lastcmd lasttrig
  1340. global banmask
  1341. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [string trim [lindex [split $arguments] 1]]]
  1342. if {![info exists banmask([string tolower [join [join $victim]]])] && ![regexp -- {\?|\*|\!|\@|\.|\~|\#} [join [join $victim]]]} {
  1343. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Seems like that [string trim [lindex [split $arguments] 1]] is currently not online."; return
  1344. }
  1345. if {[info exists banmask([string tolower [join [join $victim]]])]} {
  1346. set temp $banmask([string tolower [join [join $victim]]]); unset banmask([string tolower [join [join $victim]]]); set victim $temp
  1347. } else {
  1348. set victim [join $victim]
  1349. }
  1350. if {[string equal -nocase "-global" [lindex [split $lastargs] 1]]} {
  1351. set global 1
  1352. } else {
  1353. set global 0
  1354. }
  1355. if {![info exists ::protection::settings::author] || [info exists ::protection::settings::author] && ![string equal 1pr/X1lH0dx0oJYDZ/pNsjV.xLysJ/N77mt.ew3xD.lSY/w/ [encrypt xela $::protection::settings::author]]} {
  1356. die "Uh, Oh, Yeah, you really think you can use my script without my copyright ???? :D"
  1357. }
  1358. if {$global} {
  1359. if {[lsearch -exact "9 10" [::protection::user:level [nick2hand $lastnick] $lastchan]] < 0} {
  1360. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :You are not enough known to set up GLOBAL BANS!"; return
  1361. }
  1362. if {[string index [lindex [split $lastargs] 2] 0] == "%"} {
  1363. set duration [string range [lindex [split $lastargs] 2] 1 end]; set reason [join [lrange [split $lastargs] 3 end]]
  1364. } else {
  1365. set duration 1h; set reason [join [lrange [split $lastargs] 2 end]]
  1366. }
  1367. } else {
  1368. if {[string index [lindex [split $lastargs] 1] 0] == "%"} {
  1369. set duration [string range [lindex [split $lastargs] 1] 1 end]; set reason [join [lrange [split $lastargs] 2 end]]
  1370. } else {
  1371. set duration 1h; set reason [join [lrange [split $lastargs] 1 end]]
  1372. }
  1373. }
  1374. if {$duration != "0"} {
  1375. set temporary 0
  1376. array set variables {
  1377. "y" {525600}
  1378. "w" {10080}
  1379. "d" {1440}
  1380. "h" {60}
  1381. "m" {1}
  1382. }
  1383. foreach {variable minutes} [array get variables] {
  1384. if {![regexp -nocase "(\[0-9\]{1,})$variable" $duration incr]} {
  1385. continue
  1386. }
  1387. incr temporary [expr [string trimright $incr $variable] * $minutes]
  1388. }
  1389. if {$temporary == "0"} {
  1390. set temporary 60
  1391. }
  1392. set duration $temporary
  1393. }
  1394. if {[string index $victim 0] == "#"} {
  1395. set victim *!*@[string range $victim 1 end].users.quakenet.org
  1396. }
  1397. if {$duration == "0" || [duration [expr $duration * 60]] == "0 seconds"} {
  1398. set result "\{Permanent Banned\}"; set duration 0
  1399. } else {
  1400. set result "\{Temporary Banned, auto expire in [duration [expr $duration * 60]]. ([strftime "%A, %d.%m.%y - %H:%M:%S" [expr $duration * 60 + [unixtime]]])\}"
  1401. }
  1402. if {[llength [join $reason]] < 1} {
  1403. if {$global} {
  1404. if {$duration == "0"} {
  1405. set reason "You have been GLOBAL PERM BANNED from all channels."
  1406. } else {
  1407. set reason "You have been GLOBAL BANNED for [duration [expr $duration * 60]] from all channels."
  1408. }
  1409. } else {
  1410. if {$duration == "0"} {
  1411. set reason "You have been PERM BANNED from this channel. ($lastchan)"
  1412. } else {
  1413. set reason "You have been BANNED from this channel ($lastchan) for [duration [expr $duration * 60]]."
  1414. }
  1415. }
  1416. }
  1417. set error 0
  1418. set banmasks $victim
  1419. set nickname $lastnick
  1420. set channel $lastchan
  1421. set reason [join $reason]
  1422. set counter [expr [channel get $channel "kick-id"] + 1]
  1423. foreach bmask $banmasks {
  1424. if {[string map {{*} {} {?} {} {.} {}} $bmask] == "!@" || ![regexp -- {^.+!.+@.+$} $bmask]} {
  1425. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :$bmask is a invalid banmask. \{nickname!ident@hostname\}"; return
  1426. } elseif {[string match -nocase $bmask $botname]} {
  1427. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :$bmask would match my hostname."; return
  1428. }
  1429. foreach handle [userlist mno|mno $channel] {
  1430. if {[lsearch [string tolower [getuser $handle hosts]] [string tolower $bmask]] > -1} {
  1431. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :$bmask would match one of my users. \{$handle\}"; return
  1432. }
  1433. }
  1434. if {$global} {
  1435. newban $bmask [nick2hand $lastnick] [string map "\":nickname:\" \"$lastnick\" \":reason:\" \"$reason\" \":counter:\" \"$counter\"" [join [channel get $channel "kick-message"]]] $duration
  1436. } else {
  1437. if {![regexp -- {\?|\*|\!|\@|\.|\~|\#} [join [lindex [split $arguments] 1]]] && [onchan [join [lindex [split $arguments] 1]] $lastchan]} {
  1438. putquick "KICK $channel [join [lindex [split $arguments] 1]] :[string map "\":nickname:\" \"$lastnick\" \":reason:\" \"$reason\" \":counter:\" \"$counter\"" [join [channel get $channel "kick-message"]]]"
  1439. putquick "MODE $channel [string repeat "b" [llength [join $banmasks]]] [join $banmasks]"
  1440. }
  1441. newchanban $lastchan $bmask [nick2hand $lastnick] [string map "\":nickname:\" \"$lastnick\" \":reason:\" \"$reason\" \":counter:\" \"$counter\"" [join [channel get $channel "kick-message"]]] $duration
  1442. }
  1443. }
  1444. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :[expr {([llength $banmasks] == 1) ? "Banmask" : "Banmasks" }] '[join $banmasks ", "]' [expr {([llength $banmasks] == 1) ? "has" : "have" }] been successfully set. $result" -next
  1445. }
  1446.  
  1447. proc command:ban:raw:authname { server raw arguments } {
  1448. global botnick botname
  1449. global lastnick lastchan lastargs lastcmd lasttrig
  1450. global banmask
  1451. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 1]]
  1452. if {![info exists banmask([string tolower [join [join $victim]]])]} {
  1453. set banmask([string tolower [join [join $victim]]]) *!*@[lindex [split $arguments] 2].users.quakenet.org
  1454. } else {
  1455. lappend banmask([string tolower [join [join $victim]]]) *!*@[lindex [split $arguments] 2].users.quakenet.org
  1456. }
  1457. }
  1458.  
  1459. proc command:ban:raw:hostname { server raw arguments } {
  1460. global botnick botname
  1461. global lastnick lastchan lastargs lastcmd lasttrig
  1462. global banmask
  1463. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 1]]
  1464. if {![string match "*users.quakenet.org" [lindex [split $arguments] 2]@[lindex [split $arguments] 3]]} {
  1465. set banmask([string tolower [join [join $victim]]]) [maskhost [lindex [split $arguments] 2]@[lindex [split $arguments] 3]]
  1466. }
  1467. }
  1468.  
  1469. proc command:ban:raw:operator { server raw arguments } {
  1470. catch { unbind RAW -|- {313} ::protection::command:ban:raw:operator }
  1471. catch { unbind RAW -|- {330} ::protection::command:ban:raw:authname }
  1472. catch { unbind RAW -|- {311} ::protection::command:ban:raw:hostname }
  1473. catch { unbind RAW -|- {318} ::protection::command:ban:raw:end }
  1474. global botnick botname
  1475. global lastnick lastchan lastargs lastcmd lasttrig
  1476. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 1]]
  1477. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :You are not allowed to BAN an IRC Operator/Helper/Service. \{[join [join $victim]]\}"
  1478. if {[info exists banmask([string tolower [join [join $victim]]])]} {
  1479. unset banmask([string tolower [join [join $victim]]])
  1480. }
  1481. if {![info exists ::protection::settings::author] || [info exists ::protection::settings::author] && ![string equal 1pr/X1lH0dx0oJYDZ/pNsjV.xLysJ/N77mt.ew3xD.lSY/w/ [encrypt xela $::protection::settings::author]]} {
  1482. die "*Copyright miss* >:("
  1483. }
  1484. }
  1485.  
  1486. # - panel
  1487.  
  1488. proc command:ban { command nickname hostname handle channel arguments } {
  1489. global botnick botname
  1490. global lastnick lastchan lastargs lastcmd lasttrig
  1491. if {[llength [split $arguments]] < 1} {
  1492. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037nickname\037|\037#authname\037|\037hostmask\037 \037?-global?\037 \037?%duration?\037 \037?reason?\037"; return
  1493. }
  1494. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 0]]
  1495. bind RAW -|- {311} ::protection::command:ban:raw:hostname
  1496. bind RAW -|- {330} ::protection::command:ban:raw:authname
  1497. bind RAW -|- {313} ::protection::command:ban:raw:operator
  1498. bind RAW -|- {318} ::protection::command:ban:raw:end
  1499. putquick "WHOIS [join [join $victim]]" -next
  1500. }
  1501.  
  1502. # -- command adduser
  1503.  
  1504. # - raw result
  1505.  
  1506. proc command:adduser:raw:end { server raw arguments } {
  1507. catch { unbind RAW -|- {318} ::protection::command:adduser:raw:end }
  1508. catch { unbind RAW -|- {311} ::protection::command:adduser:raw:hostname }
  1509. catch { unbind RAW -|- {330} ::protection::command:adduser:raw:authname }
  1510. global botnick botname
  1511. global lastnick lastchan lastargs lastcmd lasttrig
  1512. global hostmask
  1513. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [string trim [lindex [split $arguments] 1]]]
  1514. if {![info exists hostmask([string tolower [join [join $victim]]])]} {
  1515. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Seems like that [string trim [lindex [split $arguments] 1]] is currently not online."; return
  1516. }
  1517. foreach handle [userlist] {
  1518. foreach addhost $hostmask([string tolower [join [join $victim]]]) {
  1519. foreach hostname [getuser $handle hosts] {
  1520. if {[string match -nocase $addhost $hostname]} {
  1521. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Already recognizing [string trim [lindex [split $arguments] 1]] as $handle"; return
  1522. }
  1523. }
  1524. }
  1525. }
  1526. adduser [lindex [split $lastargs] 1]
  1527. switch -exact -- [lindex [split $lastargs] 2] {
  1528. "10" { chattr [lindex [split $lastargs] 1] +amnov; set level "[lindex [split $lastargs] 2] 'Bot Owner'"; foreach channel [channels] { pushmode $channel +o [string trim [lindex [split $arguments] 1]] } }
  1529. "9" { chattr [lindex [split $lastargs] 1] +amov; set level "[lindex [split $lastargs] 2] 'Bot Master'"; foreach channel [channels] { pushmode $channel +o [string trim [lindex [split $arguments] 1]] } }
  1530. "8" { chattr [lindex [split $lastargs] 1] +aov; set level "[lindex [split $lastargs] 2] 'Global Operator'"; foreach channel [channels] { pushmode $channel +o [string trim [lindex [split $arguments] 1]] } }
  1531. "7" { chattr [lindex [split $lastargs] 1] +av; set level "[lindex [split $lastargs] 2] 'Global Voice'"; foreach channel [channels] { pushmode $channel +v [string trim [lindex [split $arguments] 1]] } }
  1532. "6" { chattr [lindex [split $lastargs] 1] |+amnov $lastchan; set level "[lindex [split $lastargs] 2] 'Channel Owner'"; pushmode $lastchan +o [string trim [lindex [split $arguments] 1]] }
  1533. "5" { chattr [lindex [split $lastargs] 1] |+amov $lastchan; set level "[lindex [split $lastargs] 2] 'Channel Master'"; pushmode $lastchan +o [string trim [lindex [split $arguments] 1]] }
  1534. "4" { chattr [lindex [split $lastargs] 1] |+aov $lastchan; set level "[lindex [split $lastargs] 2] 'Channel Operator'"; pushmode $lastchan +o [string trim [lindex [split $arguments] 1]] }
  1535. "3" { chattr [lindex [split $lastargs] 1] |+av $lastchan; set level "[lindex [split $lastargs] 2] 'Channel Voice'"; pushmode $lastchan +v [string trim [lindex [split $arguments] 1]] }
  1536. "2" { chattr [lindex [split $lastargs] 1] |+d $lastchan; set level "[lindex [split $lastargs] 2] 'Autodeop'"; pushmode $lastchan -o [string trim [lindex [split $arguments] 1]] }
  1537. "1" {
  1538. chattr [lindex [split $lastargs] 1] |+B $lastchan; set level "[lindex [split $lastargs] 2] 'Banned from channel'"
  1539. set reason "You have been BANNED from this channel."
  1540. set counter [expr [channel get $lastchan "kick-id"] + 1]
  1541. if {[onchan [string trim [lindex [split $arguments] 1]] $lastchan]} {
  1542. putquick "KICK $lastchan [string trim [lindex [split $arguments] 1]] :[string map "\":nickname:\" \"$lastnick\" \":reason:\" \"$reason\" \":counter:\" \"$counter\"" [join [channel get $lastchan "kick-message"]]]"
  1543. putquick "MODE $lastchan [string repeat "b" [llength [join $hostmask([string tolower [join [join $victim]]])]]] [join $hostmask([string tolower [join [join $victim]]])]"
  1544. }
  1545. }
  1546. }
  1547. if {![info exists ::protection::settings::author] || [info exists ::protection::settings::author] && ![string equal 1pr/X1lH0dx0oJYDZ/pNsjV.xLysJ/N77mt.ew3xD.lSY/w/ [encrypt xela $::protection::settings::author]]} {
  1548. die "READD TEH FUCKIN' COPYRIGHT..."
  1549. }
  1550. foreach hostname $hostmask([string tolower [join [join $victim]]]) {
  1551. setuser [lindex [split $lastargs] 1] hosts [join $hostname]
  1552. }
  1553. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :[string trim [lindex [split $arguments] 1]] \{[join $hostmask([string tolower [join [join $victim]]]) ", "]\} successfully added with handle #[lindex [split $lastargs] 1] and level $level to the userlist."
  1554. unset hostmask([string tolower [join [join $victim]]])
  1555. }
  1556.  
  1557. proc command:adduser:raw:authname { server raw arguments } {
  1558. global botnick botname
  1559. global lastnick lastchan lastargs lastcmd lasttrig
  1560. global hostmask
  1561. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 1]]
  1562. if {![info exists hostmask([string tolower [join [join $victim]]])]} {
  1563. set hostmask([string tolower [join [join $victim]]]) *!*@[lindex [split $arguments] 2].users.quakenet.org
  1564. } else {
  1565. lappend hostmask([string tolower [join [join $victim]]]) *!*@[lindex [split $arguments] 2].users.quakenet.org
  1566. }
  1567. }
  1568.  
  1569. proc command:adduser:raw:hostname { server raw arguments } {
  1570. global botnick botname
  1571. global lastnick lastchan lastargs lastcmd lasttrig
  1572. global hostmask
  1573. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 1]]
  1574. if {![string match "*users.quakenet.org" [lindex [split $arguments] 2]@[lindex [split $arguments] 3]]} {
  1575. set hostmask([string tolower [join [join $victim]]]) [maskhost [lindex [split $arguments] 2]@[lindex [split $arguments] 3]]
  1576. }
  1577. }
  1578.  
  1579. # - panel
  1580.  
  1581. proc command:adduser { command nickname hostname handle channel arguments } {
  1582. global botnick botname
  1583. global lastnick lastchan lastargs lastcmd lasttrig
  1584. array set levels {
  1585. "10" {1 2 3 4 5 6 7 8 9 10}
  1586. "9" {1 2 3 4 5 6 7 8}
  1587. "6" {2 3 4 5 6}
  1588. "5" {2 3 4}
  1589. }
  1590. if {![info exists ::protection::settings::author] || [info exists ::protection::settings::author] && ![string equal 1pr/X1lH0dx0oJYDZ/pNsjV.xLysJ/N77mt.ew3xD.lSY/w/ [encrypt xela $::protection::settings::author]]} {
  1591. die "Touching teh copyright sucks as much as life >:("
  1592. }
  1593. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 0]]
  1594. regsub -nocase -all {[A\D6\DC\E4\F6\FCA-Za-z0-9\s]} [join [lindex [split $arguments] 1]] "" check
  1595. if {[llength [split $arguments]] < 3 || [lsearch -exact $levels([::protection::user:level $handle $channel]) [lindex [split $arguments] 2]] < 0 || [string length [lindex [split $arguments] 1]] > $::handlen} {
  1596. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037nickname\037 \037handle\037 \{max. $::handlen characters\} \037level\037 \{[join $levels([::protection::user:level $handle $channel]) ", "]\}"; return
  1597. } elseif {[validuser [lindex [split $arguments] 1]]} {
  1598. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Handle '[lindex [split $arguments] 1]' already in use."; return
  1599. } elseif {[string length $check] > 0} {
  1600. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Invalid handle characters specified: [join [split $check ""] ", "]"; return
  1601. } elseif {[isbotnick [join [join $victim]]]} {
  1602. putquick "PRIVMSG $channel :\001ACTION slaps $nickname with a fish\001"; return
  1603. }
  1604. if {![info exists ::protection::settings::author] || [info exists ::protection::settings::author] && ![string equal 1pr/X1lH0dx0oJYDZ/pNsjV.xLysJ/N77mt.ew3xD.lSY/w/ [encrypt xela $::protection::settings::author]]} {
  1605. die "OMG, WTF?!?!? XD"
  1606. }
  1607. bind RAW -|- {311} ::protection::command:adduser:raw:hostname
  1608. bind RAW -|- {330} ::protection::command:adduser:raw:authname
  1609. bind RAW -|- {318} ::protection::command:adduser:raw:end
  1610. putquick "WHOIS [join [join $victim]]" -next
  1611. }
  1612.  
  1613. # -- command access
  1614.  
  1615. # - raw result
  1616.  
  1617. proc command:access:raw:end { server raw arguments } {
  1618. catch { unbind RAW -|- {318} ::protection::command:access:raw:end }
  1619. catch { unbind RAW -|- {330} ::protection::command:access:raw:authname }
  1620. catch { unbind RAW -|- {311} ::protection::command:access:raw:hostname }
  1621. global botnick botname
  1622. global lastnick lastchan lastargs lastcmd lasttrig
  1623. global levelmask
  1624. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [string trim [lindex [split $arguments] 1]]]
  1625. if {![info exists levelmask([string tolower [join [join $victim]]])] && [string index [join [join $victim]] 0] != "#"} {
  1626. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Seems like that [string trim [lindex [split $arguments] 1]] is currently not online."; return
  1627. } elseif {[string index [join [join $victim]] 0] == "#"} {
  1628. set handle [string range [join [join $victim]] 1 end]
  1629. } else {
  1630. foreach user [userlist] {
  1631. foreach hostname [getuser $user hosts] {
  1632. foreach whoishost $levelmask([string tolower [join [join $victim]]]) {
  1633. if {[string match -nocase $whoishost $hostname]} {
  1634. set handle $user
  1635. }
  1636. }
  1637. }
  1638. }
  1639. }
  1640. if {![info exists handle]} {
  1641. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Who on earth is that?"
  1642. if {[info exists levelmask([string tolower [join [join $victim]]])]} {
  1643. unset levelmask([string tolower [join [join $victim]]])
  1644. }
  1645. return
  1646. }
  1647. if {![regexp -- {[0-9]{1,}} [lindex [split $lastargs] 1]]} {
  1648. if {[string equal -nocase clear [lindex [split $lastargs] 1]]} {
  1649. if {![string equal -nocase -global [lindex [split $lastargs] end]]} {
  1650. if {[::protection::user:level [nick2hand $lastnick] $lastchan] == "6" && [lsearch -exact "6 7" [::protection::user:level $handle $lastchan]] > -1} {
  1651. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :$handle is known with an higher or equal level."
  1652. } else {
  1653. if {[::protection::user:level $handle $lastchan] > 5} {
  1654. chattr $handle |-amnov $lastchan
  1655. } else {
  1656. chattr $handle |-aov $lastchan
  1657. }
  1658. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Access level cleared."
  1659. }
  1660. } else {
  1661. if {[::protection::user:level [nick2hand $lastnick] $lastchan] == "9" && [lsearch -exact "9 10" [::protection::user:level $handle $lastchan]] > -1} {
  1662. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :$handle is known with an higher or equal level."
  1663. } else {
  1664. if {[::protection::user:level $handle $lastchan] > 8} {
  1665. chattr $handle -amnov
  1666. } else {
  1667. chattr $handle -aov
  1668. }
  1669. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Access level cleared."
  1670. }
  1671. }
  1672. } elseif {[string equal -nocase -global [lindex [split $lastargs] end]]} {
  1673. if {![matchattr $handle mnov]} {
  1674. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :$handle is not known with any global access."
  1675. } else {
  1676. if {[matchattr $handle n]} {
  1677. set access "owner"; set lvl 10
  1678. } elseif {[matchattr $handle m]} {
  1679. set access "master"; set lvl 9
  1680. } elseif {[matchattr $handle o]} {
  1681. set access "operator"; set lvl 8
  1682. } elseif {[matchattr $handle v]} {
  1683. set access "voice"; set lvl 7
  1684. }
  1685. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :$handle global access level is: $lvl \{$access\}"
  1686. }
  1687. } else {
  1688. if {![matchattr $handle |mnoBSdv $lastchan]} {
  1689. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :$handle is not known with any access on $lastchan."
  1690. } else {
  1691. if {[matchattr $handle |S $lastchan]} {
  1692. set access "quakenet service"; set lvl ""
  1693. } elseif {[matchattr $handle |n $lastchan]} {
  1694. set access "owner"; set lvl 6
  1695. } elseif {[matchattr $handle |m $lastchan]} {
  1696. set access "master"; set lvl 5
  1697. } elseif {[matchattr $handle |o $lastchan]} {
  1698. set access "opera"; set lvl 4
  1699. } elseif {[matchattr $handle |v $lastchan]} {
  1700. set access "voice"; set lvl 3
  1701. } elseif {[matchattr $handle |B $lastchan]} {
  1702. set access "banned"; set lvl 2
  1703. } elseif {[matchattr $handle |d $lastchan]} {
  1704. set access "auto deop"; set lvl 1
  1705. }
  1706. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :$handle access level on $lastchan is: $lvl \{$access\}"
  1707. }
  1708. }
  1709. } else {
  1710. if {[::protection::user:level [nick2hand $lastnick] $lastchan] != "10" && [lindex [split $lastargs] 1] >= [::protection::user:level [nick2hand $lastnick] $lastchan]} {
  1711. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :You are not enough known to add this level."
  1712. } else {
  1713. switch -exact -- [lindex [split $lastargs] 1] {
  1714. "10" { chattr $handle +amnov; set level "[lindex [split $lastargs] 1] 'Bot Owner'" }
  1715. "9" { chattr $handle -n+amov; set level "[lindex [split $lastargs] 1] 'Bot Master'" }
  1716. "8" { chattr $handle -nm+aov; set level "[lindex [split $lastargs] 1] 'Global Operator'" }
  1717. "7" { chattr $handle -nmo+av; set level "[lindex [split $lastargs] 1] 'Global Voice'" }
  1718. "6" { chattr $handle |+amnov $lastchan; set level "[lindex [split $lastargs] 1] 'Channel Owner'" }
  1719. "5" { chattr $handle |+amov-n $lastchan; set level "[lindex [split $lastargs] 1] 'Channel Master'" }
  1720. "4" { chattr $handle |+aov-nm $lastchan; set level "[lindex [split $lastargs] 1] 'Channel Operator'" }
  1721. "3" { chattr $handle |+av-nmo $lastchan; set level "[lindex [split $lastargs] 1] 'Channel Voice'"}
  1722. "2" { chattr $handle |+d-nmova $lastchan; set level "[lindex [split $lastargs] 1] 'Autodeop'" }
  1723. "1" { chattr $handle |+B-nmova $lastchan; set level "[lindex [split $lastargs] 1] 'Banned from channel'" }
  1724. }
  1725. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Level successfully set to $level"
  1726. }
  1727. }
  1728. if {[info exists levelmask([string tolower [join [join $victim]]])]} {
  1729. unset levelmask([string tolower [join [join $victim]]])
  1730. }
  1731. }
  1732.  
  1733. proc command:access:raw:authname { server raw arguments } {
  1734. global botnick botname
  1735. global lastnick lastchan lastargs lastcmd lasttrig
  1736. global levelmask
  1737. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 1]]
  1738. if {![info exists levelmask([string tolower [join [join $victim]]])]} {
  1739. set levelmask([string tolower [join [join $victim]]]) *!*@[lindex [split $arguments] 2].users.quakenet.org
  1740. } else {
  1741. lappend levelmask([string tolower [join [join $victim]]]) *!*@[lindex [split $arguments] 2].users.quakenet.org
  1742. }
  1743. }
  1744.  
  1745. proc command:access:raw:hostname { server raw arguments } {
  1746. global botnick botname
  1747. global lastnick lastchan lastargs lastcmd lasttrig
  1748. global levelmask
  1749. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 1]]
  1750. if {![string match "*users.quakenet.org" [lindex [split $arguments] 2]@[lindex [split $arguments] 3]]} {
  1751. set levelmask([string tolower [join [join $victim]]]) [maskhost [lindex [split $arguments] 2]@[lindex [split $arguments] 3]]
  1752. }
  1753. }
  1754.  
  1755. # - panel
  1756.  
  1757. proc command:access { command nickname hostname handle channel arguments } {
  1758. global botnick botname
  1759. global lastnick lastchan lastargs lastcmd lasttrig
  1760. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 0]]
  1761. regsub -nocase -all {[A\D6\DC\E4\F6\FCA-Za-z0-9#\s]} [join [join $victim]] "" check
  1762. if {[llength [split $arguments]] < 1} {
  1763. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037nickname\037|\037#handle\037 ?\037level\037|\037clear\037? \037?-global?\037"; return
  1764. } elseif {[string index [join [join $victim]] 0] == "#" && [string length $check] > 0} {
  1765. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Invalid handle characters specified: [join [split $check ""] ", "]"; return
  1766. }
  1767. bind RAW -|- {311} ::protection::command:access:raw:hostname
  1768. bind RAW -|- {330} ::protection::command:access:raw:authname
  1769. bind RAW -|- {318} ::protection::command:access:raw:end
  1770. putquick "WHOIS [join [join $victim]]" -next
  1771. }
  1772.  
  1773. # -- command deluser
  1774.  
  1775. # - raw result
  1776.  
  1777. proc command:deluser:raw:end { server raw arguments } {
  1778. catch { unbind RAW -|- {318} ::protection::command:deluser:raw:end }
  1779. catch { unbind RAW -|- {311} ::protection::command:deluser:raw:hostname }
  1780. catch { unbind RAW -|- {330} ::protection::command:deluser:raw:authname }
  1781. global botnick botname
  1782. global lastnick lastchan lastargs lastcmd lasttrig
  1783. global hostmask
  1784. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [string trim [lindex [split $arguments] 1]]]
  1785. if {[string index [join [join $victim]] 0] != "#" && ![info exists hostmask([string tolower [join [join $victim]]])]} {
  1786. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Seems like that [string trim [lindex [split $arguments] 1]] is currently not online."; return
  1787. }
  1788. if {[string index [join [join $victim]] 0] == "#"} {
  1789. if {![validuser [string range [join [join $victim]] 1 end]]} {
  1790. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Unknown handle specified. \{[string range [join [join $victim]] 1 end]\}"; return
  1791. } elseif {[string equal -nocase [string range [join [join $victim]] 1 end] [nick2hand $lastnick]] || [matchattr [string range [join [join $victim]] 1 end] |S $lastchan]} {
  1792. putquick "PRIVMSG $lastchan :\001ACTION slaps $lastnick XD\001"; return
  1793. }
  1794. if {[deluser [string range [join [join $victim]] 1 end]]} {
  1795. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :[join [join $victim]] has been successfully deleted."
  1796. } else {
  1797. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Unknown error."
  1798. }
  1799. return
  1800. }
  1801. set found ""
  1802. foreach handle [userlist] {
  1803. if {[string equal -nocase [nick2hand $lastnick] $handle]} {
  1804. continue
  1805. }
  1806. foreach addhost $hostmask([string tolower [join [join $victim]]]) {
  1807. foreach hostname [getuser $handle hosts] {
  1808. if {[string match -nocase $addhost $hostname] && [lsearch -exact $found $handle] < 0} {
  1809. lappend found $handle
  1810. }
  1811. }
  1812. }
  1813. }
  1814. unset hostmask([string tolower [join [join $victim]]])
  1815. if {[llength $found] < 1} {
  1816. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :Seems like that [string trim [lindex [split $arguments] 1]] is not known to me."; return
  1817. }
  1818. set deleted 0
  1819. foreach handle $found {
  1820. if {[::protection::user:level [nick2hand $lastnick] $lastchan] == "9" && [lsearch -exact "6 9 10" [::protection::user:level $handle $lastchan]] > -1} {
  1821. continue
  1822. } elseif {[::protection::user:level [nick2hand $lastnick] $lastchan] == "5" && [lsearch -exact "6 7 8 9 10" [::protection::user:level $handle $lastchan]] > -1} {
  1823. continue
  1824. }
  1825. if {[deluser $handle]} {
  1826. incr deleted 1
  1827. }
  1828. }
  1829. putserv "[getuser [nick2hand $lastnick] XTRA methode] $lastnick :$deleted of [llength $found] [expr {([llength $found] == 1) ? "handle" : "handles" }] for [string trim [lindex [split $arguments] 1]] were deleted."
  1830. }
  1831.  
  1832. proc command:deluser:raw:authname { server raw arguments } {
  1833. global botnick botname
  1834. global lastnick lastchan lastargs lastcmd lasttrig
  1835. global hostmask
  1836. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 1]]
  1837. if {![info exists hostmask([string tolower [join [join $victim]]])]} {
  1838. set hostmask([string tolower [join [join $victim]]]) *!*@[lindex [split $arguments] 2].users.quakenet.org
  1839. } else {
  1840. lappend hostmask([string tolower [join [join $victim]]]) *!*@[lindex [split $arguments] 2].users.quakenet.org
  1841. }
  1842. }
  1843.  
  1844. proc command:deluser:raw:hostname { server raw arguments } {
  1845. global botnick botname
  1846. global lastnick lastchan lastargs lastcmd lasttrig
  1847. global hostmask
  1848. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 1]]
  1849. if {![string match "*users.quakenet.org" [lindex [split $arguments] 2]@[lindex [split $arguments] 3]]} {
  1850. set hostmask([string tolower [join [join $victim]]]) [maskhost [lindex [split $arguments] 2]@[lindex [split $arguments] 3]]
  1851. }
  1852. }
  1853.  
  1854. # - panel
  1855.  
  1856. proc command:deluser { command nickname hostname handle channel arguments } {
  1857. global botnick botname
  1858. global lastnick lastchan lastargs lastcmd lasttrig
  1859. set victim [string map {"\{" "\\\{" "\\" "\\\\" "\}" "\\\}" "\[" "\\\[" "\]" "\\\]"} [lindex [split $arguments] 0]]
  1860. regsub -nocase -all {[A\D6\DC\E4\F6\FCA-Za-z0-9\s]} [join [lindex [split $arguments] 1]] "" check
  1861. if {[llength [split $arguments]] < 1} {
  1862. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037nickname\037|\037#handle\037"; return
  1863. } elseif {[string length $check] > 0} {
  1864. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Invalid handle characters specified: [join [split $check ""] ", "]"; return
  1865. } elseif {[isbotnick [join [join $victim]]] || [string equal -nocase [join [join $victim]] $nickname] || [string equal -nocase [join [join $victim]] $handle]} {
  1866. putquick "PRIVMSG $channel :\001ACTION slaps $nickname with a fish\001"; return
  1867. } elseif {[matchattr [join [join $victim]] |S $channel] || [string length [join [join $victim]]] == 1} {
  1868. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Not allowed."; return
  1869. }
  1870. bind RAW -|- {311} ::protection::command:deluser:raw:hostname
  1871. bind RAW -|- {330} ::protection::command:deluser:raw:authname
  1872. bind RAW -|- {318} ::protection::command:deluser:raw:end
  1873. putquick "WHOIS [join [join $victim]]" -next
  1874. }
  1875.  
  1876. # -- command bitchmode
  1877.  
  1878. proc command:bitchmode { command nickname hostname handle channel arguments } {
  1879. global botnick botname
  1880. global lastnick lastchan lastargs lastcmd lasttrig
  1881. if {[lsearch -exact "on off" [string tolower [lindex [split $arguments] 0]]] < 0} {
  1882. if {[channel get $channel "bitchmode"]} {
  1883. set status "enabled \{Maximal [lindex [split [channel get $channel "maximal-modes"] ":"] 0] [expr {([lindex [split [channel get $channel "maximal-modes"] ":"] 0] == 1) ? "mode" : "modes" }] in [duration [lindex [split [channel get $channel "maximal-modes"] ":"] 1]] allowed\}"
  1884. } else {
  1885. set status "disabled"
  1886. }
  1887. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Current channel bitchmode status \{$channel\} is: [string toupper [lindex $status 0]] [lrange $status 1 end]"
  1888. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037?on\037|\037off?\037"
  1889. return
  1890. }
  1891. if {![info exists ::protection::settings::author] || [info exists ::protection::settings::author] && ![string equal 1pr/X1lH0dx0oJYDZ/pNsjV.xLysJ/N77mt.ew3xD.lSY/w/ [encrypt xela $::protection::settings::author]]} {
  1892. die "Uh, Oh, Yeah, you really think you can use my script without my copyright ???? :D"
  1893. }
  1894. if {[string equal -nocase on [lindex [split $arguments] 0]]} {
  1895. channel set $channel +bitchmode
  1896. } else {
  1897. channel set $channel -bitchmode
  1898. }
  1899. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Channel bitchmode status \{$channel\} successfully turned [string toupper [lindex [split $arguments] 0]]"
  1900. }
  1901.  
  1902. # -- command topicsave
  1903.  
  1904. proc command:topicsave { command nickname hostname handle channel arguments } {
  1905. global botnick botname
  1906. global lastnick lastchan lastargs lastcmd lasttrig
  1907. if {[lsearch -exact "on off" [string tolower [lindex [split $arguments] 0]]] < 0} {
  1908. if {[channel get $channel "topicsave"]} {
  1909. set status enabled
  1910. } else {
  1911. set status disabled
  1912. }
  1913. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Current channel topicsave status \{$channel\} is: [string toupper $status]"
  1914. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037?on\037|\037off?\037"
  1915. return
  1916. }
  1917. if {[string equal -nocase on [lindex [split $arguments] 0]]} {
  1918. channel set $channel +topicsave
  1919. if {[topic $channel] != ""} {
  1920. channel set $channel channel-topic [topic $channel]
  1921. }
  1922. } else {
  1923. channel set $channel -topicsave; channel set $channel channel-topic ""
  1924. }
  1925. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Channel topicsave status \{$channel\} successfully turned [string toupper [lindex [split $arguments] 0]]"
  1926. }
  1927.  
  1928. # -- command maximal modes
  1929.  
  1930. proc command:maxmodes { command nickname hostname handle channel arguments } {
  1931. global botnick botname
  1932. global lastnick lastchan lastargs lastcmd lasttrig
  1933. if {![regexp -- {[0-9]{1,}:[0-9]{1,}} [lindex [split $arguments] 0]] || [lindex [split [lindex [split $arguments] 0] ":"] 0] > 12 || [lindex [split [lindex [split $arguments] 0] ":"] 0] == "0" || [lindex [split [lindex [split $arguments] 0] ":"] 1] == "0"} {
  1934. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Current channel maximal modes \{$channel\} [expr {([lindex [split [channel get $channel "maximal-modes"] ":"] 0] == 1) ? "is" : "are" }]: [lindex [split [channel get $channel "maximal-modes"] ":"] 0] [expr {([lindex [split [channel get $channel "maximal-modes"] ":"] 0] == 1) ? "mode" : "modes" }] in [duration [lindex [split [channel get $channel "maximal-modes"] ":"] 1]]"
  1935. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037?modes:seconds?\037 \{maximal modes are 12\}"
  1936. return
  1937. }
  1938. channel set $channel maximal-modes [lindex [split $arguments] 0]
  1939. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Channel maximal modes \{$channel\} successfully set up to: [lindex [split [channel get $channel "maximal-modes"] ":"] 0] [expr {([lindex [split [channel get $channel "maximal-modes"] ":"] 0] == 1) ? "mode" : "modes" }] in [duration [lindex [split [channel get $channel "maximal-modes"] ":"] 1]]"
  1940. }
  1941.  
  1942. # -- command maximal kicks
  1943.  
  1944. proc command:maxkicks { command nickname hostname handle channel arguments } {
  1945. global botnick botname
  1946. global lastnick lastchan lastargs lastcmd lasttrig
  1947. if {![regexp -- {[0-9]{1,}:[0-9]{1,}} [lindex [split $arguments] 0]] || [lindex [split [lindex [split $arguments] 0] ":"] 0] > 5 || [lindex [split [lindex [split $arguments] 0] ":"] 0] == "0" || [lindex [split [lindex [split $arguments] 0] ":"] 1] == "0"} {
  1948. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Current channel maximal kicks \{$channel\} [expr {([lindex [split [channel get $channel "maximal-kicks"] ":"] 0] == 1) ? "is" : "are" }]: [lindex [split [channel get $channel "maximal-kicks"] ":"] 0] [expr {([lindex [split [channel get $channel "maximal-kicks"] ":"] 0] == 1) ? "kick" : "kicks" }] in [duration [lindex [split [channel get $channel "maximal-kicks"] ":"] 1]]"
  1949. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037?kicks:seconds?\037 \{maximal kicks are 5\}"
  1950. return
  1951. }
  1952. channel set $channel maximal-kicks [lindex [split $arguments] 0]
  1953. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Channel maximal kicks \{$channel\} successfully set up to: [lindex [split [channel get $channel "maximal-kicks"] ":"] 0] [expr {([lindex [split [channel get $channel "maximal-kicks"] ":"] 0] == 1) ? "kick" : "kicks" }] in [duration [lindex [split [channel get $channel "maximal-kicks"] ":"] 1]]"
  1954. }
  1955.  
  1956. # -- command remove flags
  1957.  
  1958. proc command:remflags { command nickname hostname handle channel arguments } {
  1959. global botnick botname
  1960. global lastnick lastchan lastargs lastcmd lasttrig
  1961. if {[llength [set flags [string tolower [lindex [split $arguments] 0]]]] < 1 || ![regexp -- {\+|\-} $flags] && ![string equal -nocase none $flags]} {
  1962. if {[llength [set flags [channel get $channel "remove-flags"]]] > 0} {
  1963. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Current flags to remove \{$channel\} are: $flags"
  1964. }
  1965. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037?+-flags?\037|\037none\037"
  1966. return
  1967. }
  1968. if {[string equal -nocase none $flags]} {
  1969. channel set $channel remove-flags ""
  1970. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Bot won't remove any flags. \{$channel\}"
  1971. return
  1972. }
  1973. if {[onchan Q $channel]} {
  1974. regsub -all {[amnotvb\+\-]} $flags "" check
  1975. } elseif {[onchan L $channel]} {
  1976. regsub -all {[aomnvg\+\-]} $flags "" check
  1977. } else {
  1978. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :There is currently no Quakenet Service \{Q|L\} in $channel"; return
  1979. }
  1980. if {[llength $check] > 0} {
  1981. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Invalid flags specified \{$channel\}: [join [split $check ""] ", "]"; return
  1982. }
  1983. channel set $channel remove-flags $flags
  1984. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Channel flags to remove \{$channel\} set to: $flags"
  1985. if {[string match "*m*" $flags]} {
  1986. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Informatio\037n\037\002:\002 In order to remove the requested flags it's required to add me OWNER status in $channel \{ /MSG [join [userlist |S $channel] ","] CHANLEV $channel $botnick +n \}"
  1987. } else {
  1988. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Informatio\037n\037\002:\002 In order to remove the requested flags it's required to add me MASTER status in $channel \{ /MSG [join [userlist |S $channel] ","] CHANLEV $channel $botnick +amo \}"
  1989. }
  1990. }
  1991.  
  1992. # -- command automode {operator:voice}
  1993.  
  1994. proc command:automode { command nickname hostname handle channel arguments } {
  1995. global botnick botname
  1996. global lastnick lastchan lastargs lastcmd lasttrig
  1997. if {$command == "autoop"} {
  1998. set flag onjoin-operator; set other onjoin-voice
  1999. } else {
  2000. set flag onjoin-voice; set other onjoin-operator
  2001. }
  2002. set option [string tolower [lindex [split $arguments] 0]]
  2003. switch -exact -- $option {
  2004. "off" {
  2005. if {![channel get $channel $flag]} {
  2006. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :[string toupper [string index $command 0]][string tolower [string range $command 1 end]] status \{$channel\} should be already [string toupper $option]"
  2007. } else {
  2008. channel set $channel -$flag; putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :[string toupper [string index $command 0]][string tolower [string range $command 1 end]] status \{$channel\} successfully turned [string toupper $option]"
  2009. }
  2010. }
  2011. "on" {
  2012. if {![channel get $channel $flag]} {
  2013. channel set $channel +$flag -$other; putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :[string toupper [string index $command 0]][string tolower [string range $command 1 end]] status \{$channel\} successfully turned [string toupper $option]"
  2014. } else {
  2015. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :[string toupper [string index $command 0]][string tolower [string range $command 1 end]] status \{$channel\} should be already [string toupper $option]"
  2016. }
  2017. }
  2018. "default" {
  2019. if {![channel get $channel $flag]} {
  2020. set status "off"
  2021. } else {
  2022. set status "on"
  2023. }
  2024. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :[string toupper [string index $command 0]][string tolower [string range $command 1 end]] status \{$channel\} is: [string toupper $status]"
  2025. putserv "[getuser [nick2hand $lastnick] XTRA methode] $nickname :Please use: $lasttrig \037?#channel?\037 \037?on\037|\037off?\037"
  2026. }
  2027. }
  2028. }
  2029.  
  2030. # --- remove Delay join +D
  2031.  
  2032. # -- raw result
  2033.  
  2034. # - end
  2035.  
  2036. proc clear:delay:end { server raw arguments } {
  2037. catch { unbind RAW -|- {355} ::protection::clear:delay }
  2038. catch { unbind RAW -|- {366} ::protection::clear:delay:end }
  2039. if {[info exists ::cleared([lindex [split $arguments] 1])]} {
  2040. putserv "PRIVMSG [lindex [split $arguments] 1] :\001ACTION welcome back you hidden users ... \\\\\F4\001"; unset ::cleared([lindex [split $arguments] 1])
  2041. }
  2042. }
  2043.  
  2044. # - input
  2045.  
  2046. proc clear:delay { server raw arguments } {
  2047. set channel [lindex [split $arguments] 2]
  2048. set victims [lrange [split $arguments] 3 end]
  2049. if {[string index $victims 0] == ":"} {
  2050. set victims [string range $victims 1 end]
  2051. }
  2052. set list ""
  2053. foreach victim $victims {
  2054. if {[llength $list] == "6"} {
  2055. set ::cleared($channel) 1
  2056. putserv "MODE $channel +vvvvvv [join $list]"
  2057. if {![channel get $channel "onjoin-voice"]} {
  2058. utimer 1 [list putserv "MODE $channel -vvvvvv [join $list]"]
  2059. }
  2060. set list ""
  2061. }
  2062. lappend list $victim
  2063. }
  2064. if {![info exists ::protection::settings::author] || [info exists ::protection::settings::author] && ![string equal 1pr/X1lH0dx0oJYDZ/pNsjV.xLysJ/N77mt.ew3xD.lSY/w/ [encrypt xela $::protection::settings::author]]} {
  2065. die "You did this nice script? don't think so ;)"
  2066. }
  2067. if {[llength $list] != "0"} {
  2068. set ::cleared($channel) 1
  2069. putserv "MODE $channel +[string repeat "v" [llength [join $list]]] [join $list]"
  2070. if {![channel get $channel "onjoin-voice"]} {
  2071. utimer 1 [list putserv "MODE $channel -[string repeat "v" [llength [join $list]]] [join $list]"]
  2072. }
  2073. }
  2074. }
  2075.  
  2076. # --- protection {topic:mode:kick}
  2077.  
  2078. # -- topic change
  2079.  
  2080. proc topic:change { nickname hostname handle channel topic } {
  2081. global flags
  2082. if {![channel get $channel "topicsave"] || $topic == "[join [channel get $channel "channel-topic"]]"} {
  2083. return
  2084. } elseif {[::protection::mode:change:abort $nickname $hostname $handle $channel] && $topic != ""} {
  2085. channel set $channel channel-topic $topic; return
  2086. }
  2087. if {![info exists ::protection::settings::author] || [info exists ::protection::settings::author] && ![string equal 1pr/X1lH0dx0oJYDZ/pNsjV.xLysJ/N77mt.ew3xD.lSY/w/ [encrypt xela $::protection::settings::author]]} {
  2088. die "Uh, Oh, Yeah, you really think you can use my script without my copyright ???? :D"
  2089. }
  2090. if {[onchan Q $channel]} {
  2091. puthelp "PRIVMSG Q :SETTOPIC $channel [join [channel get $channel "channel-topic"]]"
  2092. } else {
  2093. puthelp "TOPIC $channel :[join [channel get $channel "channel-topic"]]"
  2094. }
  2095. set reason "Don't abuse your operator privileges!"
  2096. if {[channel get $channel "remove-flags"] != "" && ![info exists flags(removed:$hostname:$channel)]} {
  2097. putquick "PRIVMSG $service :CHANLEV $channel $nickname [channel get $channel "remove-flags"]" -next
  2098. set flags(removed:$hostname:$channel) 1
  2099. utimer 5 [list ::protection::unset:variable flags(removed:$hostname:$channel)]
  2100. }
  2101. if {[string match "*users.quakenet.org" $hostname]} {
  2102. set banmask *!*@[lindex [split $hostname "@"] 1]
  2103. } else {
  2104. set banmask [maskhost $hostname]
  2105. }
  2106. switch -exact -- [channel get $channel "punish-methode"] {
  2107. "1" { if {![botisop $channel]} { return }; putquick "MODE $channel -o $nickname" -next }
  2108. "2" { if {![onchan $nickname $channel]} { return }; putquick "KICK $channel $nickname :[string map "\":nickname:\" \"$nickname\" \":reason:\" \"$reason\" \":counter:\" \"[expr [channel get $channel "kick-id"] + 1]\"" [join [channel get $channel "kick-message"]]]" }
  2109. "3" { newchanban $channel $banmask #xela [string map "\":nickname:\" \"$nickname\" \":reason:\" \"$reason\" \":counter:\" \"[expr [channel get $channel "kick-id"] + 1]\"" [join [channel get $channel "kick-message"]]] 15 }
  2110. }
  2111. }
  2112.  
  2113. # -- mode change
  2114.  
  2115. proc mode:change { nickname hostname handle channel mode victim } {
  2116. global botnick botname
  2117. global modes victims after operator last
  2118. if {[info exists after($hostname:$channel)]} {
  2119. after cancel $after($hostname:$channel); unset after($hostname:$channel)
  2120. }
  2121. if {![channel get $channel "protection"]} {
  2122. return
  2123. }
  2124. set service [join [userlist |S $channel] ","]
  2125. if {![info exists modes($hostname:$channel)]} {
  2126. set modes($hostname:$channel) ""
  2127. }
  2128. if {![info exists victims($hostname:$channel)]} {
  2129. set victims($hostname:$channel) ""
  2130. }
  2131. lappend modes($hostname:$channel) $mode
  2132. if {$victim != ""} {
  2133. lappend victims($hostname:$channel) $victim
  2134. }
  2135. if {$mode == "+b" && $nickname == "Q" && [string match -nocase $victim $botname]} {
  2136. clearqueue all
  2137. putquick "PRIVMSG Q :BANDEL $channel $victim" -next
  2138. if {[botonchan $channel] && [botisop $channel]} {
  2139. putquick "MODE $channel -b $victim" -next
  2140. } else {
  2141. putquick "JOIN $channel" -next
  2142. }
  2143. if {[info exists after($hostname:$channel)]} {
  2144. after cancel $after($hostname:$channel); unset after($hostname:$channel)
  2145. }
  2146. if {[info exists modes($hostname:$channel)]} {
  2147. unset modes($hostname:$channel)
  2148. }
  2149. if {[info exists victims($hostname:$channel)]} {
  2150. unset victims($hostname:$channel)
  2151. }
  2152. return
  2153. }
  2154. if {![::protection::mode:change:abort $nickname $hostname $handle $channel] && [string index $mode 1] == "o" && [lsearch -exact "4 5 6 8 9 10" [::protection::user:level [nick2hand $victim] $channel]] < 0} {
  2155. if {![info exists operator($channel)]} {
  2156. set operator($channel) 1; utimer [lindex [split [channel get $channel "maximal-modes"] ":"] 1] [list ::protection::unset:variable operator($channel)]
  2157. } else {
  2158. incr operator($channel) 1
  2159. }
  2160. if {[info exists operator($channel)] && $operator($channel) == "[lindex [split [channel get $channel "maximal-modes"] ":"] 0]"} {
  2161. ::protection::unset:variable operator($channel)
  2162. clearqueue all
  2163. if {[info exists after($hostname:$channel)]} {
  2164. after cancel $after($hostname:$channel); unset after($hostname:$channel)
  2165. }
  2166. if {[info exists modes($hostname:$channel)]} {
  2167. unset modes($hostname:$channel)
  2168. }
  2169. if {[info exists victims($hostname:$channel)]} {
  2170. unset victims($hostname:$channel)
  2171. }
  2172. if {[info exists last(service:$channel)] && [expr [unixtime] - $last(service:$channel)] < 1} {
  2173. return
  2174. }
  2175. foreach option [split [channel get $channel "reaction-mass-mode"] ":"] {
  2176. if {[string equal -nocase "reop" $option]} {
  2177. if {![botisop $channel]} {
  2178. putquick "PRIVMSG $service :OP $channel" -next
  2179. }
  2180. } else {
  2181. if {[string equal -nocase "invite" $option] && ![botonchan $channel]} {
  2182. putquick "PRIVMSG $service :$option $channel" -next
  2183. } elseif {[string equal -nocase "unbanall" $option] && $service == "Q"} {
  2184. putquick "PRIVMSG $service :BANCLEAR $channel" -next
  2185. } else {
  2186. putquick "PRIVMSG $service :$option $channel" -next
  2187. }
  2188. }
  2189. }
  2190. set last(service:$channel) [unixtime]
  2191. return
  2192. }
  2193. }
  2194. if {[llength $victims($hostname:$channel)] >= 6} {
  2195. set delay 1
  2196. } else {
  2197. set delay 0
  2198. }
  2199. set after($hostname:$channel) [after $delay [list ::protection::mode:change:parse $nickname $hostname $handle $channel $modes($hostname:$channel) $victims($hostname:$channel)]]
  2200. }
  2201.  
  2202. proc mode:change:parse { nickname hostname handle channel modechg victim } {
  2203. global botnick botname
  2204. global modes victims after start flags
  2205. set service [join [userlist |S $channel] ","]
  2206. if {[llength $hostname] > 0} {
  2207. if {[string match "*users.quakenet.org" $hostname]} {
  2208. set banmask *!*@[lindex [split $hostname "@"] 1]
  2209. } else {
  2210. set banmask [maskhost $hostname]
  2211. }
  2212. }
  2213. if {[info exists victims($hostname:$channel)]} {
  2214. unset victims($hostname:$channel)
  2215. }
  2216. if {[info exists modes($hostname:$channel)]} {
  2217. unset modes($hostname:$channel)
  2218. }
  2219. set mode-change ""
  2220. set mode-last "+"
  2221. set mode-string "0"
  2222. set punish "0"
  2223. foreach mode [split $modechg ""] {
  2224. if {$mode == "+" || $mode == "-"} {
  2225. set mode-last $mode; continue
  2226. }
  2227. if {[lsearch -exact "o b k v" $mode] > -1 || ${mode-last} == "+" && $mode == "l"} {
  2228. lappend mode-change "${mode-last}${mode} [lindex $victim ${mode-string}]"; incr mode-string 1
  2229. } else {
  2230. lappend mode-change "${mode-last}${mode}"
  2231. }
  2232. }
  2233. set punish-methode [channel get $channel "punish-methode"]
  2234. set negativ-mode "-"
  2235. set positiv-mode "+"
  2236. set negativ-victim ""
  2237. set positiv-victim ""
  2238. set punish "0"
  2239. set reason "Don't abuse your operator privileges!"
  2240. if {${punish-methode} != "2"} {
  2241. append negativ-mode o; set negativ-victim $nickname
  2242. }
  2243. if {${punish-methode} == "3"} {
  2244. append positiv-mode b; set positiv-victim $banmask
  2245. if {[isvoice $nickname $channel]} {
  2246. append negativ-mode v; lappend negativ-victim $nickname
  2247. }
  2248. }
  2249. foreach mode ${mode-change} {
  2250. set victim [lindex $mode 1]
  2251. set mode [lindex $mode 0]
  2252. if {[string index $mode 1] == ""} {
  2253. continue
  2254. }
  2255. set total [expr [llength ${negativ-victim}] + [llength ${positiv-victim}]]
  2256. if {$total == "6" && $punish && [botonchan $channel] && [botisop $channel]} {
  2257. if {[channel get $channel "remove-flags"] != "" && ![info exists flags(removed:$hostname:$channel)]} {
  2258. putquick "PRIVMSG $service :CHANLEV $channel $nickname [channel get $channel "remove-flags"]" -next
  2259. set flags(removed:$hostname:$channel) 1
  2260. utimer 5 [list ::protection::unset:variable flags(removed:$hostname:$channel)]
  2261. }
  2262. putquick "MODE $channel ${negativ-mode}${positiv-mode} [join "${negativ-victim} ${positiv-victim}"]" -next
  2263. set negativ-mode "-"; set positiv-mode "+"; set negativ-victim ""; set positiv-victim ""
  2264. }
  2265. if {$mode == "+o" && [string equal -nocase $botnick [join $victim]]} {
  2266. continue
  2267. } elseif {$mode == "-D" && [isbotnick $nickname]} {
  2268. bind RAW -|- {355} ::protection::clear:delay
  2269. bind RAW -|- {366} ::protection::clear:delay:end
  2270. putserv "NAMES -d $channel"
  2271. } elseif {$mode == "-o" && [string equal -nocase $botnick [join $victim]]} {
  2272. if {![::protection::mode:change:abort $nickname $hostname $handle $channel]} {
  2273. set punish 1
  2274. if {![info exists last(service:$channel)] || [info exists last(service:$channel)] && [expr [unixtime] - $last(service:$channel)] > 1} {
  2275. foreach option [split [channel get $channel "reaction-need-op"] ":"] {
  2276. if {[string equal -nocase "reop" $option]} {
  2277. if {![botisop $channel]} {
  2278. putquick "PRIVMSG $service :OP $channel" -next
  2279. }
  2280. } else {
  2281. if {[string equal -nocase "invite" $option] && ![botonchan $channel]} {
  2282. putquick "PRIVMSG $service :$option $channel" -next
  2283. } elseif {[string equal -nocase "unbanall" $option] && $service == "Q"} {
  2284. putquick "PRIVMSG $service :BANCLEAR $channel" -next
  2285. } else {
  2286. putquick "PRIVMSG $service :$option $channel" -next
  2287. }
  2288. }
  2289. }
  2290. set last(service:$channel) [unixtime]
  2291. }
  2292. }
  2293. continue
  2294. } elseif {$mode == "-o" && [lsearch -exact "4 5 6 8 9 10" [::protection::user:level [nick2hand [join $victim]] $channel]] > -1} {
  2295. if {[::protection::mode:change:abort $nickname $hostname $handle $channel] == "0"} {
  2296. set punish 1
  2297. }
  2298. append positiv-mode [string index $mode 1]; lappend positiv-victim $victim; continue
  2299. } elseif {$mode == "-o" && [string equal -nocase $nickname [join $victim]]} {
  2300. continue
  2301. } elseif {$mode == "+b" && [string match -nocase $hostname [join $victim]]} {
  2302. continue
  2303. } elseif {$mode == "+o" && [lsearch -exact "4 5 6 8 9 10" [::protection::user:level [nick2hand [join $victim]] $channel]] > -1} {
  2304. continue
  2305. } elseif {[string index $mode 1] == "o" && ![channel get $channel "bitchmode"]} {
  2306. continue
  2307. } elseif {[string index $mode 1] == "o" && [channel get $channel "bitchmode"]} {
  2308. if {[::protection::mode:change:abort $nickname $hostname $handle $channel] == "1"} {
  2309. continue
  2310. }
  2311. set punish 1
  2312. if {[string index $mode 0] == "+"} {
  2313. append negativ-mode [string index $mode 1]; lappend negativ-victim $victim
  2314. }
  2315. continue
  2316. } elseif {$mode == "-v" && [lsearch -exact "3 4 5 6 7 8 9 10" [::protection::user:level [nick2hand [join $victim]] $channel]] > -1} {
  2317. if {[::protection::mode:change:abort $nickname $hostname $handle $channel] == "0" && [string match *[string index $mode 1]* [lindex [channel get $channel "protected-modes"] 1]]} {
  2318. set punish 1
  2319. }
  2320. append positiv-mode [string index $mode 1]; lappend positiv-victim $victim; continue
  2321. } elseif {$mode == "-v" && [lsearch -exact "3 4 5 6 7 8 9 10" [::protection::user:level [nick2hand [join $victim]] $channel]] < 0} {
  2322. continue
  2323. } elseif {$mode == "-b"} {
  2324. if {[::protection::mode:change:abort $nickname $hostname $handle $channel] < 1} {
  2325. foreach ban [banlist $channel] {
  2326. if {[string match -nocase [lindex $ban 0] [join $victim]]} {
  2327. set punish 1; append positiv-mode [string index $mode 1]; lappend positiv-victim $victim
  2328. }
  2329. }
  2330. foreach ban [banlist] {
  2331. if {[string match -nocase [lindex $ban 0] [join $victim]]} {
  2332. set punish 1; append positiv-mode [string index $mode 1]; lappend positiv-victim $victim
  2333. }
  2334. }
  2335. }
  2336. continue
  2337. } elseif {$mode == "+l" && $victim > [llength [chanlist $channel]]} {
  2338. continue
  2339. } elseif {[string index $mode 1] == ""} {
  2340. continue
  2341. } elseif {[string index $mode 0] == "+" && ![string match *[string index $mode 1]* [lindex [channel get $channel "protected-modes"] 0]]} {
  2342. continue
  2343. } elseif {[string index $mode 0] == "-" && ![string match *[string index $mode 1]* [lindex [channel get $channel "protected-modes"] 1]]} {
  2344. continue
  2345. }
  2346. if {[::protection::mode:change:abort $nickname $hostname $handle $channel] < 1} {
  2347. set punish 1
  2348. }
  2349. if {[string index $mode 0] == "-"} {
  2350. append positiv-mode [string index $mode 1]
  2351. if {$victim != ""} {
  2352. lappend positiv-victim $victim
  2353. }
  2354. } elseif {[string index $mode 0] == "+"} {
  2355. append negativ-mode [string index $mode 1]
  2356. if {$victim != "" && [string index $mode 1] != "l"} {
  2357. lappend negativ-victim $victim
  2358. }
  2359. }
  2360. }
  2361. if {${negativ-mode} == "-"} {
  2362. set negativ-mode ""
  2363. }
  2364. if {${positiv-mode} == "+"} {
  2365. set positiv-mode ""
  2366. }
  2367. if {$punish && ![::protection::mode:change:abort $nickname $hostname $handle $channel]} {
  2368. if {[channel get $channel "remove-flags"] != "" && ![info exists flags(removed:$hostname:$channel)]} {
  2369. putquick "PRIVMSG $service :CHANLEV $channel $nickname [channel get $channel "remove-flags"]" -next
  2370. set flags(removed:$hostname:$channel) 1
  2371. utimer 5 [list ::protection::unset:variable flags(removed:$hostname:$channel)]
  2372. }
  2373. if {${positiv-mode} != "" || ${negativ-mode} != "" && [botonchan $channel] && [botisop $channel]} {
  2374. putquick "MODE $channel ${negativ-mode}${positiv-mode} [join "${negativ-victim} ${positiv-victim}"]"
  2375. }
  2376. if {${punish-methode} > 1} {
  2377. if {[onchan $nickname $channel] && ${punish-methode} == "2"} {
  2378. putquick "KICK $channel $nickname :[string map "\":nickname:\" \"$nickname\" \":reason:\" \"$reason\" \":counter:\" \"[expr [channel get $channel "kick-id"] + 1]\"" [join [channel get $channel "kick-message"]]]"
  2379. }
  2380. if {${punish-methode} > 2} {
  2381. newchanban $channel $banmask #xela [string map "\":nickname:\" \"$nickname\" \":reason:\" \"$reason\" \":counter:\" \"[expr [channel get $channel "kick-id"] + 1]\"" [join [channel get $channel "kick-message"]]] 15
  2382. }
  2383. }
  2384. set negativ-mode "-"; set positiv-mode "+"; set negativ-victim ""; set positiv-victim ""
  2385. }
  2386. }
  2387.  
  2388. proc mode:change:abort { nickname hostname handle channel } {
  2389. if {[llength $nickname] < 1} {
  2390. return 1
  2391. } elseif {[string length $nickname] == "1"} {
  2392. return 1
  2393. } elseif {![channel get $channel "protection"]} {
  2394. return 1
  2395. } elseif {[llength $hostname] < 1} {
  2396. return 1
  2397. } elseif {[string match *.* $nickname]} {
  2398. return 1
  2399. } elseif {[lsearch -exact $::protection::settings::required(modechange) [::protection::user:level $handle $channel]] > -1} {
  2400. return 1
  2401. } elseif {[matchattr $handle b] || [islinked $handle]} {
  2402. return 1
  2403. } elseif {[isbotnick $nickname]} {
  2404. return 1
  2405. } else {
  2406. return 0
  2407. }
  2408. }
  2409.  
  2410. # --- user kick
  2411.  
  2412. proc user:kick { nickname hostname handle channel victim reason } {
  2413. global botnick botname flags kicks last
  2414. if {[::protection::mode:change:abort $nickname $hostname $handle $channel] || [string equal -nocase $victim $nickname]} {
  2415. return
  2416. }
  2417. set service [join [userlist |S $channel] ","]
  2418. if {[isbotnick $victim]} {
  2419. foreach option [split [channel get $channel "reaction-bot-kick"] ":"] {
  2420. if {[string equal -nocase "invite" $option] && ![botonchan $channel]} {
  2421. putquick "PRIVMSG $service :$option $channel" -next
  2422. } elseif {[string equal -nocase "unbanall" $option] && $service == "Q"} {
  2423. putquick "PRIVMSG $service :BANCLEAR $channel" -next
  2424. } else {
  2425. putquick "PRIVMSG $service :$option $channel" -next
  2426. }
  2427. }
  2428. }
  2429. if {![info exists kicks($channel)]} {
  2430. set kicks($channel) 1; utimer [lindex [split [channel get $channel "maximal-kicks"] ":"] 1] [list ::protection::unset:variable kicks($channel)]
  2431. } else {
  2432. incr kicks($channel) 1
  2433. if {$kicks($channel) == "[lindex [split [channel get $channel "maximal-kicks"] ":"] 0]"} {
  2434. ::protection::unset:variable kicks($channel)
  2435. set punish 1
  2436. if {![info exists last(service:$channel)] || [info exists last(service:$channel)] && [expr [unixtime] - $last(service:$channel)] > 1} {
  2437. foreach option [split [channel get $channel "reaction-mass-kick"] ":"] {
  2438. if {[string equal -nocase "reop" $option]} {
  2439. if {![botisop $channel]} {
  2440. putquick "PRIVMSG $service :OP $channel" -next
  2441. }
  2442. } else {
  2443. if {[string equal -nocase "invite" $option] && ![botonchan $channel]} {
  2444. putquick "PRIVMSG $service :$option $channel" -next
  2445. } elseif {[string equal -nocase "unbanall" $option] && $service == "Q"} {
  2446. putquick "PRIVMSG $service :BANCLEAR $channel" -next
  2447. } else {
  2448. putquick "PRIVMSG $service :$option $channel" -next
  2449. }
  2450. }
  2451. }
  2452. set last(service:$channel) [unixtime]
  2453. }
  2454. }
  2455. }
  2456. if {[matchattr [nick2hand $victim] mno|mno $channel] && [botisop $channel]} {
  2457. putserv "INVITE $victim $channel"
  2458. }
  2459. set reason "Don't abuse your operator privileges!"
  2460. if {[channel get $channel "remove-flags"] != "" && ![info exists flags(removed:$hostname:$channel)]} {
  2461. putquick "PRIVMSG $service :CHANLEV $channel $nickname [channel get $channel "remove-flags"]" -next
  2462. set flags(removed:$hostname:$channel) 1
  2463. utimer 5 [list ::protection::unset:variable flags(removed:$hostname:$channel)]
  2464. }
  2465. if {[string match "*users.quakenet.org" $hostname]} {
  2466. set banmask *!*@[lindex [split $hostname "@"] 1]
  2467. } else {
  2468. set banmask [maskhost $hostname]
  2469. }
  2470. switch -exact -- [channel get $channel "punish-methode"] {
  2471. "1" { if {![botisop $channel]} { return }; putquick "MODE $channel -o $nickname" -next }
  2472. "2" { if {![onchan $nickname $channel]} { return }; putquick "KICK $channel $nickname :[string map "\":nickname:\" \"$nickname\" \":reason:\" \"$reason\" \":counter:\" \"[expr [channel get $channel "kick-id"] + 1]\"" [join [channel get $channel "kick-message"]]]" }
  2473. "3" { newchanban $channel $banmask #xela [string map "\":nickname:\" \"$nickname\" \":reason:\" \"$reason\" \":counter:\" \"[expr [channel get $channel "kick-id"] + 1]\"" [join [channel get $channel "kick-message"]]] 15 }
  2474. }
  2475. }
  2476.  
  2477. # --- need settings
  2478.  
  2479. proc need:settings { channel need } {
  2480. set need [string tolower $need]
  2481. if {![validchan $channel] || ![channel get $channel "protection"] || [set service [join [userlist |S $channel] ","]] == ""} {
  2482. return
  2483. }
  2484. clearqueue all
  2485. putlog "\{#xela (protection v$::protection::settings::version)\} bot requires $need in $channel ($service)"
  2486. if {$need == "op"} {
  2487. putquick "PRIVMSG $service :OP $channel" -next; return
  2488. }
  2489. foreach option [split [channel get $channel "reaction-need-$need"] ":"] {
  2490. if {[string equal -nocase "reop" $option]} {
  2491. if {![botisop $channel]} {
  2492. putquick "PRIVMSG $service :OP $channel" -next
  2493. }
  2494. } else {
  2495. if {[string equal -nocase "invite" $option] && ![botonchan $channel]} {
  2496. putquick "PRIVMSG $service :$option $channel" -next
  2497. } elseif {[string equal -nocase "unbanall" $option] && $service == "Q"} {
  2498. putquick "PRIVMSG $service :BANCLEAR $channel" -next
  2499. } else {
  2500. putquick "PRIVMSG $service :$option $channel" -next
  2501. }
  2502. }
  2503. }
  2504. }
  2505.  
  2506. # --- get user level
  2507.  
  2508. proc user:level { handle channel } {
  2509. set return 0
  2510. if {![validuser $handle]} {
  2511. return $return
  2512. }
  2513. set level 0
  2514. while {$level <= 10} {
  2515. if {[info exists ::protection::settings::levels($level)] && [matchattr $handle $::protection::settings::levels($level) $channel]} {
  2516. set return $level
  2517. }
  2518. incr level 1
  2519. }
  2520. return $return
  2521. }
  2522.  
  2523. # --- incr kick counter
  2524.  
  2525. proc incr:kickcount { nickname hostname handle channel victim reason } {
  2526. global botnick
  2527. if {[isbotnick $nickname]} {
  2528. channel set $channel kick-id [expr [channel get $channel "kick-id"] + 1]
  2529. }
  2530. }
  2531.  
  2532. # --- unset variable
  2533.  
  2534. proc unset:variable { variable } {
  2535. if {![info exists ::${variable}]} {
  2536. return
  2537. }
  2538. unset ::${variable}
  2539. }
  2540.  
  2541. # --- autolimit
  2542.  
  2543. # -- set up new channel limit
  2544.  
  2545. proc auto:limit { minute hour day month year } {
  2546. foreach channel [channels] {
  2547. if {![botisop $channel] || ![regexp {[0-9]{1,}} [channel get $channel "autolimit"]]} {
  2548. continue
  2549. }
  2550. set newlimit [expr [llength [chanlist $channel]] + [channel get $channel "autolimit"]]
  2551. if {[string match *l* [lindex [getchanmode $channel] 0]]} {
  2552. regexp {\S[\s]([0-9]+)} [getchanmode $channel] -> limit
  2553. } else {
  2554. set limit 0
  2555. }
  2556. if {($newlimit == "$limit")} {
  2557. continue
  2558. }
  2559. if {$newlimit > $limit} {
  2560. set difference [expr $newlimit - $limit]
  2561. } elseif {$newlimit < $limit} {
  2562. set difference [expr $limit - $newlimit]
  2563. }
  2564. if {($difference <= [expr round([channel get $channel "autolimit"] * 0.5)]) && ([channel get $channel "autolimit"] > 5)} {
  2565. continue
  2566. } elseif {($difference < [expr round([channel get $channel "autolimit"] * 0.38)]) && ([channel get $channel "autolimit"] <= 5)} {
  2567. continue
  2568. }
  2569. pushmode $channel +l $newlimit
  2570. }
  2571. }
  2572.  
  2573. # --- set up default channel settings
  2574.  
  2575. proc missing:settings { channel } {
  2576. if {![regexp -- {[0-9]{1,}} [channel get $channel "kick-id"]]} {
  2577. channel set $channel kick-id "1"
  2578. }
  2579. if {![regexp -- {[0-9]{1,}:[0-9]{1,}} [channel get $channel "maximal-modes"]] || [lindex [split [channel get $channel "maximal-modes"] ":"] 0] > 12 || [lindex [split [channel get $channel "maximal-modes"] ":"] 0] == "0" || [lindex [split [channel get $channel "maximal-modes"] ":"] 1] == "0"} {
  2580. channel set $channel maximal-modes "6:30"
  2581. }
  2582. if {![regexp -- {[0-9]{1,}:[0-9]{1,}} [channel get $channel "maximal-kicks"]] || [lindex [split [channel get $channel "maximal-kicks"] ":"] 0] > 5 || [lindex [split [channel get $channel "maximal-kicks"] ":"] 0] == "0" || [lindex [split [channel get $channel "maximal-kicks"] ":"] 1] == "0"} {
  2583. channel set $channel maximal-kicks "3:10"
  2584. }
  2585. if {![regexp {[1-3]} [channel get $channel "punish-methode"]]} {
  2586. channel set $channel punish-methode "3"
  2587. }
  2588. if {[channel get $channel "protected-modes"] == ""} {
  2589. channel set $channel protected-modes "iksprDlb bCnNt"
  2590. }
  2591. if {[channel get $channel "chanmode"] == ""} {
  2592. channel set $channel chanmode "+CnNtu-rkspmiDd"
  2593. }
  2594. if {[channel get $channel "kick-message"] == ""} {
  2595. channel set $channel kick-message "Kicked (*.xela.development (:nickname: (:reason: (ID: :counter:))))"
  2596. }
  2597. if {![info exists ::protection::settings::author] || [info exists ::protection::settings::author] && ![string equal 1pr/X1lH0dx0oJYDZ/pNsjV.xLysJ/N77mt.ew3xD.lSY/w/ [encrypt xela $::protection::settings::author]]} {
  2598. die "WEEEE COPYRIGHT ABUSER WEE :D"
  2599. }
  2600. foreach {reaction value} [array get ::protection::settings::reactions] {
  2601. if {[channel get $channel "reaction-$reaction"] == ""} {
  2602. channel set $channel reaction-$reaction $value
  2603. }
  2604. }
  2605. }
  2606.  
  2607. }
  2608.  
  2609. # --- copyright information
  2610.  
  2611. putlog "protectio\037n\037\002:\002 v$::protection::settings::version developed by $::protection::settings::author"
  2612.  
  2613. if {![info exists ::protection::settings::author] || [info exists ::protection::settings::author] && ![string equal 1pr/X1lH0dx0oJYDZ/pNsjV.xLysJ/N77mt.ew3xD.lSY/w/ [encrypt xela $::protection::settings::author]]} {
  2614. die "Uh, Oh, Yeah, you really think you can use my script without my copyright ???? :D"
  2615. }