mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2024
Posts: 5
L
lastyle Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
L
Joined: Jan 2024
Posts: 5
Hi all,

i want to Monitor a channel and save the essage written to a logfile. Channel to monitor is calles movies and i want to sae all messages that contain "german" i started with the following code but nothing happens.
what do i miss ?


; Set the channel to monitor
set #channel movies

; Set the keyword to search for
set %keyword german

on *:TEXT:*:#:%channel: {
; Check if the message contains the keyword
if ($1- iswm %keyword) {
; Log the message to a file on drive D
write D:\movies_log.txt $timestamp $+ " " $nick $+ ": " $1-
}
}

; End of script

Last edited by lastyle; 02/01/24 02:49 PM.
Joined: Jan 2012
Posts: 301
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 301
Try using this script code:
Code
on *:TEXT:*:#movies:{
  var %filepath "D:\movies_log.txt"
  if (*german* iswm $1-) {
    write -i %filepath $+($time,|,$nick,:,$chr(32),$1-)
  }
}


🕮 I also recommend you that study more closely the documentation for the methods used in this code:




Happy New Year.


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Jan 2024
Posts: 5
L
lastyle Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
L
Joined: Jan 2024
Posts: 5
Thanks, that helped me a lot.
I adjusted it a bit since i just wanted the message itself without any further information which works perfectly now.

But what i didnt figure yet, how would i save the Message only if it isnt already present in the File to prevent having duplicate entrys ?

Joined: Jan 2024
Posts: 5
L
lastyle Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
L
Joined: Jan 2024
Posts: 5
Originally Posted by lastyle
Thanks, that helped me a lot.
I adjusted it a bit since i just wanted the message itself without any further information which works perfectly now.

But what i didnt figure yet, how would i save the Message only if it isnt already present in the File to prevent having duplicate entrys ?

I Meanwhile fixed that with a python script running afterwards, but there is still one thing :-)

i want to read a line from a file and then parse the text to a channel, but mirc responds with "to many arguents" in the libe where i want to check if the file exists.

var %file = d:\leechme.txt
if ($isfile(%file)) {
var %fileHandle = $file(%file, r)
var %line = $read(%fileHandle)
.close -r %fileHandle
if (%line) {
/msg #welcomechat %line
remove %file
} else {
echo -s File is empty or an error occurred while reading.
}
} else {
echo -s File does not exist.
}

Joined: Jan 2024
Posts: 5
L
lastyle Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
L
Joined: Jan 2024
Posts: 5
Originally Posted by lastyle
Originally Posted by lastyle
Thanks, that helped me a lot.
I adjusted it a bit since i just wanted the message itself without any further information which works perfectly now.

But what i didnt figure yet, how would i save the Message only if it isnt already present in the File to prevent having duplicate entrys ?

I Meanwhile fixed that with a python script running afterwards, but there is still one thing :-)

i want to read a line from a file and then parse the text to a channel, but mirc responds with "to many arguents" in the libe where i want to check if the file exists.

var %file = d:\leechme.txt
if ($isfile(%file)) {
var %fileHandle = $file(%file, r)
var %line = $read(%fileHandle)
.close -r %fileHandle
if (%line) {
/msg #welcomechat %line
remove %file
} else {
echo -s File is empty or an error occurred while reading.
}
} else {
echo -s File does not exist.
}

Found it myself, so if somebody may need wo use that function one day...

var %file = "d:\leechme.txt"
if ($isfile(%file)) {
var %line = $read(%file)
if (%line) {
/msg #welcomechat %line
remove %file
} else {
echo -s File is empty or an error occurred while reading.
}
} else {

echo -s File does not exist.
}

Joined: Jan 2012
Posts: 301
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 301
Originally Posted by lastyle
i want to read a line from a file and then parse the text to a channel, but mirc responds with "to many arguents" in the libe where i want to check if the file exists.
To test your code I put it in an alias. Further, if I correctly understood the logic of your idea, I made some corrections and additions to the code.


Try using this snippet script code:
Code
alias fileread {
  if (!$1) { echo -a 10ERROR - Enter the line number of the file being read as the first argument. | return }
  var %file D:\leechme.txt, %line $1, %lines $lines(%file)
  if ($isfile(%file)) {
    if ($file(%file)) {
      if (%line <= %lines) var %str $read(%file,nt,%line)
      else echo -a 10ERROR - The file has fewer lines. Total: %lines
      if (%str) msg #welcomechat $+(%line,.) %str
    }
    else echo -a 10ERROR - File is empty or an error occurred while reading: %file
  }
  else echo -a 10ERROR - File does not exist: %file
}

Syntax: /fileread <number>
Example: /fileread 1


🕮 Also review the following documentation to understand where you may have made mistakes and how to correctly use some of the identifiers in this code:



🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples

Link Copied to Clipboard