mIRC Homepage
Posted By: powerade661 Need help with this. - 29/06/15 02:32 PM
So basically I have been playing around trying to get this to work and would like to know if this is possible. I am trying to make it so that if someone is new in the chat, it welcomes them when they say something in the chat. If they are not new it welcomes them back.

I found this script on the forums, but I am trying to make it do something else instead. Currently it only works if they join and say something but I want to make so that if they say anything in the chat and they are new it welcomes them. Below is the code.

Example of what I am trying to do
Code:
 on *:text:#channel1: {
    if (!$read(joins.txt,nw,$nick)) {
      msg $chan Welcome to the stream $nick $+ . 
      write joins.txt $nick
    }
    else { msg $chan Welcome back $nick $+ . }
  }




Code:

on *:JOIN:#channel1: {
  on *:text:*: {
    if (!$read(joins.txt,nw,$nick)) {
      msg $chan Welcome to the stream $nick $+ . 
      write joins.txt $nick
    }
    else { msg $chan Welcome back $nick $+ . }
  }





Thanks,
Powerade661
Posted By: Nillen Re: Need help with this. - 29/06/15 03:36 PM
Look at line 2 and tell me if you see anything wrong.
Posted By: powerade661 Re: Need help with this. - 29/06/15 05:14 PM
Wow Nillen I feel really dumb now... I got it, thanks for pointing it out. smile
Posted By: powerade661 Re: Need help with this. - 29/06/15 05:38 PM
How would I put this in a command for multiple channels just out of curiosity? So instead of doing on *:text:*:#channel1:{ I could just do !welcome on and it would write the channel along with the user. And it would generate different text files for each channel. Is this possible? So for example it would put this in a text file and of course it would look for each channel for those users and if not it would welcome them.

Channel1.txt would contain
Code:
bots
potato
cloud
moose



Channel2.txt would contain
Code:
coder123
yoyo2
potato5 



How would I do this?
Posted By: Loki12583 Re: Need help with this. - 29/06/15 06:16 PM
I would suggest using ini files over text files, ini files are implemented internally as hash tables so their performance should be nearly the same (and much better than using $read(,nw)).

In this way you can have a single file with multiple sections and users.

