This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Chattr MSG Command - not working properly

Help for those learning Tcl or writing their own scripts.
Post Reply
v
vigilant
Halfop
Posts: 48
Joined: Thu Jan 05, 2006 12:06 am

Chattr MSG Command - not working properly

Post by vigilant »

Okay so I have modified my script a bit with the help of Mr Spike^^.
[10:32:15 pm] -> *leet* chattr who
[10:32:17 pm] -leet- No channel
[10:32:19 pm] -leet- Ljubljana.SI.EU.irchaven.org 401 leet who :No such nick
[10:32:21 pm] -leet- Ljubljana.SI.EU.irchaven.org 318 leet who :End of /WHOIS list.
[10:32:23 pm] -leet- User is offline
[10:32:25 pm] -leet- Changed nonglobal flags for who from * to * in
[10:37:55 pm] -> *leet* chattr
[10:37:57 pm] -leet- No nickname
[10:38:00 pm] -> *leet* chattr vigilant
[10:38:07 pm] -> *leet* chattr vigilant #woot
[10:38:11 pm] -leet- Ljubljana.SI.EU.irchaven.org 318 leet leet :End of /WHOIS list.
[10:38:13 pm] -leet- Changed nonglobal flags for vigilant from fjlmnoptx to * in
[10:38:15 pm] -leet- No flags
[10:38:17 pm] -leet- Ljubljana.SI.EU.irchaven.org 318 leet vigilant :End of /WHOIS list.
[10:38:19 pm] -leet- Changed nonglobal flags for vigilant from fjlmnoptx|almno to fjlmnoptx|almno in #woot
[10:38:27 pm] -> *leet* chattr vigilant #woot +f
[10:38:29 pm] -leet- Ljubljana.SI.EU.irchaven.org 318 leet vigilant :End of /WHOIS list.
[10:38:31 pm] -leet- Changed nonglobal flags for vigilant from fjlmnoptx|almno to fjlmnoptx|aflmno in #woot
There are some errors still
As seen above
It changes the flags for people who are offline as well
It lists flags for people when there are no flags specified
It does not say, you did not enter a channel, after typing /msg botnick chattr vigilant

Code: Select all

bind msg - chattr chattrFirstProc

proc chattrFirstProc { n u h t } {
	# using [lindex $t 0] for non global
	set nick [lindex $t 0]
	set channel [lindex $t 1]
	set flags [lindex $t 2]

# some global variables
	set ::chattrUser $n
	set ::chattrWho [lindex $t 0]
	set ::chattrNonGlobalChannel [lindex $t 1]
	set ::chattrOldFlags [chattr [nick2hand [lindex $t 0]] $channel]
	set ::chattrNewFlags [chattr [nick2hand [lindex $t 0]] -|[lindex $t 2] $channel]


	bind raw - 318 chattrSecondProc
	bind raw - 401 chattrSecondProc
	unset -nocomplain ::chattrOffline
	putquick "WHOIS $nick"

# put input verification in the first proc
	
	if {[lindex $t 0] == "-global" && [lindex $t 1] == ""} {
		putnotc $n "No nickname when -global is provided"
		return 1
	}
	
	if {[lindex $t 0] == "-global" && [lindex $t 2] == ""} {
		putnotc $n "No flags provided"
		return 1
	}
	
	if { $nick == "" } {
		putnotc $n "No nickname"
		return 1
	}
	
	if { $channel == "" } {
		putnotc $n "No channel"
		return 1
	}
	
	if { $flags == "" } {
		putnotc $n "No flags"
		return 1
	}	
}

proc chattrSecondProc { from key text } {
#  receiving a 401 reply will probably require setting another global variable so when we get the 318, we know how to reply as online or offline
	putnotc $::chattrUser "$from $key $text"
	if {$key == "401"} {
		set ::chattrOffline "1"
		return
	}
	unbind raw - "318" chattrSecondProc
	unbind raw - "401" chattrSecondProc
	if [info exists ::chattrOffline] {
		putnotc $::chattrUser "User is offline"
	}
# [07:40:13 pm] <SpiKe^^> then we add the user and/or flags to the user, or what ever we want to do if the user is online as we just proved or disproved	
	putnotc $::chattrUser "Changed nonglobal flags for $::chattrWho from $::chattrOldFlags to $::chattrNewFlags in $::chattrNonGlobalChannel"
	unset -nocomplain ::chattrOffline
}
This is an unfinished script.
It should do more input verification.
I hope you all can help with that.
Anser Quraishi
Website: http://www.anserq.com
v
vigilant
Halfop
Posts: 48
Joined: Thu Jan 05, 2006 12:06 am

Post by vigilant »

Hello all,

I have recoded the command, and it works now. I am using the onchan command. It works fine.
If you want to still reply to the above code, and tell me how to make it work that's good, otherwise it's okay.

Thanks to spike^^ for his help
Anser Quraishi
Website: http://www.anserq.com
Post Reply