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.

Sending info from one bot to the other

Old posts that have not been replied to for several years.
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Sending info from one bot to the other

Post by Buffy_25 »

Hi,

I'm trying to send info from one bot to my other bot.
What i wanna do is:
Bot one is connected and is controlling the channel. He keeps also the times from the persons that are online.
Let's say bot two connects 1 day later, then i want that bot one sends the connected time of my members (that are currently online) to my bot two. So that bot two knows for how long the members are already in the room.

I have the following for bot one:

Code: Select all

bind join - * joinproc 
proc joinproc {nick uhost hand chan} { 
  if {[isbotnick bot_one]} {return} 
  set ::joined($nick) [clock seconds] 
  if {[string equal -nocase [nick2hand $nick] "bot_two"]} { 
    putbot bot_two [list clear] 
    foreach nick [chanlist "#my_channel"] { 
      if {![info exists ::joined($nick)]} { 
        set ::joined($nick) [getchanjoin $nick $chan] 
      } 
      putbot bot_two [list join $nick [expr [clock seconds]-$::joined($nick)]] 
    } 
  } else { 
    putbot bot_two [list join $nick 0] 
  } 
} 

bind bot - "clear" procbot_clear 
proc procbot_clear {from-bot command arg} { 
  catch {unset ::joined} 
} 

bind bot - "join" procbot_join 
proc procbot_join {from-bot command arg} { 
  foreach {nick ago} $arg break 
  set ::joined($nick) [expr [clock seconds]-$ago] 
  
  puthelp "PRIVMSG #my_channel :$nick has joined (as of [duration $::joined($nick)] ago)" 
}
Now, when my bot_two connects, i don't get for each nick the online time yet. I only see things like:

bot_wo has joined (as of 3 years 13 weeks 6 days 3 mins ago)
So I only see my bot_two 's info when connecting (and it's eather not the right time!). And why am i not recieving the online time (in sec's from the other users?)
Is there something wrong in the code?

Btw, i have added the same info to bot one, so if bot one isn't in channel, but bot two is, then bot one will get all the info from bot two when entering the channel.

Thnx in advance for your help.

Best regards,

Buffy
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Post by Buffy_25 »

Hi,

Can some1 please help me with this? :-?

Thnx.

Buffy
m
meij

Post by meij »

i havnt really looked into your script that much, but i would assume using the 'LINK' bind would probably be better than the 'JOIN' one..

something like: 'bind LINK - {bot_two} joinproc'
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

Or you could store the info in a user's XTRA field, that way any bot linked in the botnet can access the info.
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Post by Buffy_25 »

meij,
So you mean when my bot connects to the botnet, he gets the info to him?

gb,
What you mean with user's XTRA field? Is that a specific way to store data in tcl?

Regards,

Buffy
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Read tcl-commands.doc in ~doc for a description of getuser and setuser :)
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Post by Buffy_25 »

Hi,

Still having some questions after reading the docs...

In the tcl-commands.doc, do the <handle> (i think this is the nick of the person i saved on my bot) needs to be a created/saved handle before the info can be stored into the XTRA field of that handle?

Let's say a new person enters my channel, how can i fill the XTRA field?
Does the user first need to be created on my bot, before he can use the "setuser"? :-?

What does the key-part mean please?

Code: Select all

setuser <handle> XTRA <key> 
to receive data set for a certain key
So let's say i want to store in seconds the time that a user has joined the room...how can i put in there that data?
And i presume, when bot two joins the partyline, then he will get the info from bot one with the getuser?

Can I get some more help on this please?

Thnx.

Regards,
Buffy
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Post by Buffy_25 »

Hi,

Can someone please show me an example how i can add some info into the XTRA field and how i can make it visible in a channel on a certain command?

I searched on the internet to have some more info about setuser and getuser but couldn't find info needed on how to work with it :(

All additional info is welcome!

Thnx.

Regards,
Buffy
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

If you're unable to look up commands in tcl-commands.doc then maybe tcl scripting isn't for you.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Two very simple uses of "setuser'. The first disables a user in the bot and the second re-enables a user.

Code: Select all

setuser $hand XTRA AUTH DEAD

Code: Select all

setuser $hand XTRA AUTH 0
The term "handle" refers to the nick originally added to the bots' user file, a user can use any nick he/she wishes as eggdrop uses hostmasks to recongise, not nicks, unless someone is unwise enough to add their host as nick!*@*.

TCL cannot be learned in 5 minutes either. You may find this link very helpful.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Post by Buffy_25 »

