; ##### SETUP START #####
; put the name of the channel here
alias -l newschan { return #wildfire }
; put the file name of your news file if it's located in your main mirc directory, or the full path and filename if the file is located elsewhere
alias -l newsfile { return news.txt }
; put the catchword to trigger playback of the news file. All users can access this trigger in your query
alias -l triggerword { return !news }
; put the initial word ("command") for file manipulation. Only ops of the newschan can access these triggers in your query
alias -l opword { return ~news }
; put the delay for the news playback (in ms, per line)
alias -l delay { return 500 }
; ##### SETUP END #####
alias -l reply { return msg $nick }
alias -l lines { return $lines($newsfile) }
alias -l b { return $+($chr(2),$$1-,$chr(15)) }
; query text trigger
on *:text:*:?: {
; trigger for ops
if ($1 == $opword) {
; check for being ops
if ($nick isop $newschan) {
if ($2 == CLEAR) {
write -c $qt($newsfile)
$reply *** File cleared.
}
elseif ($2 == APPEND) {
if ($3) {
write $qt($newsfile) $3-
$reply *** New line appended (file has now $lines lines). The apppended line reads:
$reply $read($newsfile,n,$lines)
}
else { $reply *** No text to append. Syntax is: " $+ $opword append $b(TEXT) $+ " }
}
elseif ($2 == DELLAST) {
if ($lines($newsfile)) {
write $+(-dl,$v1) $qt($newsfile)
$reply *** Last line deleted (file has now $lines lines).
}
else { $reply *** Line cannot be deleted - file is empty. }
}
elseif ($2 == INSERT) {
var %l = $int($3)
if (%l isnum 1-) {
if ($v1 <= $lines) {
if ($4) {
write $+(-il,%l) $qt($newsfile) $4-
$reply *** New line inserted at position %l (file has now $lines lines). The inserted line reads:
$reply $read($newsfile,n,%l)
}
else { $reply *** No text to insert. Syntax is: " $+ $opword insert LINENR $b(TEXT) $+ " }
}
else { $reply *** There are only $lines lines in the file. }
}
elseif ($3) { $reply *** Syntax is: " $+ $opword insert $b(LINENR) TEXT" (LINENR is the line position of the text to insert) }
else { $reply *** Syntax is: " $+ $opword insert LINENR TEXT" (LINENR is the line position where TEXT will be inserted as new line) }
}
elseif ($2 == READ) {
if ($int($3) isnum 1-) {
if ($v1 <= $lines) {
$reply *** Line $v1 $+ :
$reply $$read($newsfile,n,$v1)
}
else { $reply *** Line $int($3) cannot be read: There are only $lines lines in the file. }
}
else { $reply *** Syntax is: " $+ $opword read $b(LINENR) $+ " (LINENR is the line number to read) }
}
elseif ($2 == DEL) {
if ($int($3) isnum 1-) {
if ($v1 <= $lines) {
write $+(-dl,$v1) $qt($newsfile)
$reply *** Line No. $v1 deleted (file has now $lines lines).
}
else { $reply *** Line $int($3) cannot be deleted: There are only $lines lines in the file. }
}
else { $reply *** Syntax is: " $+ $opword del $b(LINENR) $+ " (LINENR is the line number to delete) }
}
else {
$reply *** Commands to manipulate the newsfile for Ops of channel $newschan :
$reply " $+ $opword $b(clear) $+ " (clears the file) " $+ $opword $b(append) TEXT" (appends TEXT as new line to the file) " $+ $opword $b(dellast) $+ " (deletes the last line in the file)
$reply " $+ $opword $b(insert) LINENR TEXT" " (inserts TEXT as a new line at line position LINENR) " $+ $opword $b(read) LINENR" (reads this line) " $+ $opword $b(del) LINENR" (deletes this line)
}
}
}
; regular playback trigger (to receive the news: triggerword is somewhere in the message)
elseif ($istok($strip($1-),$triggerword,32)) {
; newsfile found: playback of the file (queued: max. 1 playback per nick, max. 10 queued playbacks in total)
if ($lines) { .play -q10m1 $nick $qt($newsfile) $iif($delay,$v1,500) }
; no newsfile
else { $reply There are no news at the moment. }
}
}