mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2014
Posts: 24
T
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Apr 2014
Posts: 24
I am in the process of making a Twitch.tv Chat Bot. I ran into a problem when I had the bot welcome 1 user at a time, for some reason the bot disconnected and reconnected to the chat and welcomed everyone who was already in the chat at once. Twitch.tv has a rule that you cannot send 20+ messages in 30 seconds, this results in an 8 hour suspension.
My bot account has been suspended twice already.

What I want the bot to do is welcome the new users that have joined every 5 seconds. This is what I want it to say: Welcome to the stream $nick1 $nick2 $nick3
I know I need a timer, but I don't know how to get the script to display multiple users.

This is what I have now.
Code:
on *:JOIN:#ll_delirious_ll: { msg $chan Welcome to the stream $+($nick,!) }


I tried this script, but it did not welcome anybody.
From this post
Code:
 on !@*:JOIN:#:{
    if ($mid(#,2) ison $chan) {
    if ($nick == $mid(#,2)) { return }
    set -e $+(%,ajwelcome.,$cid,#) $addtok($($+(%,ajwelcome.,$cid,#),2),$nick,44)
    if (!$timer($+(.ajw.,$cid,#))) { $+(.timer.ajw.,$cid,#) 1 3 ajwelcome # }
  }
}
alias -l ajwelcome {
  if ($($+(%,ajwelcome.,$cid,$1),2)) {
    msg $1 welcome $v1 $+ , to my channel enjoy your nuggets!!.
    unset $+(%,ajwelcome.,$cid,$1)
  }
}


I also tried this one, but I was only able to get it say something when the bot joined, but not when anyone else joined.
From this other post
Code:
on *:join:#<3:{ 
  if ($nick == $me) { msg # Have no fear Ike_Bot is here. }
  elseif ($me isop #) && (%welcome) {
    set -e %welcome.nicks [ $+ [ # ] ] $addtok(%welcome.nicks [ $+ [ # ] ],$nick,32)
    var %msg = Hey everyone $list(%welcome.nicks [ $+ [ # ] ]) $iif($numtok(%welcome.nicks [ $+ [ # ] ],32) > 1,have,has) joined the stream.
    .timer.welcome [ $+ [ # ] ] 1 3 msg $safe(#) %msg $(|,0) unset %welcome.nicks [ $+ [ # ] ]
  }
}

alias -l list {
  tokenize 32 $1
  var %items = $1-, %list = %items
  if ($0 > 2) {
    %list = $regsubex(%items,/(\x20)/g,$iif(\n == \0,$chr(44) and $chr(32),$chr(44) $chr(32)))
  }
  elseif ($0 > 1) {
    %list = $1 and $2
  }

  return %list
}

alias safe return $!decode( $encode($1,m) ,m)


For the 2 scripts above I did put my channel after the :join:#

Can somebody please help me?

Last edited by Thedelirious1; 11/04/14 11:27 AM.
Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
So, basically what you're requesting is that once you join the room and get flooded with (x has joined #) you don't want to welcome them?

Code:
on *:join:#: { 
if (%joinspam == on) return
msg # Welcome to the stream $nick $+ ! 
}

on me:*:join:#: { 
set -u60 %joinspam on
}


EDIT: I noticed the other stuff you wanted too.
Here's how I would do it, ignore the part above.

Code:
on *:text:!welcome*:#: {
  if ($2 == on) {
    .timerjoin 0 5 Joined
    set %channel #
  }
  if ($2 == off) { 
    .timerjoin off 
    unset %channel 
  }
}

on *:join:#: { 
  if (%channel != #) return
  set %joined $addtok(%joined,$nick,32)
}

alias Joined {
  if (%joined == $null) return
  msg %channel Welcome to the stream, %joined :)  
  unset %joined
}

Last edited by Nillen; 11/04/14 12:05 PM.

Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Apr 2014
Posts: 24
T
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Apr 2014
Posts: 24
Thanks for helping, but I could not get the code to work. I type !welcome* to activate the timer with my regular account then left and rejoined the channel, but the bot did not welcome me when I joined back. Do I have to input my channel name into the code to get it to work?

Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191

!welcome on -> to activate the timer
!welcome off -> to deactivate


Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Like Blessing said, you need to state whether or not it should be on or off. The * in the on event means that ANY text can be used after Welcome, that's why there are if statements used to tell them apart.

if ($2 == on)
if ($2 == off)

$2 in this case is the second word you post, $1 is !welcome.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Apr 2014
Posts: 24
T
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Apr 2014
Posts: 24
I got it working in one channel. How do I get it to work in multiple channels? I changed the welcome text for different channels, I renamed the timers, and added the channel name for each code. I can't seem to get it working in more than one channel at a time. Do I have to add something to "Joined" to differentiate between the two?

Here is what I have so far:
Code:
on *:text:!welcomesquirrel*:#: {
  if ($2 == on) {
    .timerjoinsq 0 10 Joined
    set %channel #
  }
  if ($2 == off) { 
    .timerjoinsq off 
    unset %channel 
  }
}

on *:join:#th3squirrel4: { 
  if (%channel != #) return
  set %joined $addtok(%joined,$nick,32)
}

alias Joined {
  if (%joined == $null) return
  msg %channel Welcome to the stream, %joined :)  
  unset %joined
}


and

Code:
on *:text:!welcomegeico*:#: {
  if ($2 == on) {
    .timerjoinge 0 10 Joined
    set %channel #
  }
  if ($2 == off) { 
    .timerjoinge off 
    unset %channel 
  }
}

on *:join:#geico_cavemanx: { 
  if (%channel != #) return
  set %joined $addtok(%joined,$nick,32)
}

alias Joined {
  if (%joined == $null) return
  msg %channel Welcome to the stream, %joined :)  
  unset %joined
}
on

Last edited by Thedelirious1; 13/04/14 12:57 AM.
Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
This code is actually already good.

Code:
on !*:JOIN:#:{
    set -e $+(%,ajwelcome.,$cid,#) $addtok($($+(%,ajwelcome.,$cid,#),2),$nick,44)
    if (!$timer($+(.ajw.,$cid,#))) { $+(.timer.ajw.,$cid,#) 1 3 ajwelcome # }
}
alias -l ajwelcome {
  if ($($+(%,ajwelcome.,$cid,$1),2)) {
    msg $1 welcome $v1 $+ , to my channel enjoy your nuggets!!.
    unset $+(%,ajwelcome.,$cid,$1)
  }
}


It did not work when you tried it because the original code do checking if your botname == your channelname. That can cause problem if your botname is not same with your channelname.

With this code, you can not turn on/off timer.
You have to modified nillen's code if your want able to turn on/off timer. But the + is the code already support multi network/connection and multi channel as you wanted it.

Joined: Apr 2014
Posts: 24
T
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Apr 2014
Posts: 24
Thanks guys. That code works now for me in all the channels. I don't know why I couldn't get it working before.


Link Copied to Clipboard