|
|
|
Joined: Dec 2014
Posts: 3
Self-satisified door
|
OP
Self-satisified door
Joined: Dec 2014
Posts: 3 |
I'm trying to make a Twitch bot but I don't really know much about programming. I'm confused on most of these things, so help would be much appreciated. One of the things that I want to do is prevent emote spam. This website has 2 JSONs, one of them for global Twitch emotes and another for subscriber emotes. How can I integrate these into a script so that when there are >=5 of these in a message, the user will be timed out? I also found this, but I don't know how to use it either and I'm not sure if it will help. I also want to do an !uptime command which will make the bot say how long the stream has been running. I could do a timer that I start/stop manually, but that's slightly annoying. Is there an automatic way to do it? The Twitch API has a "created_at" parameter for streams, but I'm not sure if that's related to the uptime or not. Lastly, how can I do prevention of spammed letters/symbols? For example, if I type something like "Hhhhjvugggyuvghgjghghvghgghhygfgghggg" into chat, the bot would time me out because of repeated letters. Likewise, if I spam too many symbols (anything that isn't A-Z or 0-9), I would also be timed out. I don't have much of a clue on this one because I'm not experienced at all... Sorry for the very open-endedness of this question. Any help would be very appreciated, though.
|
|
|
|
Joined: Sep 2014
Posts: 259
Fjord artisan
|
Fjord artisan
Joined: Sep 2014
Posts: 259 |
I use this for uptime (credit to Nillen, I just changed minor things). You can delete the first 3 lines if you don't want flood protection. Usage: "!uptime" or "!uptime <Streamer Name>"
on *:text:!uptime*:#:{
if ((%flooduptime) || ($($+(%,flooduptime.,$nick),2))) { return }
set -u5 %flooduptime On
set -u10 %flooduptime. $+ $nick On
if (!$2) { set %target $remove($chan,$chr(35))
else set %target $iif($2,$2,$mid(#,2-))
set %channel #
uptime
}
alias uptime {
sockclose uptime
sockopen uptime nightdev.com 80
}
on *:sockopen:uptime:{
if ($sockerr) { sockclose $sockname | halt }
sockwrite -n $sockname GET /hosted/uptime.php?channel= $+ %target HTTP/1.1
sockwrite -n $sockname Host: www.nightdev.com
sockwrite -n $sockname $crlf
}
on *:sockread:uptime:{
if ($sockerr) { sockclose $sockname | halt }
var %data
sockread %data
tokenize 32 %data
if ($1 isnum) && ($2) { msg %channel %target has been online for $1- }
elseif (%data == The channel is not live.) msg %channel %target is currently not online.
}
on *:sockclose:uptime:{
unset %channel
unset %target
}
Twitch emotes are just plain text in mIRC, so no need for anything crazy. There are probably better ways of doing it, but this is what I came up with. It times people out for using 5 or more emotes. I only listed a few of the emotes, you will need to add the rest on *:LOAD:{
/set %Bannword Kappa FrankerZ DansGame
}
ON @*:TEXT:*:#: {
if ($nick !isop #) {
set %Badword. [ $+ [ $nick ] ] 0
var %i = 0
while (%i < $numtok(%Bannword,32)) {
inc %i
var %current.word = $gettok(%Bannword,%i,32)
if ($regex($1-,/ $+ %current.word $+ /g) > 0 ) {
%Badword. [ $+ [ $nick ] ] = %Badword. [ $+ [ $nick ] ] + $regex($1-,/ $+ %current.word $+ /g)
if ( %Badword. [ $+ [ $nick ] ] >= 5 ) {
msg # Stop spamming emotes, $nick $+ !
msg # .timeout $nick 120
unset %Badword. [ $+ [ $nick ] ]
return
}
}
}
unset %Badword. [ $+ [ $nick ] ]
}
Last edited by Sakana; 05/01/15 05:58 AM.
|
|
|
|
Joined: Sep 2014
Posts: 259
Fjord artisan
|
Fjord artisan
Joined: Sep 2014
Posts: 259 |
Uhm, nevermind the last script. It can be done much simpler ON @*:TEXT:*:#: {
if ($nick !isop #) {
if ( $regex($1-,/Kappa|FrankerZ|DansGame|SoonerLater/g) >= 5 ) {
msg # Stop spamming emotes, $nick $+ !
msg # .timeout $nick 120
}
}
|
|
|
|
Joined: Dec 2014
Posts: 3
Self-satisified door
|
OP
Self-satisified door
Joined: Dec 2014
Posts: 3 |
Thanks, those two scripts helped a lot
|
|
|
|
Joined: Sep 2014
Posts: 259
Fjord artisan
|
Fjord artisan
Joined: Sep 2014
Posts: 259 |
No probs. FYI there's an error in the 1st one replace
if (!$2) { set %target $remove($chan,$chr(35))
with
if (!$2) { set %target $remove($chan,$chr(35)) }
|
|
|
|
Joined: Dec 2013
Posts: 779
Hoopy frood
|
Hoopy frood
Joined: Dec 2013
Posts: 779 |
Since you're asking me to point out stuff you could do better, you can leave that part out of the code entirely. if (!$2) { set %target $remove($chan,$chr(35)) }
else set %target $iif($2,$2,$mid(#,2-)) is exactly the same thing. $remove($chan,$chr(35)) is the same as $mid(#,2-) assuming there aren't double ##, which isn't allowed on twitch to begin with. And if (!$2) isn't necessary as there's a check for $iif($2) $iif works this way: $iif ( $2 , $2 , # ) If $2 exists, use $2, else use # So, tl;dr, all you need is set %target $iif($2,$2,$mid(#,2-))
Nillens @ irc.twitch.tv Nillen @ irc.rizon.net
|
|
|
|
Joined: Sep 2014
Posts: 259
Fjord artisan
|
Fjord artisan
Joined: Sep 2014
Posts: 259 |
|
|
|
|
Joined: Jan 2015
Posts: 2
Bowl of petunias
|
Bowl of petunias
Joined: Jan 2015
Posts: 2 |
Uhm, nevermind the last script. It can be done much simpler ON @*:TEXT:*:#: {
if ($nick !isop #) {
if ( $regex($1-,/Kappa|FrankerZ|DansGame|SoonerLater/g) >= 5 ) {
msg # Stop spamming emotes, $nick $+ !
msg # .timeout $nick 120
}
}
is there a way to do this without listing them individually?
|
|
|
|
Joined: Jan 2014
Posts: 107
Vogon poet
|
Vogon poet
Joined: Jan 2014
Posts: 107 |
Uhm, nevermind the last script. It can be done much simpler ON @*:TEXT:*:#: {
if ($nick !isop #) {
if ( $regex($1-,/Kappa|FrankerZ|DansGame|SoonerLater/g) >= 5 ) {
msg # Stop spamming emotes, $nick $+ !
msg # .timeout $nick 120
}
}
is there a way to do this without listing them individually? Not for use with Twitch, No. You have to list them individually. I'd recommend putting all the commmon ones in there.
|
|
|
|
Joined: Sep 2014
Posts: 259
Fjord artisan
|
Fjord artisan
Joined: Sep 2014
Posts: 259 |
They have an API for all their emotes, so you could use a JSON parser to download them every week or so and set them to a variable in the form of emote1|emote2|emote3 etc. http://twitchemotes.com/apidocsI'm not really sure how to do that though, and also don't know if it will cause performance issues to have a $regex with 5 billion different words in it :[
|
|
|
|
Joined: Jan 2004
Posts: 1,361
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,361 |
You can populate a hash table and use $hfind
|
|
|
|
Joined: Jan 2015
Posts: 1
Mostly harmless
|
Mostly harmless
Joined: Jan 2015
Posts: 1 |
Tried using this script says there is a Bracket error on line 1 and elsewise doesn't work.
|
|
|
|
|
|
|
|