I have two questions, I hope someone can help me with it
Me and my friends have a little channel, where we have a bot with a script that stores info of size and files of a release.
The script works, but the problem is if someone adds info of a release and few hours later, someone else adds the same info, it will be stored twice.
So im looking for a way, that when info is already stored of the release in the db, and someone whant to add it again, it will give someting like a announce as: Release info already stored, not adding this info.
Then my second question is I want to add a command that @ in the channel can do to delete the info in the db. Someting like !delete releasename and the whole line with that info will be deleted from the db.
Hope everyting is clear.
Here is the script i use:
Code: Select all
### config
set infodb "./infodb.txt"
set chan_(info) "#channel"
bind pub - !info echo:info
### announce style
set announce_(info) {[ INFO ] -> #releasename# -::- #section# #file#}
### addinfo
proc echo:info { nick uhost handle chan arg } {
global infodb chan_
set rl [lindex $arg 0]
if { $rl == "" } {
putserv "privmsg $chan : Usage :!info RELEASE SIZE FILE"; return 0 }
set sz [lindex $arg 1]
set fl [lindex $arg 2]
echo:infoadd INFO $fl $sz $rl INFO $chan_(info) 1
}
### announce
proc echo:infoadd { stat fl sz rl stat chan_info save } {
global infodb announce_
if { $save == "1" } {
set data [open $infodb a]
puts $data "$stat $fl $sz $rl"
close $data
putlog "$stat $fl $sz $rl added"
}
if { $stat == "INFO" } { set announce $announce_(info) }
regsub -- {#file#} $announce $fl announce
regsub -- {#section#} $announce $sz announce
regsub -- {#releasename#} $announce $rl announce
putserv "PRIVMSG $chan_info :$announce"
}