Menu

Getting user information problem

Scripting
2003-02-13
2003-02-13
  • Matthew Holmes

    Matthew Holmes - 2003-02-13

    I have written the following code and have used some code from other people in here for working out the tag to try and make a bot that will let you send a pm to it and will display information about a user.

    Here is the code:
    $botname = "BOT";

    sub main()
    {
        odch::register_script_name($botname);
    }

    sub data_arrival()
    {
        my($user, $data) = @_;
        if($data =~ /\$To: $botname From: $user \$<$user> !info/)
        {
        my(@userdata) = split(/<$user> !info /,$data);
    my($tmpdata) = odch::get_description($userdata[-1]);
    my($pos1) = rindex($tmpdata, "<") +1;
    my($pos2) = rindex($tmpdata, ">");
    $verdata = substr($tmpdata, $pos1, $pos2 - $pos1);
    my(@verdata2) = split(/\ /, $verdata);
    my($pos1) = rindex($tmpdata, "<@verdata2[0]") + length(@verdata2[0]);
    $tmpdata = substr($tmpdata, $pos1, $pos2 - $pos1);
    my(@tmpdata) = split(/,/, $tmpdata);
    $dcClient = @verdata2[0];
    $dcVersion = (split(/:/, $tmpdata[0]))[1];
    $ModeAP = (split(/:/, $tmpdata[1]))[1];
    $NbHubs = (split(/:/, $tmpdata[2]))[1];
    $NSlots = (split(/:/, $tmpdata[3]))[1];
    $UploadLimit = (split(/:/, $tmpdata[4]))[1];
    $dcVersion = odch::get_version($userdata[-1]);
    $conn = odch::get_connection($userdata[-1]);
    $share = odch::get_share($userdata[-1]);
    odch::data_to_all("\$To: $user From: $botname \$<$botname> User Name: $userdata[-1] |");
    odch::data_to_all("\$To: $user From: $botname \$<$botname> Description: $tmpdata |");
    odch::data_to_all("\$To: $user From: $botname \$<$botname> DC Version: $dcVersion |");
    odch::data_to_all("\$To: $user From: $botname \$<$botname> DC Client: $$dcClient |");
    odch::data_to_all("\$To: $user From: $botname \$<$botname> Mode A/P: $ModeAP |");
    odch::data_to_all("\$To: $user From: $botname \$<$botname> No of Hubs: $NbHubs |");
    odch::data_to_all("\$To: $user From: $botname \$<$botname> No of Slots: $NSlots |");
    odch::data_to_all("\$To: $user From: $botname \$<$botname> No of Upload Limit: $UploadLimit |");
    odch::data_to_all("\$To: $user From: $botname \$<$botname> Connection Type: $conn |");
    odch::data_to_all("\$To: $user From: $botname \$<$botname> Share Size: $share |");
    }
    }

    The problem is the responce i recieve only contains the user's information eg:

    <test> !info test
    <BOT> User Name: test
    <BOT> Description: 
    <BOT> DC Version: 
    <BOT> DC Client: 
    <BOT> Mode A/P: 
    <BOT> No of Hubs: 
    <BOT> No of Slots: 
    <BOT> No of Upload Limit: 
    <BOT> Connection Type: 
    <BOT> Share Size: 

    Will it be possible to get this to work? I am new to perl and odch so im not sure.

    Thanks for posting the scripts you have done as they have made this alot easier.

    Godfather

     
    • Robin Hill

      Robin Hill - 2003-02-13

      There's a few things here.  The major issue is that the username you're pulling out using the split still has a | on the end.  You'll need to strip this off first - chop($userdata[-1]) will work there.

      The second problem is with this line:
      my($pos1) = rindex($tmpdata, "<@verdata2[0]") + length(@verdata2[0]);
      Change it to:
      $pos1 = rindex($tmpdata, "<@verdata2[0]") + length(@verdata2[0]) + 1;
      since you've alreay got $pos1 declared and you'll need to skip another character for the leading <.

      Thirdly, you've got a double $$ when printing out the dcClient.

      Finally, instead of @verdata2[0], use $verdata2[0] since the elements of an array are scalars.

      Hope that's clear enough - the script still doesn't seem to print out the DC version so you'd be better off using $dcVersion rather than tring to pull back the client version from the hub.

      Cheers,
      Robin

       

Log in to post a comment.