Alchera,
Thnx for the info.
After having some time again, i read some TCL/.../ pages you wrote above, and tried to script this part again.

Find below what i want to do, and how i tried to script it:
(i have 2 bots in my channel. Let's say bot1 is connected, and bot2 isn't)
When bot1 joins, he needs to check if bot2 is in (if not, he just continues to take the info from the users in chan right now. If bot2 is in, then he will get the info from bot2)
But, when a person joins the channel after this, the bot1 add this user "adduser <handle>" (if it doesn't exist yet) and once that is done, bot1 starts a timer in -> setuser handle XTRA key data
The bot makes this for each nick that joins.
Once bot2 connects, bot1 will send all this info from all the connected handles (timers) to bot2, who will put all those info's into his setuser (if handle doesn't exist, create first before adding the timer to his XTRA field).

Script on bot1:

Code: Select all

bind join – "#channel" checkbotonline
proc checkbotonline {nick uhost hand chan} {
if {[onchan bot2 #channel]} { return 0 }
else {
foreach nick [chanlist "#channel"] {
set hand $nick
setuser $hand XTRA startjointime 0 }
}
}

bind join - * joinuser
proc joinuser {nick uhost hand chan} {
if {[isbotnick bot2]} {return} #or do i need to work with islinked ?
if {![info exists $hand)]} {
set $hand $nick
adduser $hand $uhost
}
setuser $hand XTRA startjointime start timer
#When the person joins, i would like that a normal timer starts counting in seconds (so when that person will leave afterwards, i will see how long he was in in XX days XX hours...). Can someone please help me on how i can make this timer work in "Setuser"?

bind join - * joinbot
proc joinbot {nick uhost hand chan} {
if {[isbotnick bot2]} {
foreach $nick [chanlist "#channel"] {
set hand $nick
set jointime($nick) [getuser $hand XTRA startjointime]
putbot bot2 [time $nick jointime($nick)]
}
}
}

bind bot - "time" procbot_join 
proc procbot_join {from-bot command arg} {
if {[string equal -nocase $nick "bot2"] || [string match -nocase "*@blabla.com" $uhost]} {
set $nick [lindex [split $arg] 0]
set jointime($nick) [lindex [split $arg] 1]
set hand $nick
setuser $hand XTRA startjointime $jointime($nick) #how can i make now this amount of seconds (coming from bot2) and to start counting as a timer (for example bot2 transferred 2154 sec … now i want that my timer starts with this 2154 sec , 2155 sec, …)
}
}

Script for bot2, same as above, but where bot2 needs to be changed by bot1.

I hope that some one understand they way i want to go to …

Unfortunately i can’t make it work/test yet, since i need some clarification/help on some lines…(ref remarks in script part)

If you see something that can be changed, or made easier, please feel free to change.

Kind regards,

Buffy
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Post by Buffy_25 »

Hi,

Can someone help me a bit more please? :-?

Thnx.

Buffy
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Post by Buffy_25 »

How can i put in an setuser XTRA parameter a timer?

For example:
setuser $hand XTRA startjointime "start a timer now in seconds" ?

Is this possible?
So i would like that when i do setuser for a certain person, it starts counting from 0 sec till i ask the getuser (with this i'll get the elapsed time in seconds from the setuser to the getuser)
And if it's possible, how do i need to show this elapsed time in the getuser type?

Thnx.

Buffy
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Code: Select all

# store the start time
setuser $hand XTRA whatever [clock seconds]
# when needed, calculate the duration like this (current time-stored time):
duration [expr {[clock seconds]-[getuser $hand XTRA whatever]}]
(make sure the XTRA field contains a number before you do the calculation)
Have you ever read "The Manual"?
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Post by Buffy_25 »

Thnx user!

This is working great. :D

Btw, i looked on the forum with the search results for a script that added a user automatically on a onjoin. But in vain :-?

Can someone please help me to put me on the right way to start a script like this:
When a person joins my #channel. My bot then checks if this nick is known in a handle on my bot. If yes, then disregard, if not, then he does a adduser <handle> (with the nick that joined) <uhost>

Code: Select all

bind join - * joinproc
proc joinproc {nick uhost hand chan} {
if {[isbotnick $nick]} {return 0}
if {string match $hand $nick} {return 0}
else {
set $hand $nick
adduser $hand $uhost
chattr $hand +f #channel
}
}
Is this correct?

If i have for example a $nick that exist in my botlist with "Blargo"...and he connects with BlargoZZZ or Blargo_Zzz or Blargo[A] or [A]Blargo, how can i tell my script that that person already has a handle on my bot?

Thnx.

Buffy
Locked