mIRC Homepage
Posted By: Sparkz Bot reading/identifying mods - 09/11/14 12:49 AM
I am currently trying to make a twitch chat bot but there are some issues. There is a problem with [if ($nick isop #)] For that to work, mirc needs to refresh (only does it every minute or so) So if a mod join and tries something straight away, it wont work. Is there a script I can use that reads a file and if a mods name is in the file, it allows them to use it. Thank you.
Posted By: Nillen Re: Bot reading/identifying mods - 09/11/14 01:01 AM
Code:
alias -l mod {
var %file mods.ini, %nick $iif($1 == add,$2,$1)
if ($1 == add) if (!$readini(%file,#,%nick)) writeini %file # %nick 1
else return $iif(($readini(%file,#,%nick) || (%nick isop #)),1)
}
on *:op:#: mod add $nick
on *:text:*:#: mod add $nick

In your scripts you can now use
Code:
on *:text:!test:#: { 
;if ($mod($nick)) { do stuff }
;else { don't do stuff }
}
Posted By: Bramzee Re: Bot reading/identifying mods - 09/11/14 07:35 AM
This isn't working for me.

I put the alias into a new remote then did

on *:text:!test:#: {
if ($mod($nick)) { msg # yes }
else { msg # no }
}

It keeps returning no. And anything I put "if ($mod($nick))" on doesn't work.
Posted By: Nillen Re: Bot reading/identifying mods - 09/11/14 09:57 AM
Try removing the "-l" from the alias. What I can think of is that your events aren't being called from the same scriptfile.
Sorry, that was my miss.
Posted By: Bramzee Re: Bot reading/identifying mods - 09/11/14 03:12 PM
That worked smile Thanks Nillen.
Posted By: Nillen Re: Bot reading/identifying mods - 09/11/14 03:20 PM
Btw, I just realized when I checked this that there was no check at all for if nick was op to add him to the ini originally in the text event.
Replace what you have with this, and you should probably delete the ini file you have right now, considering that it has everyone who's written in the channel added to it currently.
You can simply type: /remove mods.ini
Code:
alias mod {
var %file mods.ini, %nick $iif($1 == add,$2,$1)
if ($1 == add) if (!$readini(%file,#,%nick)) writeini %file # %nick 1
else return $iif(($readini(%file,#,%nick) || (%nick isop #)),1)
}
on *:op:#: mod add $nick
on *:text:*:#: if ($nick isop #) mod add $nick
Posted By: Bramzee Re: Bot reading/identifying mods - 09/11/14 05:11 PM
Done. Thanks again smile

Quick question though, is my username supposed to be the only one in the ini file?

[#myname]
myname=1


^^that's how it looks.

It's still saying other's are mods when I check them using a quick !ismod* command after they join/type but they're not showing up in the file itself. Guess it's not a big deal since either way it's working. Just curious as to why that would be.
Posted By: Nillen Re: Bot reading/identifying mods - 09/11/14 05:41 PM
They should get added to the ini file as soon as their either say something in the channel or if they get opped in the channel. Until either of those happen, they won't be in the list. But they will still be counted in in the $mod($nick) since it checks for either in the inifile or as an op in the channel for just this kind of situation.
© mIRC Discussion Forums