mIRC Home    About    Download    Register    News    Help

Print Thread
#244934 06/04/14 07:27 AM
Joined: Mar 2014
Posts: 215
J
Fjord artisan
OP Offline
Fjord artisan
J
Joined: Mar 2014
Posts: 215
I am trying to add a few commands to my twitch chat bot, !command add* and !command remove*
I have made a little text command for add that writes to my current remote file
Code:
on *:TEXT:!command add*:#: {
Write remote.ini on *:TEXT:$$3:#: { msg # $$4 $$5 $$6 $$7 $$8 $$9 $$10 $$11 $$12 $$13 $$14 $$15 }
 { msg # $$3 added to commands! }
}
but when it writes it the $$3 (and above) is in plain text, not capturing the words. I'm probably doing something terribly wrong. please give support on how to fix it smile
Also have no idea on how to make a remove script.


#imAbeginner
i made a chat bot for mark_paintball! http://twitch.tv/mark_paintball
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358

Joined: Mar 2014
Posts: 215
J
Fjord artisan
OP Offline
Fjord artisan
J
Joined: Mar 2014
Posts: 215
Ok thanks, sorry for this duplicate thread then


#imAbeginner
i made a chat bot for mark_paintball! http://twitch.tv/mark_paintball
Joined: Mar 2014
Posts: 215
J
Fjord artisan
OP Offline
Fjord artisan
J
Joined: Mar 2014
Posts: 215

any way it can be in this format and basically counteract this code?
Code:
on *:TEXT:!reg add*:#: {
  if ($nick !isop #) {
    write reglist.txt $$3
    msg $chan $$3 has been added to the regular list! 
  }
  if ($nick == TheYoungerGamer ) {
    write reglist.txt $$3
    msg $chan $$3 has been added to the regular list!
  }
}


#imAbeginner
i made a chat bot for mark_paintball! http://twitch.tv/mark_paintball
Joined: Mar 2014
Posts: 215
J
Fjord artisan
OP Offline
Fjord artisan
J
Joined: Mar 2014
Posts: 215
Originally Posted By: judge2020

any way it can be in this format and basically counteract this code?
Code:
on *:TEXT:!reg add*:#: {
  if ($nick !isop #) {
    write reglist.txt $$3
    msg $chan $$3 has been added to the regular list! 
  }
  if ($nick == TheYoungerGamer ) {
    write reglist.txt $$3
    msg $chan $$3 has been added to the regular list!
  }
}

let me explain it a little better:

I would like there to be a !reg del [name] command, basically removing their name from my text file.
Code:
on *:TEXT:!reg add*:#: {
  if ($nick isop #) {
    write reglist.txt $$3
    msg $chan $$3 has been added to the regular list! 
  }
}
}

I would just like to know what code would i replace with the write line to get it to erase that name.


#imAbeginner
i made a chat bot for mark_paintball! http://twitch.tv/mark_paintball
Joined: Feb 2014
Posts: 10
I
Pikka bird
Offline
Pikka bird
I
Joined: Feb 2014
Posts: 10
as far as I'm aware it's hard to get lines with a normal file.
you could ofcourse append the $nick by writing:
write FILE.txt NICK $calc( $lines(FILE.txt) + 1)
this way it'll write nick 1 nick 2 nick 3 etc.
then if you do a $read(NICK) it'll return the number.
you can then write -dl $read(NICK) to remove the line


however I'd advice you to do with with ini files.
writeini and remini are way easier to use IMO.


(PS: I think it's somehow possible with $readall, however I'm not sure how this works, as you need to ender $readall(file,NICK,CHAR), where char is the chars that have to be before or after the nick. (which would be 'enter' I guess.))

Last edited by iFort; 07/04/14 04:21 PM.
Joined: Mar 2014
Posts: 215
J
Fjord artisan
OP Offline
Fjord artisan
J
Joined: Mar 2014
Posts: 215
so making it an ini file will work better? Would the code presented before work if i did this?


#imAbeginner
i made a chat bot for mark_paintball! http://twitch.tv/mark_paintball
Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Code:
if ($read(reglist.txt,nw,$3)) write -dl $+ $readn reglist.txt 


It's amazing how much info you can obtain from reading the help files.
Quote:

/write [-cidna l# s# w# r#] <filename> [text]

Writes lines to a text file. For example:



/write store.txt This line will be appended to the end of file store.txt



The -c switch clears the file completely before writing to it, so it allows you to start with a clean slate.



/write -c c:\info.txt This file will be erased and have this line written to it



The -l# switch specifies the line number where the text is to be written.



/write -l5 c:\info.txt This line will overwrite the 5th line in the file



The -i switch indicates that the text should be inserted at the specified line instead of overwriting it. If you do not specify any text then a blank line is inserted. If you do not specify a line number then a blank line is added to the end of the file.



/write -il5 c:\info.txt This line will be inserted at the 5th line in the file



The -d switch deletes a line in the file. If you do not specify a line number then the last line in the file is deleted.



/write -dl5 c:\info.txt



The above command will delete the 5th line in the file.



The -s# switch scans a file for the line beginning with the specified text and performs the operation on that line.



/write -dstest c:\info.txt



This will scan file info.txt for a line beginning with the word "test" and if found, deletes it.



If you do not specify any switches then the text is just added to the end of the file.



The -w# switch scans a file for the line containing the specified wildcard text and performs the operation on that line. The -r# switch implies a regex match.



Note: With both -s# and -w# you can enclose the scan text in quotes if it contains spaces.



The -a switch indicates that mIRC should append the line of text you specified to the existing text of the specified line.



The -n switch prevents it from adding a $crlf to the end of the text.



Note: You cannot use this command to write to an INI file. If you do so, you will most likely corrupt the INI file.



Quote:

$readn

Returns the line number that was matched in a previous call to $read(). If no match was found, $readn is set to zero.



Last edited by Nillen; 07/04/14 06:14 PM. Reason: Forgot the $readn quote

Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Apr 2014
Posts: 33
B
Ameglian cow
Offline
Ameglian cow
B
Joined: Apr 2014
Posts: 33
See the dynamic commands script I posted today.


Link Copied to Clipboard