Code: Select all
bind pub - !status proc_status
proc proc_status { ircnick userhost handle channel arg } {
set status "$arg"
if {$status == ""} {
puthelp "PRIVMSG $ircnick :Please supply your status"
return 0
}
set fs [open "/srv/httpd/htdocs/status.txt" r]
set tmpfs [open "/srv/httpd/htdocs/tmpstatus.txt" w]
set change 0
while {![eof $fs]} {
if {![gets $fs line]} {
puts -nonewline $tmpfs "$line\n"
} elseif {[lindex $line 1] == $ircnick} {
puts -nonewline $tmpfs "[unixtime] $ircnick $status\n"
set change 1
}
}
if {!$change} {
puts -nonewline $tmpfs "[unixtime] $ircnick $status"
puthelp "PRIVMSG $ircnick : Your status has been added."
} else {
puthelp "PRIVMSG $ircnick : Your status has been updated."
}
close $fs
close $tmpfs
set tmpfs [open "/srv/httpd/htdocs/tmpstatus.txt" r]
set statusdb "[read $tmpfs]"
close $tmpfs
set fs [open "/srv/httpd/htdocs/status.txt" w]
puts -nonewline $fs "$statusdb"
close $fs
return 0
}