mIRC Homepage
Posted By: Electrospeed A couple questions... - 15/07/14 07:53 PM
For my Twitch.tv bot, when someone joins, I want the bot to say "Hello (username)!" e.g. "Hello Electrospeed!" But, when I try to add a ! to the end of $nick, it stops working.

Also, the names of other users are not capitalized. It says "Hello electrospeed" instead of "Hello Electrospeed!" Is there any way to fix that?

Thirdly, since I'm new to this, when people say !ban (user), I want the bot to say "(user) has been banned by $nick" and since I have no idea how to do that, could somebody help? Or at least point me to somewhere I can figure it out...
Posted By: Nillen Re: A couple questions... - 16/07/14 05:04 AM
When appending something to an identifier you must use the $+ function first. $nick! wont work since this will become a totally new identifier. use $nick $+ ! which will let you evaluate $nick into the value first and then append the ! afterwards.

Your second request is not a built in feature. I suggest you create your own custom alias for this. You can simply paste this into your remote.ini and this will work wonders for you.
Code:
alias capital return $upper($left($1,1)) $+ $mid($1,2-)
Now whenever you use $nick in your messages you can use $capital($nick) and it will use the value with a capital starting letter.

As for your third request:
Code:
on *:text:!ban *:#: { 
  if ($nick !isop #) || ($me !isop #) return
  ;However you ban people I do not know. Just insert it here, probably something like " /ban # $2 " or something.
  msg # $2 was banned by $nick $+ . $iif($3,Reason: $3-,$null)
}
The first line will check for if the user writing or the bot's level in the #channel, if both aren't op then the script won't work.
The 2nd line is where you input your ban method, you probably know that better than I do.
And the 3rd line will message the channel that the target ($2) has been banned by the user ($nick) If there is anything after the target that will also be included in the message as a reason.
Posted By: BlackWhiteX Re: A couple questions... - 29/03/15 04:12 PM
I have a question regarding the capitalization of the username.

Twitch gives the possibility to capitalize various letters in a username (such as "MrBlackWhiteX" or "TNTAlchemist").

Is there a way to create an alias or somehing that allows me to output $nick in the correct Twitch capitalization?

Kind Regards
Posted By: Nillen Re: A couple questions... - 29/03/15 05:33 PM
Do you know where to pull the info from?
How does Twitch tell you that mrblackwhitex is supposed to be MrBlackWhiteX?
Posted By: Belhifet Re: A couple questions... - 29/03/15 08:24 PM
I use something that looks like this..I edited this a couple times rq because there was tons of stuff in it that wouldn't make sense to post here..but

Code:
alias twitchname {
  if ($hget(nickformat) == $null) { hmake nickformat }
  if ($hget(nickformat,$1)) { return $iif($hget(nickformat,$1) == $null,$1,$hget(nickformat,$1)) }
  var %json https://api.twitch.tv/kraken/users/ $+ $1
  JSONOpen -ud nicename %json
  hadd nickformat $1 $json(nicename,display_name)
  return $iif($hget(nickformat,$1) == $null,$1,$hget(nickformat,$1))
}


obv you will replace any messages with $nick with $twitchname($nick) or w/e the identifier for the name you want to use.
Posted By: FroggieDaFrog Re: A couple questions... - 29/03/15 11:24 PM
using this, he'll need a copy of my JSON parser

See my signature for link
© mIRC Discussion Forums