Menu

User name from nick

Scripting
2003-02-15
2003-02-17
  • Matthew Holmes

    Matthew Holmes - 2003-02-15

    Has anybody got a fully working script for this? the ones already posted dont seem to work and i cant get them to work :(

    Any help would be appreciated
    Godfather

     
    • Henry Pyland

      Henry Pyland - 2003-02-15

      i got one for 7.4 but it seems to bog down because of the dc++ protection... and the other one that i posted does work too.... with 7.3

       
      • Matthew Holmes

        Matthew Holmes - 2003-02-15

        I need it to work with 0.7.5 and when i tried it nothing happened. What do you mean by bog down?

         
    • Robin Hill

      Robin Hill - 2003-02-15

      What user name do you mean?  I'm not aware of any user name (other than the nick) involved in the DC protocol.

       
    • Matthew Holmes

      Matthew Holmes - 2003-02-15

      Sorry i meant ip to username. I have tried the other ones that are posted but they do not appear to work.

       
    • Robin Hill

      Robin Hill - 2003-02-15

      This one works for me (with 0.7.5):

      sub user_from_ip {
      my ($IP) = @_;
      foreach (split(/ /, odch::get_user_list())) {
      if (odch::get_ip($_) eq $IP) {
      return $_;
      }
      }
      return "";
      }

       
      • Henry Pyland

        Henry Pyland - 2003-02-16

        i cant get this one to work.. what command do you use to get it to sub to work?

        btw rob1n.. thx for all the guidence and sorry bout the speeling... hehehe

         
        • Robin Hill

          Robin Hill - 2003-02-16

          Somethink like this:

          $botname = "IP";

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

          sub data_arrival()
          {
          my($user, $data) = @_;
          if($data =~ /getnick (.*?)|/)
          {
          my $result = user_from_ip($1);
          if ($result ne "") {
          odch::data_to_user($user, "<$botname> $1 belongs to $result|");
          } else {
          odch::data_to_user($user, "<$botname> Could not find user for $1|");
          }
          }
          }

           
    • Matthew Holmes

      Matthew Holmes - 2003-02-16

      Here is a working bot for 0.7.5 Thanks for the help guys

      $botname = "IP";

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

      sub new_user_connected()
      {
      my($user) = @_;
      $usersList{$user} = ($user);
      }

      sub op_admin_connected()
      {
      my($user) = @_;
      $usersList{$user} = ($user);
      }

      sub op_connected()
      {
      my($user) = @_;
      $usersList{$user} = ($user);
      }

      sub reg_user_connected()
      {
      my($user) = @_;
      $usersList{$user} = ($user);
      }

      sub data_arrival()
      {
          my($user, $data) = @_;
          if($data =~ /getnick/)
              {
              $poz1 = rindex($data, "getnick")+8;
              my($tmpdata) = substr($data, $poz1, -1);
              my(@uservalues) = values %usersList;
              while (@uservalues)
                  {
                  my($userval) = pop(@uservalues);
                  my($userIp) = odch::get_ip($userval);
                  if($tmpdata eq $userIp)
                      {
                      odch::data_to_user($user, "<$botname> $userIp belongs to $userval|");
                      }
                  }
              }
      }

      sub user_disconnect()
      {
      my($user) = @_;
      if(exists $usersList{$user})
      {

       
      • Henry Pyland

        Henry Pyland - 2003-02-16

        looks like this would stop working if you reloadscripts???

         
    • Matthew Holmes

      Matthew Holmes - 2003-02-16

      if you reload the scripts then the array will be lost wont it? so yes. sorry i know very little about perl.

       
      • Henry Pyland

        Henry Pyland - 2003-02-16

        salright.. hehehe i know very little about perl also thats why i had to ask...

         
      • AzaToth

        AzaToth - 2003-02-16

        Personally I think the smartest is to save all data in a sql-database (I use Mysql).

         
        • AzaToth

          AzaToth - 2003-02-17

          I do like this when I use mysql, firs sample outout:

          [01:15:27] User: +getip Another_user
          [01:15:27] AzaBoth:
          Name: Another_user
          IP: 10.0.0.2
          LONGIP: 167772162
          Online: 1
          [01:15:37] User: +getuser 10.0.0.2
          [01:15:37] AzaBoth:
          Name: Another_user
          IP: 10.0.0.2
          LONGIP: 167772162
          Online: 0
          [01:15:37] AzaBoth:
          Name: Another_user_1
          IP: 10.0.0.2
          LONGIP: 167772162
          Online: 0

          ___BEGIN___

                  if($data =~/\+getip/) {

                      my $theuser =  (split(/\ /, $data))[2];
                      chop($theuser);
                      my $teuser = $dbh->quote($theuser);
                      my $sth = $dbh->prepare("SELECT * FROM users WHERE user=$teuser");
                      $sth->execute();

                      while(my $ref = $sth->fetchrow_hashref()) {
                          odch::data_to_all("<$botname> \nName: $ref->{'user'}\nIP: $ref->{'ip'}\nLONGIP: $ref->{'longip'}\nOnline: $ref->{'online'}|");
                      }
                  }
                 
                  if($data =~/\+getuser/) {

                      my $theuser =  &quad2int((split(/\ /, $data))[2]);
                      my $sth = $dbh->prepare("SELECT * FROM users WHERE longip=$theuser");
                      $sth->execute();

                      while(my $ref = $sth->fetchrow_hashref()) {
                          odch::data_to_all("<$botname> \nName: $ref->{'user'}\nIP: $ref->{'ip'}\nLONGIP: $ref->{'longip'}\nOnline: $ref->{'online'}|");
                      }
                  }

          ___END___

           
          • AzaToth

            AzaToth - 2003-02-17

            Forgot :) : the script as it is now, is at: http://medlem.spray.se/brutalis/odchbot.html

             

Log in to post a comment.