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.

Virtual host of bot (process into process)

Help for those learning Tcl or writing their own scripts.
Post Reply
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Virtual host of bot (process into process)

Post by juanamores »

I need the vhost (virtual host) my bot, that I did not return the getchanhost, matchaddr or maskhost commands.

If I do a whois to my bot, your vhost is different than other commands return.

The matchaddr command returns the real host, that is, the company belonging to the internet .:
mybot!botijo@anteldata.net.uy

The vhost my bot is another:
mybot!botijo@hello.your.best.bot

I need a command to return vhost bot.

I found the solution, but have the problem of getting the value of the variable vhost from one process to another.

Code: Select all

bind mode - "% +b" check:ban 

proc check:ban {nick host hand chan mode target} {
 global canal_admin vhost
  putserv "WHOIS $::botnick"
proc whois::311 {from key botnick } {
global canal_admin vhost
  if {[regexp -- {^[^\s]+\s(.+?)\s(.+?)\s(.+?)\s\*\s\:(.+)$} $botnick wholematch nick ident host realname]} {
    set vhost [stripcodes bc ${host}]
	putserv "PRIVMSG $canal_admin :boT vhost: $vhost"
 }
}
 set host1 "*!*@[join $vhost]"
.................more stuff................
Tcl error [check:ban]: can't read "vhost": no such variable
The problem starts in the following line:
set host1 "*!*@[join $vhost]"
You can not set the host1 variable, because it can not read the vhost variable.

Is there any way to fix this code, or another way to get the vhost bot?
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

You can't just put the proc whois::311 inside of the process that is calling the whois, and then just continue on as though you have the returned results from the server.
At the time this line runs: set host1 "*!*@[join $vhost]" :there has not been a return from the server yet, and you have no bind to even catch that raw return.
Also, don't use :: in your process names unless you fully understand tcl namespaces, and you handle the namespace correctly.

If I was trying to do this sort of thing, I would whois the bot on connection to the network, and save the required nick!user@vhost info to a global var I could call when needed.
This info should not change while you are still connected, and can be updated as needed every time the bot connects.
That would keep you from having to whois the bot every time someone sets a ban on any channel the bot is on.

Then, all you have to do when a ban is set, is string match -nocase the new ban mask against the stored nick!user@vhost of the bot, and can continue without having to wait for a whois to be returned by the server:)
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

He doesn't need to do a whois on the bot when can get creative and instead use getchanhost on the bot and will result current vhost. At least in theory. Will see what results he will get in the other topic that he opened with about the same subject.
Once the game is over, the king and the pawn go back in the same box.
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

SpiKe^^ wrote: ...
This info should not change while you are still connected, and can be updated as needed every time the bot connects.
...
This made me remember:
Are not most vhosts controlled by Nickserv? In that the vhost is not applied until the nick identifies with Nickserv.

I think the original poster said something about getchanhost failing to get an address that matched.
Could this have been the problem?

Just a thought ....
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

caesar wrote: He doesn't need to do a whois on the bot when can get creative and instead use getchanhost on the bot and will result current vhost. At least in theory. Will see what results he will get in the other topic that he opened with about the same subject.
It is truly in theory.
willyw wrote: I think the original poster said something about getchanhost failing to get an address that matched.
[matchaddr $target "$::botnick![getchanhost $::botnick]"] return 0 (zero)
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
Post Reply