mIRC Homepage
Posted By: Micahnameistaken Another on *:text:*:#channel: { - 11/01/08 05:54 PM
Hey.
Do you know how I could make a script pick out a specific word from a sentence that was written and reply to it?

In the following example, I want the word "coffee" to be in focus, if someone types a sentence, like: "Where is my coffee?"
Code:
on *:text:*:#mychannel: {
  if ($1- == coffee) {
    msg $chan $read(C:\Program Files\mIRC\coffee.txt)
  }
}

Got this so far...

Thanks.
Posted By: MrX Re: Another on *:text:*:#channel: { - 11/01/08 06:33 PM
Code:
on *:text:Coffee:*: {
    msg $chan $read(C:\Program Files\mIRC\coffee.txt)
}


That code wil work on any chanel with the word Coffee
Posted By: Micahnameistaken Re: Another on *:text:*:#channel: { - 11/01/08 06:37 PM
Oh... That easy, eh? Thanks a bunch!

Also: How can I make a script reply on text, but _ONLY_ when I am using a certain nick. Is that possible?

For example, I want a script that responds when someone says my nick, but only when I have a certain nick...

Get it? :S
Posted By: sparta Re: Another on *:text:*:#channel: { - 11/01/08 07:11 PM
When you have a nick: if ($me == YourNick) { do stuff }

if someone else need to have a nick you want to trigger on:

if ($nick == UsersNick) { do stuff }

Code:
on *:text:Coffee:*: {
   if ($me == YourNick) { msg $chan $read(C:\Program Files\mIRC\coffee.txt) }
}

on *:text:Coffee:*: {
   if ($nick == UsersNick) { msg $chan $read(C:\Program Files\mIRC\coffee.txt) }
}
Posted By: Micahnameistaken Re: Another on *:text:*:#channel: { - 11/01/08 07:15 PM
Awesome. Thanks a lot guys. smile
Posted By: MrX Re: Another on *:text:*:#channel: { - 11/01/08 07:20 PM
Originally Posted By: MrX
Code:
on *:text:Coffee:*: {
    msg $chan $read(C:\Program Files\mIRC\coffee.txt)
}


That code wil work on any chanel with the word Coffee


btw about that "easy" script, read this:

* matches any TEXT (not possable in this script)

& matches any WORD (not possable in this script)

Coffee matches if text contains only this word

Coffee* matches if text starts with this word

*Coffee matches if text ends with this word

*Coffee* matches if text contains this word anywhere
Posted By: Micahnameistaken Re: Another on *:text:*:#channel: { - 11/01/08 07:30 PM
Thanks, I'm saving that for later use!


I hate to keep asking, but I'm wondering about one more thing, partly unrelated.

Say if I wanted to have (as an example) 3 words to trigger a message reply?

I.e. If a sentence contained these 3 words:
Quote:
Micah, program, ink

Example sentence:
Quote:
Micah, which program do you use to ink your pictures?


As an example reply, I'd like to automatically say
Quote:
Hey "nick", I use MSPaint for that.


How would that look? laugh
Posted By: MrX Re: Another on *:text:*:#channel: { - 11/01/08 07:35 PM
ehm,

If its exacly the same text it could be

Code:
on *:TEXT:Micah, which program do you use to ink your pictures?:*: {
Msg $chan Hey $nick $+ , I use MSPaint for that.
}
Posted By: Micahnameistaken Re: Another on *:text:*:#channel: { - 11/01/08 07:55 PM
Yes, well, there is no way I would know how they spell it. They could use spelling errors and so on, which is why I want the script to only catch certain words.
Posted By: Riamus2 Re: Another on *:text:*:#channel: { - 11/01/08 09:27 PM
Do this:

Code:
on *:text:*:#: {
  if (Micah isin $1- && program isin $1- && ink isin $1-) { msg $chan $read(filename.txt) }
  elseif (coffee isin $1-) { msg $chan $read(filename.txt) }
}


Just continue adding things using the format in the ELSEIF line. Use && as shown in the IF line to check for multiple words that aren't necessarily in the same order. Use || to check for any word, but not necessarily all words (it means OR).

As a note, using isin may cause you some issues if you use smaller words that may be part of larger words... for example, you may want the word "ink" but not "link". You can do various things to get around that, but they will be more complicated. It depends on how important that is to you. To get around it, you'd be needing to use $istok() and probably also $remove() to remove punctuation when checking.
Posted By: MrX Re: Another on *:text:*:#channel: { - 12/01/08 12:02 PM
Code:
on *:text:*:#: {
  if (Micah isin $1- && program isin $1- && ink isin $1-) { msg $chan $read(filename.txt) }
  elseif (coffee isin $1-) { msg $chan $read(filename.txt) }
}


I suggest doing it without that $read
example:
Code:
on *:text:*:#: {
  if (Micah isin $1- && program isin $1- && ink isin $1-) { msg $chan I use MSpaint for that }
  elseif (coffee isin $1-) { msg $chan Gimme my Coffee }
}
Posted By: Micahnameistaken Re: Another on *:text:*:#channel: { - 12/01/08 01:26 PM
Thanks a lot... Never met anyone so helpful before. Highly, highly appreciated!

