mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
Variables and things #108967 24/01/05 05:24 PM
Joined: Jan 2005
Posts: 16
A
Angrycat Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Jan 2005
Posts: 16
I am wanting to have a system where by people I am friends with can type a command and be given the latest news.

such as !news would check my friends list (a var - %friend John Jack Tim Fred Sally)

Check to make sure that they have identified with the server.

Then message them the latest news from a variable (%news This is todays news. A cat got stuck in a tree.)

I am happy to manually edit the variables when they need changing.

Any / all help appreciated.

I got as far as
Code:
 on *:text:!news:#: if ($nick == %friend)/msg $nick test %news 

it doesnt work confused

and variable definations (global)

thanks smile

Re: Variables and things #108968 24/01/05 05:45 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
on *:text:!news:#: if ($istok(%friend,$nick,32)) { msg $nick test %news } [/code]

since %freind is a space seperated list of nicks, you must see if $nick is one of the tokens (nicks) in the list, the list of tokens has spaces (ascII 32) seperating each one, so
$istok(%friend,$nick,32) becomes true in $nick is in %friend, before u were checking if $nick was the same as the whole list.

This does not confront the issue of them identifing to the server

Re: Variables and things #108969 24/01/05 06:04 PM
Joined: Jan 2005
Posts: 16
A
Angrycat Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Jan 2005
Posts: 16
Thanks a lot for that Dave, very much appreciated.

If anyone can offer advice on how to check if the user has ID'd with the server that would be great.

Thanks.

Re: Variables and things #108970 24/01/05 06:32 PM
Joined: Jan 2005
Posts: 16
A
Angrycat Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Jan 2005
Posts: 16
I am thinking about using the STATUS command

-NickServ- 0 - no such user online or nickname not registered
-NickServ- 1 - user not recognized as nickname's owner
-NickServ- 2 - user recognized as owner via access list only
-NickServ- 3 - user recognized as owner via password identification

syntax: /ns status nick
Hmm i shall think on about it. Help still needed tho !

Re: Variables and things #108971 24/01/05 06:44 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
why not just have them message you the request with a code word on the end so u know its really them ?

Re: Variables and things #108972 24/01/05 06:49 PM
Joined: Jan 2005
Posts: 16
A
Angrycat Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Jan 2005
Posts: 16
Well too be honest I had not considered that. It is a good idea.

Sadly the chances of them keeping it secure are slim to none,

I am drifting along the road of

// !news system

on *:text:*-NickServ- STATUS angrycat 3*

kind of thing.

Just trying to get my head around messaging NickServ with the $nick, reading the response and then activating or denying the news.

Last edited by Angrycat; 24/01/05 06:50 PM.
Re: Variables and things #108973 24/01/05 07:07 PM
Joined: Oct 2003
Posts: 96
J
JoeDaddy Offline
Babel fish
Offline
Babel fish
J
Joined: Oct 2003
Posts: 96
You could also check their whois for
angrycat has identified for this nick
a lot of networks have that .. maybe yours too ?

Last edited by JoeDaddy; 24/01/05 07:09 PM.
Re: Variables and things #108974 24/01/05 07:10 PM
Joined: Jan 2005
Posts: 16
A
Angrycat Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Jan 2005
Posts: 16
So far i have done this

Code:
 
// !news system
on *:text:!news:#: { msg NickServ status $nick } if
(on *:text:*-NickServ- STATUS 3*) then ($istok(%friend,$nick,32)) { msg $nick %news } 
else { msg $nick test %ID }
 


That is a logical lay out, and obviously doesnt work, I am just working on a proper soloution atm, help as always - appreciated.

Re: Variables and things #108975 25/01/05 12:03 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
on *:TEXT:!news:#: {
  if ($istok(%friend,$nick,32) {
    msg NickServ status $nick
    set -u5 %friend.news $true
  }
}
on *:NOTICE:STATUS * 3: {
  if ((%friend.news) && ($nick == Nickserv) && ($istok(%friend,$2,32)) && ($3- == 3)) {
    msg $2 %news
  }
}


