Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Script: News 2 HTML
- # Author: Wingman <[email protected]>
- # http://www.WINGDesign.de/
- # Update: Fixed r/w mode By DoctorD90
- # Path and name of news'files.
- set n2h(file) "news"
- # Name of news' html Title.
- set n2h(title) "NEWS"
- # What command should be used for adding news?
- set n2h(cmd) "AddNews"
- # How date should be used for adding news? (ex. Mon 01 99 at 09:00)
- set n2h(date) "%d %b %Y at %H:%M"
- # How news line should be? Use %date to insert date layout setted in previous setting; Use %user to write name; Use %news to write news' text that you add (ex. Wingman (Mon 01 99 at 01:01): this script roxx)
- set n2h(news) "%user (%date): %news"
- # What flags are authorized for using News 2 HTML? [global_flag|chan_flag]
- set n2h(cmd_flags) "o|o"
- set n2h(ver) "2.1"
- bind pub $n2h(cmd_flags) $n2h(cmd) pub:n2h
- proc n2h:addnews {hand news} {
- global n2h
- if {[file exists "${n2h(file)}.txt"]} {
- set fs [open "${n2h(file)}.txt"]
- set lines [split [read -nonewline $fs] "\n"]
- close $fs
- }
- set text [string map [list %user $hand %date [strftime $n2h(date)] %news $news] $n2h(news)]
- lappend lines $text
- set fs [open "${n2h(file)}.txt" w]
- puts $fs [join $lines "\n"]
- close $fs
- set fs [open "${n2h(file)}.html" w]
- puts $fs "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"><HTML>"
- puts $fs " <HEAD>"
- puts $fs " <META CONTENT=\"text/html; charset=ISO-8859-1\" http-equiv=\"content-type\">"
- puts $fs " <TITLE>$n2h(title)</TITLE>"
- puts $fs " </HEAD>"
- puts $fs " <BODY>"
- puts $fs [join $lines "<br>\n"]
- puts $fs " </BODY>"
- puts $fs "</HTML>"
- close $fs
- }
- proc pub:n2h { nick uhost hand chan text } {
- global n2h
- if {![llength [split $text]]} {
- putserv "PRIVMSG $nick :Usage: $n2h(cmd) <news>"
- return
- }
- n2h:addnews $hand $text
- putserv "PRIVMSG $nick :Updated news: \"$text\"."
- }
- putlog "News2Html $n2h(ver) by Wingman loaded."
Advertisement