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.

!unban $nick and probs to retrive the uhost

Old posts that have not been replied to for several years.
Locked
G
Garp
Voice
Posts: 29
Joined: Mon Sep 15, 2003 7:58 pm

!unban $nick and probs to retrive the uhost

Post by Garp »

I want to have a !unban <nick> but I run into problems to retrive the uhost while the banned nick is outside the channel.

I try at the moment with some bind raw to catch the nick's uhost.

Code: Select all


bind pub o|o !unban my:unban

proc my:unban {nick uhost hand chan arg} {
    set nicks [join [lindex [split $arg] 0]]
    if {$nicks == ""} {
        return 0
    }
	putserv "who $nicks \[i]%h"
}

bind raw - 354 my:getuhost

proc grp:getuhost {botnick hand arg} {
if { $hand == 354 } {
set nn "*!*@[join [lindex [split $arg] 1]]"
putserv "MODE #mychannel -b $nn"
}
}
raw 354 returns something like nick host.domain.tcl

This code is working but .... it doesn't look good.

The problem is that all raw events interfer with other who and whois stuff such as the bots own checking if he is proper logged in.

Is there a way to retrive a userhost by nick while the nick is not on the channel from inside a proc?

putserv "MODE #mychannel -b $nn" is really bad, better would be a way to use $chan so that I can use the script more variable for more then one channel.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

You can use [getchanhost $nick] or [getchanhost $nick $chan] but for this case it seems redundant as you said the user is out of the channel. This getchanhost only works if the user is on any of the channels as same with the bot, otherwise it returns "".

What you can do is bind raw after executing the proc:

Code: Select all

proc my:unban {nick uhost hand chan arg} { 
   ................
   .......................
   bind raw - 354 my:getuhost 
   putserv "who $nicks \[i]%h
   }
}

#and unbind it after you have removed the ban.

proc grp:getuhost {botnick hand arg} {
   ................
   .......................
   unbind raw - 354 my:getuhost
   putserv "MODE #mychannel -b $nn"
   }
}
Or either you can make a global variable, and do something like this:

Code: Select all

if {($pub_unban == 1)} { bind raw - 354 my:getuhost }

#Then in your both procs declare pub_unban as global.
#After that in the first one:

proc my:unban {nick uhost hand chan arg} { 
 global pub_unban
   ................
   .......................
   set pub_unban 1
   putserv "who $nicks \[i]%h
   }
}

#And in the second one:

proc grp:getuhost {botnick hand arg} {
 global pub_unban
   ................
   .......................
   set pub_unban 0
   unbind raw - 354 my:getuhost
   putserv "MODE #mychannel -b $nn"
   }
}
The only way to retrieve a userhost of a user outside a channel is in my knowledge, /who or /whois, or if you have nickserv services, say or some kind of services so the user is identified you can match them as well, but easier would be the first two. Secondly, when a bot joins a channel it does a /who upon the channel so thats why it is able to use getchanhost in the first place.

As for the channel thingy, this would be a bit complicated since you are doing /who and it has nothing todo with channels plus the user is not in the channel. You can make the bot do a foreach chan [channels] loop, and check with ischanban or some function and match if the ban is in the channel ban list then go ahead and remove it, something of that sort yeah.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Locked