mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2009
Posts: 4
T
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Apr 2009
Posts: 4
Hello all,

I am really hoping this is possible. I have a channel that local people can go to during a wildfire in our area to find out what is going on. Last year, we had tons of people asking questions and the channel ops had to repeat themselves over and over again. What I would like to do is provide a script that will run on mIRC on my machine that will respond to a specific word in the channel via PM with all the current information we have about a given incident. Relatively simple to accomplish this. However, what I cannot figure out is how to allow other channel ops to update this information so if I am not available and new information comes in, they can update the response. Is this possible and how?

Thanks!

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Code:
on *:text:*!command*:?:{

msg $nick Text to message nick.

}


Make !command the command they type to get the message.

Write response after "msg $nick"

Last edited by DJ_Sol; 17/04/09 03:25 AM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Adjust the settings in the "setup" part, then give it a try by typing "~news" in a query with the person running the script (and being op at the newschan) If you run the script yourself, someone else has to test it - you cannot trigger your own on text events)
Code:
; ##### 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. }
  }
}


Edit: if you manipulate the newsfile with a text editor, avoid inserting blank lines. The script will "count" blank lines, but will neither display nor play blank lines. You can "fake" blank lines of course, e.g. by using control codes as "text" for a line (a single ctrl-o is sufficient). smile

Edit2: fixed "insert"
Edit3: ...typos :X...

Final edit:
to trigger the news reply in the channel (and not only in a query with you), add:
Code:
on *:text:*:$($newschan): {
  if ($gettok($strip($1-),1,32) == $triggerword) {
    if ($lines) { .play -q10m1 $nick $qt($newsfile) $iif($delay,$v1,500) }
    else { $reply There are no news at the moment. }
  }
}
(The triggerword has to be the first word here, so ops/helpers can hint to the trigger smile )

Last edited by Horstl; 17/04/09 04:36 AM.
Joined: Apr 2009
Posts: 4
T
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Apr 2009
Posts: 4
I cannot thank you both enough for your responses. This will make things so much easier this fire season. I will try this tonight after work. THANK YOU!

Joined: Apr 2009
Posts: 4
T
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Apr 2009
Posts: 4
I just implemented it (and added the last code snippet to make it respond to the command from within channel) and it all works perfectly. On behalf of myself and all of the people that will benefit from this, THANK YOU!


Link Copied to Clipboard