The short-words issue isn't important to me at all, as I'll probably just find another word combination that fits better. I got it all running and working now and it really does make life easier when you don't have to explain things multiple times. But this requires me to make multiple *.txt files, is there a way to make it use lines in a *.txt file? If the script is complicated, that's quite alright. I can always just stuff them into a folder for sorting purposes.

So, eh... I guess you wouldn't happen to know the code for a rather long and complicated seen script?

Seriously, I know this question is like pretty insane, but anyway here's the general layout on what I has on my mind. I'm not that into coding, so I'll use words out of context.

on ".seen WORD" (The seen script idea), reply with: WORD was last seen [RANDOM generated sentence from a list.]

Example:
SomeGuy: .seen Pikachu
Micah: Pikachu was last seen (Start) being eaten by Raptorjesus.

Where "being eaten by Raptorjesus" is on, for example, line 31 in a txt file. Is this possible at all? shocked I'll gladly make a new topic about it if that suits you better, _IF_ you know how to help.

Thanks again, sorry to ask so much. This one is only for a funny purpose, so it's not important. smile
Posted By: MrX Re: Another on *:text:*:#channel: { - 12/01/08 01:39 PM
Reading this already give me headache but i wil try -_-o

Edit:
This must be a Write and read file
that can get larger then your computer is ready for...

Btw. it would bug your whole pc...

SO no i'm not gonna make before MY pc crashes...
Posted By: Micahnameistaken Re: Another on *:text:*:#channel: { - 12/01/08 04:49 PM
No, it should not be _A_ seen script. But it should only _READ_ randomly from the *.txt that I have pre-made... but yet react from a .seen command, so it would appear as a seen scrip, except that it doesn't display what the user thinks.
Posted By: DJ_Sol Re: Another on *:text:*:#channel: { - 12/01/08 07:18 PM
I wasn't sure if RaptorJesus was a randomly chosen nick from the nicklist or text in a text file.
Code:
on *:text:.seen &:#:{
if (%seen. [ $+ [ $nick ] ]) { return }
msg $chan $2 was last seen $read(text.txt)
set -u5 %seen. [ $+ [ $nick ] ] $true
}


Reading it, it looks like text in your text file. I personally think its fun to pick a nickname at random from the nicklist and use it in the joke.

msg $chan was last seen $read(text.txt) at $nick($chan,$rand(1,$nick($chan,0)) $+ 's house!
Posted By: Riamus2 Re: Another on *:text:*:#channel: { - 13/01/08 01:01 AM
Originally Posted By: MrX
I suggest doing it without that $read


Unless he only wants a single possible response to a given word combination, $read is how to do it as it will read a random line that relates to the given words, which is what the OP's original post seems to indicate. Obviously, if there's always one single response, there's no reason to use $read. smile

Originally Posted By: MrX
This must be a Write and read file
that can get larger then your computer is ready for...

Btw. it would bug your whole pc...

It wouldn't if you "trim" your results automatically.
Posted By: Riamus2 Re: Another on *:text:*:#channel: { - 13/01/08 01:15 AM
Originally Posted By: Micahnameistaken
But this requires me to make multiple *.txt files, is there a way to make it use lines in a *.txt file? If the script is complicated, that's quite alright. I can always just stuff them into a folder for sorting purposes.


One possible method would be to use an INI file with everything in it...

Code:
on *:text:*:#: {
  if (Micah isin $1- && program isin $1- && ink isin $1-) {
    var %r = $rand(1,$ini(replies.ini,topic1,0))
    msg $chan $readini(replies.ini,topic1,%r)
  }
  elseif (coffee isin $1-) {
    var %r = $rand(1,$ini(replies.ini,topic2,0))
    msg $chan $readini(replies.ini,topic2,%r)
  }
}


Repeat the ELSEIF section as needed, changing only the comparison and the topic name (i.e. topic2). Note that the topic names can be anything you like... I just used "topic1" and "topic2" as generic topic names. Make them fit whatever your matchtext is. Now, your INI file would look like this:
Quote:

replies.ini
[topic1]
1=Reply 1
2=Reply 2
3=Reply 3
[topic2]
1=Reply 1
2=Reply 2
3=Reply 3


And so on. Make sure to number the lines in the topic from 1 to whatever number of replies there are in each topic or you'll run into problems. It will randomly read one of the items in the chosen topic. Remember that if you only need a single reply to a given matchtext, you can always just put that in the msg line without using $read or $readini. These methods are only if you want to have more than one possible response for variety.

Originally Posted By: Micahnameistaken

So, eh... I guess you wouldn't happen to know the code for a rather long and complicated seen script?

Seriously, I know this question is like pretty insane, but anyway here's the general layout on what I has on my mind. I'm not that into coding, so I'll use words out of context.

on ".seen WORD" (The seen script idea), reply with: WORD was last seen [RANDOM generated sentence from a list.]