When they text !news, you request the neckserv to tell u there status, you also set a flag that falls after 5 seconds that you have done one of these.
When (if) nickserv replies, u see if there is the flag up, and the nick is in your list, and its just "status nick 3"
The last one "&& ($3- == 3)" I added becuase i cant remember how to make it match one word between STATUS & 3 in the ON *:NOTICE (sorry had a late night)

Re: Variables and things #108976 25/01/05 02:31 PM
Joined: Aug 2003
Posts: 1,831
I
Iori Offline
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Quote:
i cant remember how to make it match one word between STATUS & 3 in the ON *:NOTICE (sorry had a late night)


Er yep musta been a late one, that is how you match one word, & = 1 word. laugh
  • on *:notice:STATUS & 3:{

Re: Variables and things #108977 25/01/05 03:40 PM
Joined: Jan 2005
Posts: 16
A
Angrycat Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Jan 2005
Posts: 16
Thanks laugh

Re: Variables and things #108978 25/01/05 05:20 PM
Joined: Jan 2005
Posts: 16
A
Angrycat Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Jan 2005
Posts: 16
* /if: invalid format (line 15, script.ini)

confused

Re: Variables and things #108979 25/01/05 05:26 PM
Joined: Aug 2003
Posts: 1,831
I
Iori Offline
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Code:
on *:text:!news:#:{
  if ($istok(%friend,$nick,32)[color:red])[/color] {
    msg NickServ status $nick
    set -u5 %friend.news $true
  }
}
on *:notice:STATUS & 3:[color:red]?:[/color]{
  if ((%friend.news) && ($nick == Nickserv) && ($istok(%friend,$2,32))) {
    msg $2 %news
  }
}

Last edited by Iori; 25/01/05 06:10 PM.
Re: Variables and things #108980 25/01/05 05:51 PM
Joined: Jan 2005
Posts: 16
A
Angrycat Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Jan 2005
Posts: 16
ok this is not producing any errors and it is msg'ing nicvserv fine, and getting the response fine.

however it is not messaging the news.
Code:
 
%getnews !news
%news NEWS NEWS NEWS | Server back up sometime today | Town meeting likely | Xplict loves pie | Don't Reply to this |
%ID Please identify with the server before requesting news.  Syntax:  /msg NickServ Identify <PASSWORD>  If you have already identified then you are not on the access list for todays news.
%friend icedevil tsakos


there are my global variables

Re: Variables and things #108981 25/01/05 06:11 PM
Joined: Aug 2003
Posts: 1,831
I
Iori Offline
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Whoops sorry, see the edit above in the notice event, I just copied Daves code without looking, apparently blush

Re: Variables and things #108982 25/01/05 06:16 PM
Joined: Jan 2005
Posts: 16
A
Angrycat Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Jan 2005
Posts: 16
I
LOVE
YOU

Thanks a million to everyone who helped me with this.

cool

Re: Variables and things #108983 25/01/05 09:32 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
%getnews !news
%news NEWS NEWS NEWS | Server back up sometime today | Town meeting likely | Xplict loves pie | Don't Reply to this |
%ID Please identify with the server before requesting news. Syntax: /msg NickServ Identify <PASSWORD> If you have already identified then you are not on the access list for todays news.
%friend icedevil tsakos[/code]

I adjusted the code to cover sending the %ID out if your not voiced. It sends %ID if u are in the %friend list but not a 3, So you might want to remove the last sentence on the %ID I dont know?!?!?

Code:
 
on *:text:%getnews:#:{
  if ($istok(%friend,$nick,32)) {
    msg NickServ status $nick
    set -u5 %friend.news $true
  }
}
on *:notice:STATUS &amp; &amp;:?:{
  if ((%friend.news) &amp;&amp; ($nick == Nickserv) &amp;&amp; ($istok(%friend,$2,32))) {
    if ($3 == 3) { msg $2 %news }
    else         { msg $2 %ID }
  }
}


Thanks Iori for fixing my typoes, I thought it was & but was getting tired and didnt want to risk putting it in on a guess, Oh and yes it was a rather hard night out.

Re: Variables and things #108984 25/01/05 10:15 PM
Joined: Jan 2005
Posts: 16
A
Angrycat Offline OP
Pikka bird
OP Offline
Pikka bird
A
Joined: Jan 2005
Posts: 16
Thanks Dave ,

