| View previous topic :: View next topic |
| Author |
Message |
BilldaCat Voice
Joined: 30 May 2014 Posts: 1 Location: United States
|
Posted: Fri May 30, 2014 12:59 pm Post subject: New to TCL - making sure nick is registered with NickServ |
|
|
I'm writing a script in which when a command is issued from a user, it needs to check that the nick is registered before proceeding.
| Code: |
bind pub - ".signup" ofm:signup
bind raw - 307 auth_check
proc ofm:signup {nick host handle chan text} {
global m
putserv "WHOIS $nick"
if {[auth_check $nick] == "1"} {
puthelp "PRIVMSG $chan :verified - ok to keep going"
} else {
puthelp "PRIVMSG $chan :unverified - we need to stop here"
}
}
proc auth_check {args} {
if {![string match "*is a registered nick*" $args]} {return "0"}
set nick [lindex [split $args] 1]
return "1"
}
|
I know there's something I'm doing wrong with how I'm calling auth_check, I just don't know the right way to handle this. I'm going to need to call this function to check if the user is really registered on future checks as well, so I'm trying to break it out into it's own function I can use on demand.
[/code] |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri May 30, 2014 5:02 pm Post subject: |
|
|
Hello,
You'll have to re-think your coding ways alittle, I'm afraid.
The workflow you are suggesting needs to work in an asynchronous way - that is, you cannot expect the server reply of your WHOIS-command to be available within your ofm:signup function.
Instead, you should have your WHOIS-response handler do all the needed actions beyond your "putserv WHOIS $nick". Also, you'll have to keep in mind, that the instance of ofm:signup no longer exists, so there are no $nick, $host, $chan, etc variables available anymore - unless you've explicitly stored them as a global variable. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Get_A_Fix Master

Joined: 07 May 2005 Posts: 206 Location: New Zealand
|
Posted: Sat May 31, 2014 12:14 am Post subject: |
|
|
lol, I gave you the code and you changed it like that?
You would want to have the puthelp send to channel inside the auth_check, this gives the whois time to return output and match. _________________ We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
Last edited by Get_A_Fix on Wed Jun 04, 2014 12:51 am; edited 1 time in total |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat May 31, 2014 3:36 pm Post subject: |
|
|
@Get_A_Fix:
If you're really going to thrash down on a new poster like that, you really should atleast get your own code/facts straight (and no, I don't encourage thrashing down on users).
First of all, your posted example is using recursive code in a flawed manner.
Secondly, within auth_check, there exists no local variable "chan", so your puthelp's will throw an error.
Now, some code that should get you started atleast:
| Code: |
bind pub - ".signup" ofm:signup
bind raw - 307 handleAuth
array set authUsers ""
proc ofm:signup {nick host handle channel text} {
set ::authUsers([string tolower $nick]) [list 0 $channel [unixtime]]
putserv "WHOIS $nick"
}
proc handleAuth {from keyword text} {
set index [string first " " $text]
set nick [string range $text 0 $index]
set lnick [string tolower $nick]
set rest [lindex [split text ":"] end]
if {[info exists ::authUsers($lnick)]} {
set channel [lindex $::authUsers($lnick) 1]
if {[string match "*is a registered nick*" $rest]} {
set ::authUsers($lnick) [list 1 $channel [unixtime]]
puthelp "NOTICE $channel :verified - ok to keep going"
} else {
unset ::authUsers($lnick)
puthelp "NOTICE $channel :unverified - we need to stop here"
}
}
#Always return 0 so we don't break other things relying on 307 response.
return 0
}
|
The above code is a bare skeleton for making these asynchronous flows working.
A short explanation;
I use a global array to keep track of the different requests being made. Each item in the array is identified by the nickname (in lowercase), and contains a list of data - a boolean (0/1) whether the user has been verified, the channel from which the request was issued, and a timestamp of the latest update.
The first can be used for future lookups (caching), with the help of the timestamp to decide if it's still valid or not.
The second is used in the authCheck function to know where to send the response.
authCheck will check that there is a request in progress for the current server reply. If not, the response will be silently ignored.
The first few lines of authCheck shows different ways of extracting the server response into separate variables. Once the request have been found in the array, the channel name is also extracted. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Get_A_Fix Master