Example:
SomeGuy: .seen Pikachu
Micah: Pikachu was last seen (Start) being eaten by Raptorjesus.

Where "being eaten by Raptorjesus" is on, for example, line 31 in a txt file. Is this possible at all? shocked I'll gladly make a new topic about it if that suits you better, _IF_ you know how to help.

Thanks again, sorry to ask so much. This one is only for a funny purpose, so it's not important. smile


As far as this goes, if you just want to use a specific list of responses for a specific list of words, you can do the same thing as the script above. Just put .seen* in the matchtext on the on TEXT line instead of just *. Remember to put it in a separate script file to avoid conflicts between multiple on TEXT events. Technically, you could put the .seen one at the top of the script file, but separate is easier. smile

If you want to capture text from within the channel and use it in this way, you'll want to either use your logs or else write the lines of text (all or just random lines) into a file and then use $read with the "w" option for wildcard matching to find lines that include the word(s) that you want to find. That would not be an easy script to make, and I don't think that's what you wanted anyhow, based on what you wrote.

In either case, you can use DJ_Sol's suggestion for including random nicks in this script if desired as well. Just include the $nick(...) part in the msg line in this script to include a random nick from the channel. (Just add one more closing parentheses in it that was missed... see below). And, if you only want the nicks to be Regular users (those who aren't voiced/opped/etc), adjust it to be:

$nick($chan,$rand(1,$nick($chan,0,r)),r)

"r" is for Regulat only (notice it's there twice).

To include voices, use "v". For ops, use "o". You can also combine multiple such as "rv". (No quotes, of course). Leaving out the letter as shown below will randomly select a nick out of everyone in the channel.

$nick($chan,$rand(1,$nick($chan,0)))
Posted By: Micahnameistaken Re: Another on *:text:*:#channel: { - 13/01/08 12:25 PM
Okay, I read it all over about three times and I'm still a tad confused... I'm not sure my words got through the way I hoped. I'll try to explain once more just in case.

When someone says .seen <NICK> (The nick is the only thing the script should capture from the channel, the rest of the text is randomly selected from an already made list.)

Code:
[07:06:58] User: .seen Tommy
[07:06:58] Me: Tommy was last seen dancing with Night Elves.
[07:07:05] User: .seen Tommy
[07:07:05] Me: Tommy is invisible at the moment, shhh...


As you can see, the user did the same command, but from my premade list, it would pick a random line.

Sort of like a "!quote" script, except that it should remember the nick after .seen

I added a timestamp, but its not relevant.
Posted By: OrionsBelt Re: Another on *:text:*:#channel: { - 13/01/08 01:33 PM
Code:
on *:text:.seen *:#:{
 msg $chan $2 $read(filename.txt)
}

Whenever someone types .seen with a word/nick behind it,
this will respond to the channel: /msg $chan
then add the word/nick behind the .seen command: $2
and add a random line from your premade list: $read(filename.txt)
Posted By: DJ_Sol Re: Another on *:text:*:#channel: { - 13/01/08 06:50 PM
Sorry I wasn't clear.

Code:
on *:text:.seen &:#:{
if (%seen. [ $+ [ $nick ] ]) { return }

msg $chan $2 was last seen $read(text.txt)

set -u5 %seen. [ $+ [ $nick ] ] $true
}


I included flood protection which I think is mandatory for any text response.

I chose to use ".seen &" because & matches any word. So this will only be $true if $1 == .seen and $2 exists, but $3- doesn't.

.seen * means it will respond if someone puts anything behind .seen. Like: .seen nickname more text following.

You could also check if the nickname is on the channel as well.

Quote:
if ($2 ison $chan) { msg $chan $2 was last seen $read(text.txt) }


I hope this helps.
Posted By: Micahnameistaken Re: Another on *:text:*:#channel: { - 13/01/08 08:53 PM
Yep, helps more than I could ever have asked for. Thanks again! smile
Posted By: Micahnameistaken Re: Another on *:text:*:#channel: { - 15/01/08 07:35 PM
Originally Posted By: DJ_Sol
Code:
on *:text:.seen &:#:{
if (%seen. [ $+ [ $nick ] ]) { return }

msg $chan $2 was last seen $read(text.txt)

set -u5 %seen. [ $+ [ $nick ] ] $true
}


I included flood protection which I think is mandatory for any text response.

Is there away I can use that flood protection for other than my seen script? shocked I don't understand all the variables and triggers and such, unfortunately.

Example
Code:
On *:text:!random:#: {
  msg $chan $read(random.txt)
}

How could I put a flood protection on that? (Sorry, you guys got me hooked on these scripts now!)

EDIT: ... and I am really sorry about the doubble post. -_-!
Posted By: DJ_Sol Re: Another on *:text:*:#channel: { - 15/01/08 08:00 PM
Look here.

https://forums.mirc.com/ubbthreads.php?ub...true#Post187299
Posted By: Micahnameistaken Re: Another on *:text:*:#channel: { - 15/01/08 08:14 PM
Thanks again. wink *Stops bothering you now*
© mIRC Discussion Forums