Menteroth   -  Oct 20, 2013

how can I change the $replace part to replace "mentbot" with a random nick existing in the channel?

on *:TEXT:*:#todstream: {
  write -i todstream.txt $replace($1-,mentbot,$nick)
  var %r = $rand(1,26)
  var %r2 = $rand(1,42)
  set %randomtalk %r
  set %randommatch %r2
  if (%randomtalk == %randommatch) msg #todstream $read(todstream.txt,n)
  .echo 14(00 $+ $time $+ 14) 15 todstream -- The current 00text15 variable is %randomtalk and we are looking for %randommatch 
}
Meta  -  Oct 21, 2013

$nick(#,$r(1,$nick(#,0))) will return a random nick on the channel.

Menteroth  -  Oct 21, 2013

Would it be possible to have the first letter in the nick forced to be uppercase?
And not to include mentbot as random nick? Since that is the word/nick I'm trying to replace if it's mentioned in the channel.

Thanks for the help.

Meta  -  Oct 21, 2013

Sure: $regubex($nick(#,$r(1,$nick($,0))),(\pL),$upper(\1))

Should be suitable in most cases; will match the first letter in the nick, even if it's not at the beginning, and capitalize it. (eg meta -> Meta, [123]someone[123] -> [123]Someone[123])

As for discluding mentbot, you'll need a loop. goto works well for this...

Before the line with the $replace() add:

:rnick
var %rnick $regubex($nick(#,$r(1,$nick($,0))),(\pL),$upper(\1))
if %rnick == mentbot { goto rnick }

And then just use %rnick in place of what I said to use earlier -- $replace($1-,mentbot,%rnick)

Meta  -  Oct 21, 2013

One other thing: change $read(todstream.txt) to $read(todstream.txt,n)

Normally, $read() and $readini() will attempt to evaluate identifiers and variables in the line being read, which can be a huge security concern. The n in the second parameter prevents this.

Menteroth  -  Oct 21, 2013

I tried this: $regubex($nick(#,$r(1,$nick($,0))),(\pL),$upper(\1))
but with testing it only wrote all of the text except "mentbot" in the sentence. did not even replace.

or did I get the code wrong altogether maybe? (you did mean to type $regSubex and not $regubex right? I did try both though)

write -i todstream.txt $replace($1-,mentbot,$regsubex($nick(#,$r(1,$nick($,0))),(\pL),$upper(\1)))

like if I typed "asdsdasdsas mentbot asdsdsa 2332" in the channel it only wrote "asdsdasdsas asdsdsa 2332"

I didn't add the loop yet. just wanted to try out the uppercase nick thing.

Meta  -  Oct 21, 2013

Oi, sorry. Replace the lone $ in $nick($,0) with a #

And yes, regsubex

Probably shouldn't type these things through the phone lol... much more typo-prone.

Menteroth  -  Oct 21, 2013

hehe no problem. it happens even on a computer.

thanks for all the help. it works fine now.

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.