Need Help With A Simple Twitch Bot

By Logey on Nov 23, 2014

Ok, so I have my own Twitch bot that runs in mIRC and I'm a big noob to mIRC.

All I want to do is so someone can do a command to give another user your points.
So say I did "!give Username 5", it would take 5 of my points away and give 5 points to the user, 'Username'.

It's probably really simple to do.

This is the code I have at the moment.

on !*:join:#:{
  $+(.timerpoints.,#,.,$nick) 0 300 add.pts $+(#,.,$nick)
  add.pts $+(#,.,$nick)
}
on !*:part:#:$+(.timerpoints.,#,.,$nick) off
alias -l add.pts {
  writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
}
alias -l addPoints {
  if ($1 !isnum) { echo 2 -st $1 is not a number. It needs to be a number. | halt }
  var %topic $+($chan,.,$nick)
  var %points $calc($readini(Points.ini,%topic,Points) + $1)
  writeini -n Points.ini %topic Points %points
  return %points
}
alias -l lookUpPoints {
  var %topic $+($chan,.,$nick)
  var %points $readini(Points.ini,%topic,Points)
  return %points
}
alias doaddpoints {
  if ($3 !isnum) { echo 2 -st $3 is not a number. It needs to be a number. | halt }
  var %topic $+($1,.,$2)
  var %points $calc($readini(Points.ini,%topic,Points) + $3)
  writeini -n Points.ini %topic Points %points
  echo -a Added points for %topic
}
alias dorempoints {
  var %topic $+($1,.,$2)
  remini -n Points.ini %topic Points
  echo -a Removed points for %topic
}
on *:text:!points:#:{
  if ($readini(Points.ini,$+(#,.,$nick),Points) > 0) {
    msg # /me \\ $nick $+ , you have $readini(Points.ini,$+(#,.,$nick),Points) points.
  }
  else { msg # /me \\ $nick $+ , sadly, you have no points. BibleThump }
}
on $*:text:/!points (add|remove)/Si:#:{
  if ($nick = Logey420) {
    if ($0 < 3) { msg # Insufficient parameters: Use !points <add|remove> <user> [number] | return }
    writeini -n Points.ini $+(#,.,$3) Points $calc($readini(Points.ini,$+(#,.,$3),Points) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
    { msg $chan /me \\ $3 now has $readini(Points.ini,$+(#,.,$3),Points) total points. }
  }
  else { msg $chan /me \\ You need to have special permissions to use this command. }
}

Also, it would be helpful if you explain what each part of the code does because I'm trying to get used to coding but you don't have to. I will appreciate it if you do though!

Thanks in advance!

EDIT: It also has to make it so you can't give someone a negative amount of points (so that people can't steal other people's points).

Comments

Sign in to comment.
jally511   -  Mar 04, 2015

so after 2 days of trying to figure this all out.. i finally got. however you can change all the "carrots" parts into whatever type point system you want since i use carrots for mine. this is my entire points and raffle system that i've edited to original scripts that darkestginge and afterburn1000 had provided out there.: http://pastebin.com/uhB3tZg6

Also, you can change the "feed" word to something else as well.. whatever it is that would match your points system. =) happy scripting!

 Respond  
Afterburn1000   -  Dec 01, 2014

Hey, I'm kinda new to mIRC myself however I think I can help you, I just can't hope to explain a great deal of the script to you myself.

This is also my first post on Hawkee so I don't know how to input the script as code, apologies.

I believe the script you are looking for is something along the lines of:

on :text:!Give points:#: {
if ($0 != 4) || ($4 !isnum) {
msg # Insufficient or incorrect parameters: use !Give points [user] [number]
Halt
}
if ($4 <= 0) {
msg # $nick you cannot give someone less than 1 point
halt
}
if ($readini(Points.ini,$+(#,.,$3),Points) = $null) {
msg # $nick I do not recognise that name, please check your spelling or that you have the correct name and try again.
Halt
}
else {
if ($readini(Points.ini,$+(#,.,$nick),Points) >= $4) {
writeini -n Points.ini $+(#,.,$3) Points $calc($readini(Points.ini,$+(#,.,$3),Points) + $4)
writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) - $4)
msg # $nick has given $4 of their points to $3, $3 now has $readini(Points.ini,$+(#,.,$3),Points) points.
halt
}
elseif ($readini(Points.ini,$+(,.,$nick),Points) < $4) {
msg # $nick you do not have that many points to give.
halt
}
}
}

Now I will attempt to break what each segment means, as best I can.

on :text:!Give points:#: {
if ($0 != 4) || ($4 !isnum) { If there are more or less than 4 words in the chat message and the 4th word is not a number
msg # Insufficient or incorrect parameters: use !Give points [user] [number]
Halt
}
if ($4 < 1) { if the number is less than 1
msg # $nick you cannot give someone less than 1 point
halt
}
if ($readini(Points.ini,$+(#,.,$3),Points) = $null) { If the target doesn't exist (meaning isn't in the points system)
msg # $nick I do not recognise that name, please check your spelling or that you have the correct name and try again.
Halt
}
else {
if ($readini(Points.ini,$+(#,.,$nick),Points) >= $4) { if the user has more or equal points to those they are trying to give
writeini -n Points.ini $+(#,.,$3) Points $calc($readini(Points.ini,$+(#,.,$3),Points) + $4) Adds points to the target's points balance
writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) - $4) removes points from the user's balance
msg # $nick has given $4 of their points to $3, $3 now has $readini(Points.ini,$+(#,.,$3),Points) points. displays the target's new balance
halt
}
elseif ($readini(Points.ini,$+(,.,$nick),Points) < $4) { If the user has less points than they are trying to give
msg # $nick you do not have that many points to give.
halt
}
}
}

I hope this helps. On a side note you may want to be careful who you allow to use this command, due to the possibility for someone with multiple accounts to add more points to one of their accounts.
If you definitely want to use the command you may also want to add some flood protection, I won't bother describing that as you may already know it.

Logey  -  Dec 01, 2014

Sorry but the code doesn't seem to work for me. It doesn't do anything at all when doing "!give points" or "!give points [user] [amount]".

Thank you very much for trying though. I really appreciate it!

Afterburn1000  -  Dec 01, 2014

If you get no response at all it is either an error with your copying (if so can't say I blame you with the mess in that message) or means you have another command which is "blocking" this one. Have you tried opening a different script file and putting it in there?

I have tested the code on my own bot with my points system and it worked as intended. I have tried to adapt it to your points system (only difference being mine is not channel specific)

If you want to test it out go to either my twitch twitch.tv/Afterburn1000 or my bot's twitch.tv/Burn_Bot

In the event that it is a copying error I have copied it into a pastebin http://pastebin.com/LMLqYsQV, this should make it a much simpler job of simply copy and pasting. Try it in a different script window (just hit new in the file tab of the script editor) and if you still don't get any feed back (such as one of the error messages) I can't say I know whats going on.

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.