mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#253718 29/06/15 02:32 PM
Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
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

Last edited by powerade661; 29/06/15 02:57 PM.
Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Look at line 2 and tell me if you see anything wrong.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
Wow Nillen I feel really dumb now... I got it, thanks for pointing it out. smile

Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
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?

Last edited by powerade661; 29/06/15 05:41 PM.
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
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.

Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
How would I write the .ini files for each channel that executes the command?

Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
Any ideas?

Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
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

Joined: Jun 2014
Posts: 248
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
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

Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
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
  }
}

Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
Ok this works. Has anyone figured out how to do a timer command to create timers?

Regards,
Powerade661

Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
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 }

}




Last edited by powerade661; 06/07/15 04:05 PM.
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
try inserting this line

Code:
if ($nick == $remove(#,$chr(35))) { return }

Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
Never mind

Last edited by powerade661; 06/07/15 05:25 PM.
Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
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

Last edited by powerade661; 06/07/15 05:28 PM.
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
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-

}

Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
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-

}
}


Last edited by powerade661; 06/07/15 09:03 PM.
Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
How would I stop this timer? is it just named timer or is the channelname the timer's name?

Regards,
Powerade661

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
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.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
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.

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
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 }


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
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...

Last edited by powerade661; 07/07/15 01:32 PM.
Joined: May 2015
Posts: 249
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
Create timer with NON-default name..


Dont give a fish - teach to fish!
Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
How? .timer.thisismytimer Is that what you are referring to?

Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
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

Last edited by sparta; 07/07/15 03:10 PM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Jan 2015
Posts: 168
P
Vogon poet
OP Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
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?

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
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.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Apr 2014
Posts: 33
B
Ameglian cow
Offline
Ameglian cow
B
Joined: Apr 2014
Posts: 33
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.

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
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.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Page 1 of 2 1 2

Link Copied to Clipboard