that was extremely helpful indeed.

now i am working on letting users add news to the string, but am researching if i can use sequencial variables and display the whole sequence (i,.e a user !addnews today is a good day. | then the tect is written to a new variable in sequence and !news returns the whole sequence.

The problems i forsee is a huge amount of data i have to manually remove = pain.

The other thing is to have the news somehow tagged on the end. maybe when the user !add new today is a nice day, the script calls the current version and adds the text on the end with some kind of delimiter.

And finally a !delete news function - which thankfully I think i can manage on my own.

If anyone wants to have a crack at this - as per usual - it is always appreciated, but I will slog on with it and see what happens.

Thanks again !

Re: Variables and things #108985 25/01/05 11:44 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
well this addition well cause it to become a bit more complex, I suggest using a NEWS.TXT file rather than multiple varables and, since to get ride of old news u can just edit the NEW.TXT file. To send them the contents of the file is simple use /PLAY


Also this well cause problems in that yuou must confirm all users who add news are also registered nicks. so the ON NOTIOCE needs to know what event tripped the check and what to do if the user comes back as registered,

However i have another solution for you
set %addnews !addnews

Code:
on *:text:%getnews:#:{
  if ($istok(%friend,$nick,32)) {
    var %ticks = $ticks
    .timer.kill.getnews. [ $+ [ $nick $+ . $+ [ %ticks ] ] ]  1 5 .timer.getnews. [ $+ [ $nick $+ . $+ [ %ticks ] ] ] off
    ;
    ;
    .timer.getnews. [ $+ [ $nick $+ . $+ [ %ticks ] ] ]       1 6 play $nick NEWS.TXT 1000
    ;^ this plays the news.txt to the $nick in 6 seconds time
  }
}
on *:text:%addnews:#:{
  if ($istok(%friend,$nick,32)) {
    var %ticks = $ticks
    .timer.kill.addnews. [ $+ [ $nick $+ . $+ [ %ticks ] ] ]  1 5 .timer.addnews. [ $+ [ $nick $+ . $+ [ %ticks ] ] ] off
    ;
    ;
    .timer.addnews. [ $+ [ $nick $+ . $+ [ %ticks ] ] ]       1 6 write NEWS.TXT $2-
    ;^ this adds news to the NEWS.TXT file in 6 seconds
  }
}
on *:notice:STATUS &amp; &amp;:?:{
  if ((%friend.news) &amp;&amp; ($nick == Nickserv) &amp;&amp; ($istok(%friend,$2,32))) {
    if ($3 == 3) { .timer.kill.*. [ $+ [ $2 $+ . $+ * ] ] off } 
    else         { msg $2 %ID }
  }
}


ok what i have done here is on each text event i start two timers, the 1st one kills the second one before it can run, the 2nd one is what ever the event is to do (assuming the user is registered), BUT as i said the 1st one well kill it before it can, So how does it work?
Well the reply of the nickserv if the user is registered, well kill the 1st timer, which well of course allow the second timer to run.

This way the on notice nickserv doesnt need to know what event tripped it, it just destroys the kill timers. allowing the event to progress to completion.

Re: Variables and things #108986 26/01/05 02:46 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
on *:text:%addnews:#:{
  if ($istok(%friend,$nick,32)) {
    var %ticks = $ticks
    .timer.kill.addnews. [ $+ [ $nick $+ . $+ [ %ticks ] ] ]  1 5 .timer.addnews. [ $+ [ $nick $+ . $+ [ %ticks ] ] ] off
    ;
    ;
    set -u7 %news. [ $+ [ $nick $+ . $+ [ %ticks ] ] ] $2-
    .timer.addnews. [ $+ [ $nick $+ . $+ [ %ticks ] ] ]       1 6 write NEWS.TXT % $+ news. [ $+ [ $nick $+ . $+ [ %ticks ] ] ]
    ;^ this adds news to the NEWS.TXT file in 6 seconds
  }
}


Just thought about this, and the above code is safer as $2- well be preservered in the variable, this closes a security gap with passing unknown contents in a timers parameters.

Page 1 of 2 1 2