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.

why tcl

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

That's weird. The channel #chan is set correctly yet you don't see the op notice? Anyway, add:

Code: Select all

if {![channel get $chan cswhy]} return
if {[lsearch $text "Identification"] == -1} return
before:

Code: Select all

set csWhyList [channel get $chan csWhyList]
and remove the debug line and it should be working fine.
Once the game is over, the king and the pawn go back in the same box.
User avatar
Amr
Halfop
Posts: 94
Joined: Fri Sep 14, 2007 7:13 am
Location: Egypt

Post by Amr »

now I see the chanserv's reply on the telnet only.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

The code in my previous comment makes it *ignore* any other notices if is not one regarding an issued WHY command, thus no more errors like that of a invalid channel.

To be honest I don't quite understand you. You said it's working, then it isn't and then you change your mind again. Decide already, is it working or not? I ran some tests and was working fine at me, yet at you it didn't. Don't know what exactly you've done there as it should work without any issues.

I'll get later on a bot on Dalnet servers and test this again, although the result shouldn't differ, meaning it's working as should.
Once the game is over, the king and the pawn go back in the same box.
User avatar
Amr
Halfop
Posts: 94
Joined: Fri Sep 14, 2007 7:13 am
Location: Egypt

Post by Amr »

I got the result only via telnet , not over ops notice.
User avatar
Amr
Halfop
Posts: 94
Joined: Fri Sep 14, 2007 7:13 am
Location: Egypt

Post by Amr »

caesar; any news?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Here's a new version:

Code: Select all

namespace eval csWhy {
	setudef str csWhyList
	setudef flag cswhy

	bind mode * "% +o" [namespace current]::checkWhy
	bind notc * * [namespace current]::checkReply
	bind part * * [namespace current]::remove
	bind sign * * [namespace current]::remove
	bind nick * * [namespace current]::nick
	bind kick * * [namespace current]::kick
	bind join * * [namespace current]::botJoin

	# purge
	proc purge {chan user {newNick ""}} {
		set csWhyList [channel get $chan csWhyList]
		set pos [lsearch $csWhyList $user]
		if {$pos != -1} {
			if {![llength $newNick]} {
				set csWhyList [lreplace $csWhyList $pos $pos]
			} else {
				set csWhyList [lreplace $csWhyList $pos $pos $newNick]
			}
			channel set $chan csWhyList $csWhyList
		}
		return $pos
   }
   
	# cleanup
	proc cleanup {chan user} {
		if {[isbotnick $user]} {
			channel set $chan csWhyList {}
		} else {
			purge $chan $user
		}
	}
   
	# join
	proc botJoin {nick uhost hand chan} {
		if {[isbotnick $nick]} {
			channel set $chan csWhyList {}
		}
    }
   
	# kick
	proc kick {nick uhost handle chan vict reason} {
		if {![channel get $chan cswhy]} return
		if {![wasop $chan $nick]} return
		cleanup $chan $nick
	}

	# part & sign
	proc remove {nick uhost handle chan {text ""}} {
		if {![channel get $chan cswhy]} return
		cleanup $chan $nick
	}

	# nick
	proc nick {nick uhost handle chan newNick} {
		if {[isbotnick $nick] || ![channel get $chan cswhy]} return
		if {![isop $chan $nick]} return
		puthelp "ChanServ WHY $chan $newNick"
		purge $chan $nick $newNick
	}
   
	# someone got OP'ed on the channel
	proc checkWhy {nick uhost hand chan mode target} {
		if {[isbotnick $target]} return
		if {![channel get $chan cswhy]} return
		set csWhyList [channel get $chan csWhyList]
		lappend csWhyList $target
		channel set $chan csWhyList $csWhyList
		puthelp "ChanServ WHY $chan $target"
   }

	# reply of WHY command from ChanServ
	proc checkReply {nick uhost hand text {dest ""}} {
		if {[string equal -length 1 # $dest]} return
		if {![string equal $nick "ChanServ"]} return
		set text [split $text]
		if {[lsearch $text "Identification"] == -1} return
		set chan [string trim [lindex $text 5] {.}]
		if {![channel get $chan cswhy]} return
		set user [lindex $text 0]
		if {[purge $chan $user] != -1} {
			puthelp "NOTICE @$chan :$text"
		}
	}
}

putlog "cswhy.tcl loaded.." 
I joined Dalnet in order to check this out but needed AOP on a channel to issue the WHy command so I had to fake a few things in order to test this out, and from my results it's working fine.
* bot sets mode: +o caesar
<@bot> ChanServ WHY #chan caesar
-bot:@#chan- @ caesar has FOUNDER access to #chan. Reason: Identification to services with the channel password. Channel Frozen: NO

* caesar is now known as user
<@bot> ChanServ WHY #chan user
Once the game is over, the king and the pawn go back in the same box.
Post Reply