|
| Author |
Message |
Cheater Senior Member

Joined: 10 Jun 2005 Posts: 236
  
|
Posted: Tue Jun 14, 2005 12:44 pm Post subject: Nexusbot brain.pl question |
|
|
I was looking at brain.pl in an effort to help me write my own command. One of the lines looks like this:
| Code: | elsif ($msg =~ /how old am i|what is my age/i) {
$reply = "You told me you were $chaos->{users}->{$client}->{age} years old.";
} |
I'm trying to figure out what the part below means so I can edit it.
| Code: | | $chaos->{users}->{$client}->{age} |
|
|
| Back to top |
|
 |
JTW God Like

Joined: 07 Mar 2004 Posts: 582 Location: Maidstone
  votes: 4
|
Posted: Tue Jun 14, 2005 1:15 pm Post subject: |
|
|
| Code: | | $chaos->{users}->{$client}->{age} |
Is a variable/hash (not sure if there is a difference) In it the clients age would have been stored
Basically it is looking in $chaos which must be the main thing in nexus
{users}- because it is user related
{$client} - the persons email address or unique id
{age} - the persons age
You can store all kinds of things in variables/hashes like these nicknames almost whatever you want. |
|
| Back to top |
|
 |
Cheater Senior Member

Joined: 10 Jun 2005 Posts: 236
  
|
Posted: Tue Jun 14, 2005 1:16 pm Post subject: |
|
|
| but there is no user folder |
|
| Back to top |
|
 |
JTW God Like

Joined: 07 Mar 2004 Posts: 582 Location: Maidstone
  votes: 4
|
Posted: Tue Jun 14, 2005 1:43 pm Post subject: |
|
|
It doesn't have to be a users file I don't know what nexus saves its information in but normally $chaos would be related to a single file (most likely .DAT i.e. evolution saves anything in $bot->{store} to a file called save.DAT )and it would then organize its self something like this in the file.
| Quote: | {users}
{who@where.com}
{age} = 19;
{someoneelse@whoknows.com}
{age} = 10;
|
So everything in red is in the users who unique name/addy is who@where.com
in turn everything in Green is related to someoneelse@whoknows.com
it might not appear right because forums do strange things to text formatting
Edit:It posted before i was finished
Last edited by JTW on Tue Jun 14, 2005 1:50 pm; edited 1 time in total |
|
| Back to top |
|
 |
Cheater Senior Member

Joined: 10 Jun 2005 Posts: 236
  
|
Posted: Tue Jun 14, 2005 1:47 pm Post subject: |
|
|
The place where it's taking the age from is:
Nexusbot>Clients>(txt file with name of user)
An example file looks like:
| Quote: | permission=
messages=
name=
age=
sex=
location=
color=
band=
book=
sexuality=
job= |
It would normally have data filled in. |
|
| Back to top |
|
 |
JTW God Like

Joined: 07 Mar 2004 Posts: 582 Location: Maidstone
  votes: 4
|
Posted: Tue Jun 14, 2005 1:52 pm Post subject: |
|
|
(Did i mention i know nothing about nexusbot :p)
in that case its a diffrent system then to what im used to so i dont think i can help you. |
|
| Back to top |
|
 |
Cheater Senior Member

Joined: 10 Jun 2005 Posts: 236
  
|
Posted: Tue Jun 14, 2005 1:58 pm Post subject: |
|
|
| ok, thanks anyway |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Tue Jun 14, 2005 2:15 pm Post subject: |
|
|
None of my bots get and store their entire body hashref in text files. On startup it goes through and loads everything in.
The bot opens the "clients" folder and goes through every file inside (each file for a specific user). To get the user's username, it just removes the .txt from the end. Then it stores all the data inside $chaos->{users}->{$username}
So $chaos may look like this, in respect to user data:
| Code: | $chaos = {
users => {
kirsle => {
name => 'Cer',
age => 17,
sex => 'male',
location => 'USA',
# etc. etc.
},
somebodyelse {
name => 'Billy',
age => 10,
sex => 'female', # dont ask
location => 'UK',
},
anotherperson {
# etc. you get the idea
},
},
}; |
Hashrefs are just a way of storing data, and don't have any relation to existing folder paths. For example, I could make a hashref that's
$chaos->{a}->{b}->{c}->{d}->{e}->{f}->{g}->{h}->{i}->{j}->{k}->{l}->{m}->{n}->{o}->{p}->{q}->{r}->{s}->{t}->{u}->{v}->{w}->{x}->{y}->{z} = "Now I know my ABC's.";
Well for another example, there's $chaos->{system} when there's no folder that is remotely called any synonym to "system" |
|
| Back to top |
|
 |
Cheater Senior Member

Joined: 10 Jun 2005 Posts: 236
  
|
Posted: Tue Jun 14, 2005 2:20 pm Post subject: |
|
|
I was thinking I had to use that for the notes thing. So it would look like this:
| Code: | elsif ($msg =~ /viewnote XXXX) {
$reply = "You told me you were $chaos->{users}->{$client}->{Note}->{XXXX}";
} |
With some variable in place of XXXX |
|
| Back to top |
|
 |
|