User Control Panel
Advertisements

HELP US, HELP YOU!

Nexusbot brain.pl question

 
Post new topic   Reply to topic    Bot Depot Forum Index -> General Programming Questions
View unanswered posts
Author Message
Cheater
Senior Member
Senior Member


Joined: 10 Jun 2005
Posts: 236

Reputation: 15.8Reputation: 15.8

PostPosted: Tue Jun 14, 2005 12:44 pm    Post subject: Nexusbot brain.pl question Reply with quote

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
God Like


Joined: 07 Mar 2004
Posts: 579
Location: Maidstone
Reputation: 67.1
votes: 4

PostPosted: Tue Jun 14, 2005 1:15 pm    Post subject: Reply with quote

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
Senior Member


Joined: 10 Jun 2005
Posts: 236

Reputation: 15.8Reputation: 15.8

PostPosted: Tue Jun 14, 2005 1:16 pm    Post subject: Reply with quote

but there is no user folder
Back to top
JTW
God Like
God Like


Joined: 07 Mar 2004
Posts: 579
Location: Maidstone
Reputation: 67.1
votes: 4

PostPosted: Tue Jun 14, 2005 1:43 pm    Post subject: Reply with quote

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
Senior Member


Joined: 10 Jun 2005
Posts: 236

Reputation: 15.8Reputation: 15.8

PostPosted: Tue Jun 14, 2005 1:47 pm    Post subject: Reply with quote

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
God Like


Joined: 07 Mar 2004
Posts: 579
Location: Maidstone
Reputation: 67.1
votes: 4

PostPosted: Tue Jun 14, 2005 1:52 pm    Post subject: Reply with quote

(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
Senior Member


Joined: 10 Jun 2005
Posts: 236

Reputation: 15.8Reputation: 15.8

PostPosted: Tue Jun 14, 2005 1:58 pm    Post subject: Reply with quote

ok, thanks anyway
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Tue Jun 14, 2005 2:15 pm    Post subject: Reply with quote

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
Senior Member


Joined: 10 Jun 2005
Posts: 236

Reputation: 15.8Reputation: 15.8

PostPosted: Tue Jun 14, 2005 2:20 pm    Post subject: Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> General Programming Questions All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group