activity.ini:
Code:
[#chan1]
nick1=1
nick2=1
nick3=1

[#chan2]
nick4=1
nick5=1
nick6=1


Then you use $readini(activity.ini,n,$chan,$nick) to access that information. Instead of storing just a "1" you could store other information like last join time to use for limiting when you welcome them.
Posted By: powerade661 Re: Need help with this. - 30/06/15 02:43 AM
How would I write the .ini files for each channel that executes the command?
Posted By: powerade661 Re: Need help with this. - 05/07/15 06:47 PM
Any ideas?
Posted By: powerade661 Re: Need help with this. - 05/07/15 06:52 PM
Also I have been wondering is it possible to have a timer command such as !timer #channel 30 This is my timer message.

Regards,
Powerade661
Posted By: Belhifet Re: Need help with this. - 06/07/15 12:29 AM
Originally Posted By: powerade661
How would I write the .ini files for each channel that executes the command?


/writeini <inifile> <section> <item> <value>

/writeini activity.ini $chan $nick $ctime
Posted By: powerade661 Re: Need help with this. - 06/07/15 01:45 PM
Would this be right?

Code:
on *:text:*:#:{
  if (!$readini(activity.ini,n,$chan,$nick) {
    msg $chan Welcome to the stream $nick $+ !
    /writeini activity.ini $chan $nick $ctime
  }
}
Posted By: powerade661 Re: Need help with this. - 06/07/15 01:59 PM
Ok this works. Has anyone figured out how to do a timer command to create timers?

Regards,
Powerade661
Posted By: powerade661 Re: Need help with this. - 06/07/15 04:04 PM
How would I make the script do nothing if the streamer was to type something in the chat?

Code:

on *:text:*:#:{
  if !$readini(activity.ini,n,$chan,$nick) {
    msg $chan /me Welcome to the stream $nick $+ ! :)
    /writeini activity.ini $chan $nick $ctime
  }
  elseif (# = #) { return }

}



Posted By: Sakana Re: Need help with this. - 06/07/15 05:15 PM
try inserting this line

Code:
if ($nick == $remove(#,$chr(35))) { return }
Posted By: powerade661 Re: Need help with this. - 06/07/15 05:21 PM
Never mind
Posted By: powerade661 Re: Need help with this. - 06/07/15 05:24 PM
That worked! Thanks so much! What exactly is going on here? Can you explain it to me? Also how would I make a command that can create timers?
Example: !addtimer #channel1 30 This is my timer
Posted By: Sakana Re: Need help with this. - 06/07/15 06:59 PM
It just checks if the nick is the name of the channel (without the #) -- so that's the same as the streamer's nick

A basic command to add timers could be this, but you need some IF statements because as is it would be abusable


Code:
on *:text:!addtimer *:#:{

.timer 0 $calc($3 * 60) msg $2 $4-

}
Posted By: powerade661 Re: Need help with this. - 06/07/15 09:02 PM
Is this what you are referring to when you are talking about IF statements?

Code:
on *:text:!addtimer *:#:{
if ($nick isop #) {
.timer 0 $calc($3 * 60) msg $2 $4-

}
}

Posted By: powerade661 Re: Need help with this. - 06/07/15 09:12 PM
How would I stop this timer? is it just named timer or is the channelname the timer's name?

Regards,
Powerade661
Posted By: Nillen Re: Need help with this. - 06/07/15 09:40 PM
You could try figuring it out yourself. /Help timers

As mentioned in that, your timer would be timer1 assuming there were no previous timers active. If you want to bypass this unexpected number behaviour you could edit your own script to begin with.
Posted By: powerade661 Re: Need help with this. - 06/07/15 10:03 PM
That's just the thing, there are tons of timers running. /timer1 off is generally how you would normally turn off the timer if the timer was timer1, I just don't know what this timer is named. That's why I asked.
Posted By: Nillen Re: Need help with this. - 07/07/15 09:46 AM
Originally Posted By: Help Files
To see a list of active timers type /timers. To see the setting for timer1 type /timer1. To deactivate timer1 type /timer1 off. To deactivate all timers type /timers off. If you are activating a new timer you do not need to specify the timer number, just use:

/timer 10 20 /ame I am not here!

And mIRC will allocate the first free timer it finds to this command.
Was all I said. You can find all info you've asked for in this channel by simply reading the help files. Here, I'll go out of my way to explain what Sakana posted since you asked what was going on in his code.

You have this code presented:
Code:
if ($nick == $remove(#,$chr(35))) { return }

If I don't know what the code would do, I would first type " /help /return " and see that this halts a command.
We know that $nick means the username's nickname
We know that $remove will remove something from a string. Our string in this case is #, which is translated to #CHANNEL.
$chr might be an odd one. " /help $chr " - We now know that it returns an ascii character. The ascii character for number 35 is a hashtag (#).

So it literally translates to this.
$nick = Nillens
# = #Nillens
$chr(35) = #
$remove(#,$chr(35)) = Nillens
if (Nillens == Nillens) { return }
Posted By: powerade661 Re: Need help with this. - 07/07/15 01:32 PM
When I type /timers it shows .timer username 0 1800s delay "the message is here" I know how to stop and create a timer, I just didn't understand what timer was in use so I could stop it.. I learned how to create timers from the help files...
Posted By: splinny Re: Need help with this. - 07/07/15 01:51 PM
Create timer with NON-default name..
Posted By: powerade661 Re: Need help with this. - 07/07/15 02:54 PM
How? .timer.thisismytimer Is that what you are referring to?
Posted By: sparta Re: Need help with this. - 07/07/15 03:09 PM
You can use

if ($timer(timer_name)) { timer_name off }

/timers <- show you the timers that are running.

Try not to use to many timers since it can make your script slow.

;--- edit

you can name your timers to what you want.

timer.time
timer.show
timer_time
timer_show
Posted By: powerade661 Re: Need help with this. - 07/07/15 03:12 PM
My only concern with that was if I name the timer would I be able to run different messages with that timer on multiple channels?
Posted By: Nillen Re: Need help with this. - 07/07/15 05:41 PM
Of course you can. How about creating a timer for each channel? How about creating a timer that calls an alias that messages each different channel?

Examples:
Code:
on 1:join:#: { 
if ($nick == $me) timerMsg_ $+ # 0 600 msg # However you get the message here is up to you I guess.
}

Code:
on 1:connect: {
if (twitch isin $server) timerMsgAll 0 600 msgall 
}
alias msgall { 
var %channels $ini(MSGALL.ini,Chans,0) 
var %i 1 
while (%i <= %chans) {
var %chan $ini(MSGALL.ini,Chans,%i) 
var %message $readini(MSGALL.ini,Chans,%chan)
if (%chan ischan) msg %chan %message
inc %i
}
}
Well, you can always start the same scripts using a different event though if you prefer using text events.
Posted By: bl968 Re: Need help with this. - 21/07/15 06:49 AM
I don't know why people still use ini's. I use hashtables for a multichannel twitch bot with extensive features.

/hmake tablename
/hadd tablename itemname value
/hdel tablename itemname

You use $hfind to search it. $hget to check a value.

For each channel I have one table for Channel Data, One for dynamic triggers, One for dictionary terms, one for ops, one for user info commands, one for dynamic trigger aliases, one to store regular users, one to store channel followers, one to store subscribers.
Posted By: Nillen Re: Need help with this. - 21/07/15 08:37 AM
Personal preference. In this situation I'd use a local variable over anything, I just used $ini in hopes of educating the user a bit further. I use a variation of inis and hashtables, I don't think there's one better than the other, I think they have unique qualities that trump the other's same aspect.
© mIRC Discussion Forums