Joined: 07 May 2005 Posts: 206 Location: New Zealand
|
Posted: Sun Jun 01, 2014 3:25 am Post subject: |
|
|
| nml375 wrote: | @Get_A_Fix:
If you're really going to thrash down on a new poster like that, you really should atleast get your own code/facts straight (and no, I don't encourage thrashing down on users).
|
Thrashing a user? I did no such thing, I was merely trying to help.
Also, my own code? Umm, it _WAS_ my code the user was originally using, after they joined the #eggdrop channel on freenode and I gave them this code...
| Code: |
# --- NO EDIT ---
bind raw - 307 auth_check
bind join - * join_routine
setudef flag authcheck
proc join_routine {nick uhost hand chan arg} {
if {![channel get $chan authcheck]} {return}
if {![isbotnick $nick] && ![validuser [nick2hand $nick]]} {
putserv "WHOIS $nick"
}
}
proc auth_check {from keyword args} {
if {![string match "*is a registered nick*" $args]} {return}
set nick [lindex [split $args] 1]
foreach chan [channels] {
if {![onchan $nick $chan] && ![channel get $chan authcheck] && [validuser [nick2hand $nick]] && [isop $nick $chan] && [isvoice $nick $chan]} {return}
putquick "MODE $chan +v $nick"
return 0
}
}
|
I told them the script performed a similar function to what they were wanting and they could use it as a base to work on, to make theirs.
So, my code? Yes, it was.
I am sorry my code is 'flawed'. I am not proficient in TCL. This is only a hobby for me. I have had to teach myself, and while that isn't the best way and is sometimes the wrong way, eventually the code I do make works. As long as it works, I'm happy. _________________ We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
Last edited by Get_A_Fix on Wed Jun 04, 2014 12:53 am; edited 2 times in total |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Jun 01, 2014 10:59 am Post subject: |
|
|
@Get_A_Fix:
"Thrash down" might have been a strong choise of words, I admit. Apologies for that.
I do realize that you've had some discussions off-forum. Unfortunately, that means that the rest of us don't have the full context.
My comment regarding code was the example in your initial post, as I had no means of knowing what your original code had been, at that point of time.
The "original" code of yours looks proper, except perhaps for the use of the "args" keyword in your auth_check proc. Since eggdrop bindings always use a set number of parameters, "args" will not provide any features and is best avoided (it won't break your code, though). _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Get_A_Fix Master

Joined: 07 May 2005 Posts: 206 Location: New Zealand
|
Posted: Mon Jun 02, 2014 3:58 am Post subject: |
|
|
| nml375 wrote: | @Get_A_Fix:
"Thrash down" might have been a strong choise of words, I admit. Apologies for that. |
All good. Unfortunately with the internet and forums, it's hard to gauge the full meaning of some things, it may be a cultural/slang issue, or just a simple misunderstanding. It happens
| nml375 wrote: | @Get_A_Fix:
I do realize that you've had some discussions off-forum. Unfortunately, that means that the rest of us don't have the full context.
My comment regarding code was the example in your initial post, as I had no means of knowing what your original code had been, at that point of time. |
Yeah, I didn't want to complicate things by re-posting what I had already given the user.
| nml375 wrote: | @Get_A_Fix:
The "original" code of yours looks proper, except perhaps for the use of the "args" keyword in your auth_check proc. Since eggdrop bindings always use a set number of parameters, "args" will not provide any features and is best avoided (it won't break your code, though).
|
I will try to remember this, hopefully next time it will be proper and proficient.
Thanks for taking the time to actually explain, rather than just getting angry at me. Some people, like Speechless, are just tools. They abuse and berate users until they either /ragequit on IRC, or leave the forums. _________________ We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
Last edited by Get_A_Fix on Wed Jun 04, 2014 12:56 am; edited 1 time in total |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Wed Jun 04, 2014 1:52 pm Post subject: |
|
|
| Get_A_Fix wrote: | | Thanks for taking the time to actually explain, rather than just getting angry at me. Some people, like Speechless, are just tools. They abuse and berate users until they either /ragequit on IRC, or leave the forums. |
Now now... Let's be truthful here guy...
my nickname is speechles. Why people always feel the need to add the last S or call me speachless means they have an obvious lack of detail. A problem with paying attention. So pay attention to this.
I am the one not giving crappy half-assed advice better kept in your head. Sometimes it is better, to not say a word and be assumed an idiot, than to open your mouth and remove all doubt.
As users become more demanding and progress as you have get-a-fix. They become the epitomy of what is wrong with this project. People with no clue what-so-ever offering advice to others with broken junk code and an attitude to match. This is freenode.
ragequit.. I never ragequit a thing. Get your facts straight there johnny. I was banned because they cannot tolerate my opinion. This is called germany. This is what the nazi's did. In that kind of scenario I removed myself. I also called out and removed them from efnet. You need to get your information correct before once again you start spreading inaccurate, stupid, and just pointless things to this forum bro.
keep in mind, I know who you are. I've seen you on irc. You are a constant source of consternation and dismay ever time you ask once of your "questions" on irc bro. I never left the forums either. If I did, strange that here I am. What I did do is stop providing my updated scripts and basically stopped all eggdrop development in general. Why? This is the good part. Because... Does there have to be a reason? For you there must. So you start to make this assumptions...
nml375, do not remove this post as you did my last. Notice my nickname is mentioned above. If you do remove this post, remove this idiots banter above mine as well. Otherwise you the tool. Take opinions you don't like and hide them. This is so juvenile I can't believe I even wasted keystokes on this crap. But it has to be done this guy doesn't know anything and just likes to take medication and annoy others. _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Jun 04, 2014 2:01 pm Post subject: |
|
|
@speechles : In nml375's defense it was actually me who removed your post mainly cos it did add any value to the subject but trolling like you just did one more time.
@nml375 feel free to remove his and mine post when and if you see fit, if not I will later on.
@speechles and Get_A_Fix : please mind your attitude regarding other members. You got something with that member? Take it on IRC, PM or whatever, not on the forum. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Get_A_Fix Master

Joined: 07 May 2005 Posts: 206 Location: New Zealand
|
Posted: Thu Jun 05, 2014 1:55 pm Post subject: |
|
|
@speechles Keep proving my point.
caesar, I don't even have an attitude, I merely tried to help. That is all I've tried to do, for years, and am known for it on some networks. If people think it's crappy, or half-assed, that's their problem. At least I try to help, unlike others who just continue to show their constant ignorance and arrogance.
I don't have a problem with anyone, they are entitled to their opinions.
I have nothing more to say on the matter. _________________ We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|