Code: Select all
bind pub - %shitlist [censored]:list
proc [censored]:list {nick host hand chan text} {
set cmd [lindex [split $text] 0]
set rest [lindex [split $text] 1]
set reason [lindex [range [split $text] 2 end]]
switch -exact -- [string tolower $cmd] {
"add" {
if {![matchattr $hand ahnmM]} {
putserv "PRIVMSG $nick :Shitlist: You do not have access to add a channel to the shitlist."
} elseif {[matchattr $hand ahnmM]} {
if {($rest == "")} {
putserv "PRIVMSG $nick :Shitlist: Please enter a channel name to add to the shitlist."
} elseif {($rest != "") && ![string match "#*" $rest]} {
putserv "PRIVMSG $nick :Shitlist: Please enter a channel begining with #.
} elseif {($rest != "") && [string match "#*" $rest]} {
if {($reason == "")} {
set $reason No reason added...
putserv "PRIVMSG $nick :Shitlist: Adding $rest to Shitlist with the reason: $reason."
} else {
putserv "PRIVMSG $nick :Shitlist: Adding $rest to Shitlist with the reason: $reason."
}
set fp [open shitlist.db a]
put $fp $rest $reason added by $nick
close $fp
putserv "PRIVMSG $nick :Shitlist: $text now added to Shitlist."
putlog "$nick added $text to the shitlist with the reason: $reason."
}
}
"del" {
if {![matchattr $hand ahnmM]} {
putserv "PRIVMSG $nick :Shitlist: You do not have access to delete a channel from the shitlist."
} elseif {[matchattr $hand ahnmM]} {
if {($rest == "")} {
putserv "PRIVMSG $nick :Shitlist: Please enter a channel name to delete from the shitlist."
} elseif {($rest != "") && ![string match "#*" $rest]} {
putserv "PRIVMSG $nick :Shitlist: Please enter a channel begining with #.
} elseif {($rest != "") && [string match "#*" $rest]} {
set fp [open shitlist.db r]
set data [read -nonewline $fp]
close $fp
set lines [split $data "\n"]
if {![string match "$rest" $lines]} {
putserv "PRIVMSG $nick :Shitlist: $rest is not in the shitlist."
} elseif {[string match "$rest" $lines]} {
putserv "PRIVMSG $nick :Shitlist: Deleting $rest from the shitlist."
}
set fp [open shitlist.db r]
set data [read -nonewline $fp]
close $fp
set lines [split $date "\n"]
if {[string match "$rest" $lines]} {
set delline line number
set lines [lreplace $lines $delline $delline]
set fp [open shitlist.db "w"]
puts $fp [join $lines "\n"]
close $fp
putserv "PRIVMSG $nick :Shitlist: $text is now deleted from the shitlist."
putlog "$nick deleted $text from the shitlist."
}
}
}
}
"list" {
if {![matchattr $hand ahnmM]} {
putserv "PRIVMSG $nick :Shitlist: You do not have access to dump the shitlist."
} elseif {[matchattr $hand ahnmM]} {
set fp [open shitlist.db r]
set data [read -nonewline $fp]
close $fp
putserv "PRIVMSG $nick :Shitlist: Channel Reason."
foreach shitchan [split $data "\n"] {
putserv "PRIVMSG $nick : [lindex [split $text] 0] [lindex [lrange [split $text] 1 end]]
}
putserv "PRIVMSG $nick :Shitlist: End of shitlist channel list."
}
}
"default" {
if {![matchattr $hand ahnmM]} {
putserv "PRIVMSG $nick :Shitlist: You do not have access to any of the shitlist commands."
} else {
putserv "PRIVMSG $nick :Shitlist: Shitlist Commands:-."
putserv "PRIVMSG $nick :Shitlist: \[\] = optional
putserv "PRIVMSG $nick :Shitlist: %shitlist add #channel [reason]."
putserv "PRIVMSG $nick :Shitlist: %shitlist del #channel."
putserv "PRIVMSG $nick :Shitlist: %shitlist list - lists all channels added to the shitlist."
}
}
}
}
Code: Select all
"del" {
if {![matchattr $hand ahnmM]} {
putserv "PRIVMSG $nick :Shitlist: You do not have access to delete a channel from the shitlist."
} elseif {[matchattr $hand ahnmM]} {
if {($rest == "")} {
putserv "PRIVMSG $nick :Shitlist: Please enter a channel name to delete from the shitlist."
} elseif {($rest != "") && ![string match "#*" $rest]} {
putserv "PRIVMSG $nick :Shitlist: Please enter a channel begining with #.
} elseif {($rest != "") && [string match "#*" $rest]} {
set fp [open shitlist.db r]
set data [read -nonewline $fp]
close $fp
set lines [split $data "\n"]
if {![string match "$rest" $lines]} {
putserv "PRIVMSG $nick :Shitlist: $rest is not in the shitlist."
} elseif {[string match "$rest" $lines]} {
putserv "PRIVMSG $nick :Shitlist: Deleting $rest from the shitlist."
}
set fp [open shitlist.db r]
set data [read -nonewline $fp]
close $fp
set lines [split $date "\n"]
if {[string match "$rest" $lines]} {
set delline line number
set lines [lreplace $lines $delline $delline]
set fp [open shitlist.db "w"]
puts $fp [join $lines "\n"]
close $fp
putserv "PRIVMSG $nick :Shitlist: $text is now deleted from the shitlist."
putlog "$nick deleted $text from the shitlist."
}
}
}
}
Code: Select all
set delline line number
Thanks in advance!!