Menu

All In one client

Scripting
2003-02-15
2003-03-05
  • Matthew Holmes

    Matthew Holmes - 2003-02-15

    I have been working on an all in one client and this is what i have so far. It seems to work so far but needs tweaking etc.

    #The Bots name
    $botname = "FRED";

    #Hub and Slot info 28.8k modem
    $m28hub = 1;
    $m28slot = 2;

    #Hub and Slot info 33.6k modem
    $m33hub = 1;
    $m33slot = 2;

    #Hub and Slot info 56k modem
    $m56hub = 1;
    $m56slot = 2;

    #Hub and Slot info for ISDN
    $isdnhub = 2;
    $isdnslot = 3;

    #Hub and Slot info for ISDN
    $isdnhub = 2;
    $isdnslot = 3;

    #Hub and Slot info for SAT
    $sathub = 2;
    $satslot = 3;

    #Hub and Slot info for DSL
    $dslhub = 9;
    $dslslot = 4;

    #Hub and Slot info for Cable
    $cablehub = 9;
    $cableslot = 4;

    #Hub and Slot info for LAN T1
    $lan1hub = 20;
    $lan1slot = 30;

    #Hub and Slot info for LAN T3
    $lan3hub = 20;
    $lan3slot = 30;

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

    sub added_perm_ban()
    {
        my($entry) = @_;
        odch::data_to_all("<$botname> added $entry to the ban list|");
    }

    sub op_connected()
    {
        my($user) = @_;
        odch::data_to_all ("<$botname> OP $user has logged on|");
    }

    sub op_admin_connected()
    {
        my($user) = @_;
        odch::data_to_all ("<$botname> Administrator $user has logged on|");   
    }

    sub new_user_connected()
    {
    my($user) = @_;
    my($tmpdata) = odch::get_description($user);
    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];
    $NbHubs = (split(/:/, $tmpdata[2]))[1];
    $NSlots = (split(/:/, $tmpdata[3]))[1];
    $UploadLimit = (split(/:/, $tmpdata[4]))[1];
    $conn = odch::get_connection($user);

    if(odch::get_description($user) =~ /mldonkey client/)
    {
    odch::data_to_user($user, "\$To: $nick From: $botname \$ Mldonkey is banned in this hub |");
    odch::kick_user($user);
    }

    if($NbHubs > $NSlots)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$Please open at least one slot per hub|");
    odch::kick_user($user);
    }
    if($conn =~ m/1/)
    {
    if($NbHubs > $m28hub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $m28hub |");
    odch::kick_user($user);
    }
    if($NSlots > $m28slot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $m28slot |");
    odch::kick_user($user);
    }
    }

    if($conn =~ m/2/)
    {
    if($NbHubs > $m33hub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $m33hub |");
    odch::kick_user($user);
    }
    if($NSlots > $m33slot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $m33slot |");
    odch::kick_user($user);
    }
    }

    if($conn =~ m/3/)
    {
    if($NbHubs > $m56hub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $m56hub |");
    odch::kick_user($user);
    }
    if($NSlots > $m56slot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $m56slot |");
    odch::kick_user($user);
    }
    }

    if($conn =~ m/4/)
    {
    if($NbHubs > $isdnhub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $isdnhub |");
    odch::kick_user($user);
    }
    if($NSlots > $isdnslot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $isdnslot |");
    odch::kick_user($user);
    }
    }

    if($conn =~ m/5/)
    {
    if($NbHubs > $sathub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $sathub |");
    odch::kick_user($user);
    }
    if($NSlots > $satslot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $satslot |");
    odch::kick_user($user);
    }
    }

    if($conn =~ m/6/)
    {
    if($NbHubs > $dslhub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $dslhub |");
    odch::kick_user($user);
    }
    if($NSlots > $dslslot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $dslslot |");
    odch::kick_user($user);
    }
    }

    if($conn =~ m/7/)
    {
    if($NbHubs > $cablehub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $cablehub |");
    odch::kick_user($user);
    }
    if($NSlots > $cableslot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $cableslot |");
    odch::kick_user($user);
    }
    }

    if($conn =~ m/8/)
    {
    if($NbHubs > $lan1hub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $lan1hub |");
    odch::kick_user($user);
    }
    if($NSlots > $lan1slot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $lan1slot |");
    odch::kick_user($user);
    }
    }

    if($conn =~ m/9/)
    {
    if($NbHubs > $lan3hub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $lan3hub |");
    odch::kick_user($user);
    }
    if($NSlots > $lan3slot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $lan3slot |");
    odch::kick_user($user);
    }
    }

    } #final one

    sub reg_user_connected()
    {
    my($user) = @_;
    my($user) = @_;
    my($tmpdata) = odch::get_description($user);
    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];
    $NbHubs = (split(/:/, $tmpdata[2]))[1];
    $NSlots = (split(/:/, $tmpdata[3]))[1];
    $UploadLimit = (split(/:/, $tmpdata[4]))[1];
    $conn = odch::get_connection($user);

    if($tmpdata =~ /mldonkey client/)
    {
    odch::data_to_user($user, "\$To: $nick From: $botname \$ Mldonkey is banned in this hub |");
    odch::kick_user($user);
    }

    if($NbHubs > $NSlots)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$Please open at least one slot per hub|");
    odch::kick_user($user);
    }
    if($conn =~ m/1/)
    {
    if($NbHubs > $m28hub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $m28hub |");
    odch::kick_user($user);
    }
    if($NSlots > $m28slot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $m28slot |");
    odch::kick_user($user);
    }
    }

    if($conn =~ m/2/)
    {
    if($NbHubs > $m33hub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $m33hub |");
    odch::kick_user($user);
    }
    if($NSlots > $m33slot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $m33slot |");
    odch::kick_user($user);
    }
    }

    if($conn =~ m/3/)
    {
    if($NbHubs > $m56hub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $m56hub |");
    odch::kick_user($user);
    }
    if($NSlots > $m56slot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $m56slot |");
    odch::kick_user($user);
    }
    }

    if($conn =~ m/4/)
    {
    if($NbHubs > $isdnhub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $isdnhub |");
    odch::kick_user($user);
    }
    if($NSlots > $isdnslot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $isdnslot |");
    odch::kick_user($user);
    }
    }

    if($conn =~ m/5/)
    {
    if($NbHubs > $sathub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $sathub |");
    odch::kick_user($user);
    }
    if($NSlots > $satslot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $satslot |");
    odch::kick_user($user);
    }
    }

    if($conn =~ m/6/)
    {
    if($NbHubs > $dslhub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $dslhub |");
    odch::kick_user($user);
    }
    if($NSlots > $dslslot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $dslslot |");
    odch::kick_user($user);
    }
    }

    if($conn =~ m/7/)
    {
    if($NbHubs > $cablehub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $cablehub |");
    odch::kick_user($user);
    }
    if($NSlots > $cableslot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $cableslot |");
    odch::kick_user($user);
    }
    }

    if($conn =~ m/8/)
    {
    if($NbHubs > $lan1hub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $lan1hub |");
    odch::kick_user($user);
    }
    if($NSlots > $lan1slot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $lan1slot |");
    odch::kick_user($user);
    }
    }

    if($conn =~ m/9/)
    {
    if($NbHubs > $lan3hub)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $lan3hub |");
    odch::kick_user($user);
    }
    if($NSlots > $lan3slot)
    {
    odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $lan3slot |");
    odch::kick_user($user);
    }
    }

    } #final one

    sub data_arrival()
    {
        my($user, $data) = @_;
        my($usertype) = odch::get_type($user);
            if($usertype =~ /(16|32|64)/g)
            {
            if($data =~ /^<.*> !info .+/i)
            {
                my(@userdata) = split(/<$user> !info /,$data);
                chop($userdata[-1]);
                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]);
                $ip = odch::get_ip($userdata[-1]);
                $sharegb = ($share/1073741824);
                odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> User Name: $userdata[-1] |");
                odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> IP: $ip |");
                odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> DC Version: $dcVersion |");
                odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Mode A/P: $ModeAP |");
                odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> No of Hubs: $NbHubs |");
                odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> No of Slots: $NSlots |");
                odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> No of Upload Limit: $UploadLimit |");
                if($conn =~ m/1/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: 28.8K Modem |");}
                if($conn =~ m/2/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: 33.6K Modem |");}
                if($conn =~ m/3/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: 56K Modem |");}
                if($conn =~ m/4/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: Satellite |");}
                if($conn =~ m/5/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: ISDN |");}
                if($conn =~ m/6/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: DSL |");}
                if($conn =~ m/7/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: Cable |");}
                if($conn =~ m/8/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: LAN T1 |");}
                if($conn =~ m/9/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: LAN T3 |");}
                odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Share Size: $sharegb GB |");
            }
            }

    my($usertype) = odch::get_type($user);
    if($usertype =~ /(32|64)/g)
    {
    if($data =~ /^<.*> !announce .+/i)
    {
    $data =~ s/<$user> !announce //ig;
    chop($data);
    odch::data_to_all("<$botname> $data|");
    }
    }
    } #end one

     
    • Anonymous

      Anonymous - 2003-02-27

      For some reason the bot wont send any of those messages to a user. Any particular reason maybe?

       
      • Matthew Holmes

        Matthew Holmes - 2003-02-27

        I had made a few mistakes on this one which i hadnt noticed. I am in the process of making a new bot now.

         
    • Anonymous

      Anonymous - 2003-02-28

      This generally looks good. But i see alot of code being written again anda again.

      You should consider using specific functions to save you some time. For instance you do alot of description checking, why not make a function for it?

      But otherwise, good job, nice to see some bot examples.

       
      • Matthew Holmes

        Matthew Holmes - 2003-02-28

        When i started the bot i didnt know any perl at all so some is very basic. Im currently in the process of making it more efficient and adding more features.

         
    • Lost Soul

      Lost Soul - 2003-03-04

      The hub that me and Godfather run has been using this bot for a few weeks now, I can confirm that it is stable and does it's job well :D Needs tweaking for individual hubs though, and a small modification to hub sourcecode to surpress the !command not found messages.

       
      • Matthew Holmes

        Matthew Holmes - 2003-03-04

        This is the new version with a few improvements. Registered users are classed as vips and so do not have a min share etc. Also fixed a few bugs.

        #The Bots name
        $botname = "FRED";

        #Hub and Slot info 28.8k modem
        $m28hub = 1;
        $m28slot = 2;

        #Hub and Slot info 33.6k modem
        $m33hub = 1;
        $m33slot = 2;

        #Hub and Slot info 56k modem
        $m56hub = 1;
        $m56slot = 2;

        #Hub and Slot info for ISDN
        $isdnhub = 2;
        $isdnslot = 3;

        #Hub and Slot info for SAT
        $sathub = 2;
        $satslot = 3;

        #Hub and Slot info for DSL
        $dslhub = 9;
        $dslslot = 4;

        #Hub and Slot info for Cable
        $cablehub = 9;
        $cableslot = 4;

        #Hub and Slot info for LAN T1
        $lan1hub = 20;
        $lan1slot = 30;

        #Hub and Slot info for LAN T3
        $lan3hub = 20;
        $lan3slot = 30;

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

        sub added_perm_ban()
        {
            my($entry) = @_;
            odch::data_to_all("<$botname> Added $entry to the ban list|");
        }

        sub op_connected()
        {
            my($user) = @_;
            $usersList{$user} = ($user);
            odch::data_to_all("<$botname> OP $user has logged on|");
        }

        sub op_admin_connected()
        {
            my($user) = @_;
            $usersList{$user} = ($user);
            odch::data_to_all("<$botname> Administrator $user has logged on|");   
        }

        sub new_user_connected()
        {
        my($user) = @_;
        $usersList{$user} = ($user);
        my($tmpdata) = odch::get_description($user);
        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];
        $NbHubs = (split(/:/, $tmpdata[2]))[1];
        $NSlots = (split(/:/, $tmpdata[3]))[1];
        $UploadLimit = (split(/:/, $tmpdata[4]))[1];
        $conn = odch::get_connection($user);

        if(odch::get_description($user) =~ /mldonkey client/)
        {
        odch::data_to_user($user, "\$To: $nick From: $botname \$ Mldonkey is banned in this hub |");
        odch::kick_user($user);
        }

        if($NbHubs > $NSlots)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$Please open at least one slot per hub|");
        odch::kick_user($user);
        }

        if($conn =~ m/1/)
        {
        if($NbHubs > $m28hub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $m28hub |");
        odch::kick_user($user);
        }
        if($NSlots > $m28slot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $m28slot |");
        odch::kick_user($user);
        }
        }

        if($conn =~ m/2/)
        {
        if($NbHubs > $m33hub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $m33hub |");
        odch::kick_user($user);
        }
        if($NSlots > $m33slot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $m33slot |");
        odch::kick_user($user);
        }
        }

        if($conn =~ m/3/)
        {
        if($NbHubs > $m56hub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $m56hub |");
        odch::kick_user($user);
        }
        if($NSlots > $m56slot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $m56slot |");
        odch::kick_user($user);
        }
        }

        if($conn =~ m/4/)
        {
        if($NbHubs > $isdnhub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $isdnhub |");
        odch::kick_user($user);
        }
        if($NSlots > $isdnslot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $isdnslot |");
        odch::kick_user($user);
        }
        }

        if($conn =~ m/5/)
        {
        if($NbHubs > $sathub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $sathub |");
        odch::kick_user($user);
        }
        if($NSlots > $satslot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $satslot |");
        odch::kick_user($user);
        }
        }

        if($conn =~ m/6/)
        {
        if($NbHubs > $dslhub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $dslhub |");
        odch::kick_user($user);
        }
        if($NSlots > $dslslot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $dslslot |");
        odch::kick_user($user);
        }
        }

        if($conn =~ m/7/)
        {
        if($NbHubs > $cablehub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $cablehub |");
        odch::kick_user($user);
        }
        if($NSlots > $cableslot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $cableslot |");
        odch::kick_user($user);
        }
        }

        if($conn =~ m/8/)
        {
        if($NbHubs > $lan1hub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $lan1hub |");
        odch::kick_user($user);
        }
        if($NSlots > $lan1slot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $lan1slot |");
        odch::kick_user($user);
        }
        }

        if($conn =~ m/9/)
        {
        if($NbHubs > $lan3hub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $lan3hub |");
        odch::kick_user($user);
        }
        if($NSlots > $lan3slot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $lan3slot |");
        odch::kick_user($user);
        }
        }

        } #final one

        sub reg_user_connected()
        {
        my($user) = @_;
        $usersList{$user} = ($user); 
        my($tmpdata) = odch::get_description($user);
        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];
        $NbHubs = (split(/:/, $tmpdata[2]))[1];
        $NSlots = (split(/:/, $tmpdata[3]))[1];
        $UploadLimit = (split(/:/, $tmpdata[4]))[1];
        $conn = odch::get_connection($user);

        if($tmpdata =~ /mldonkey client/)
        {
        odch::data_to_user($user, "\$To: $nick From: $botname \$ Mldonkey is banned in this hub |");
        odch::kick_user($user);
        }

        if($NbHubs > $NSlots)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$Please open at least one slot per hub|");
        odch::kick_user($user);
        }
        if($conn =~ m/1/)
        {
        if($NbHubs > $m28hub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $m28hub |");
        odch::kick_user($user);
        }
        if($NSlots > $m28slot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $m28slot |");
        odch::kick_user($user);
        }
        }

        if($conn =~ m/2/)
        {
        if($NbHubs > $m33hub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $m33hub |");
        odch::kick_user($user);
        }
        if($NSlots > $m33slot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $m33slot |");
        odch::kick_user($user);
        }
        }

        if($conn =~ m/3/)
        {
        if($NbHubs > $m56hub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $m56hub |");
        odch::kick_user($user);
        }
        if($NSlots > $m56slot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $m56slot |");
        odch::kick_user($user);
        }
        }

        if($conn =~ m/4/)
        {
        if($NbHubs > $isdnhub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $isdnhub |");
        odch::kick_user($user);
        }
        if($NSlots > $isdnslot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $isdnslot |");
        odch::kick_user($user);
        }
        }

        if($conn =~ m/5/)
        {
        if($NbHubs > $sathub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $sathub |");
        odch::kick_user($user);
        }
        if($NSlots > $satslot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $satslot |");
        odch::kick_user($user);
        }
        }

        if($conn =~ m/6/)
        {
        if($NbHubs > $dslhub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $dslhub |");
        odch::kick_user($user);
        }
        if($NSlots > $dslslot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $dslslot |");
        odch::kick_user($user);
        }
        }

        if($conn =~ m/7/)
        {
        if($NbHubs > $cablehub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $cablehub |");
        odch::kick_user($user);
        }
        if($NSlots > $cableslot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $cableslot |");
        odch::kick_user($user);
        }
        }

        if($conn =~ m/8/)
        {
        if($NbHubs > $lan1hub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $lan1hub |");
        odch::kick_user($user);
        }
        if($NSlots > $lan1slot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $lan1slot |");
        odch::kick_user($user);
        }
        }

        if($conn =~ m/9/)
        {
        if($NbHubs > $lan3hub)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $lan3hub |");
        odch::kick_user($user);
        }
        if($NSlots > $lan3slot)
        {
        odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $lan3slot |");
        odch::kick_user($user);
        }
        }

        } #final one

        sub data_arrival()
        {
        my($user, $data) = @_;
        my($usertype) = odch::get_type($user);

        if($data =~ /(\+help|\+away|\+op|\+admin|\+rules)/i)
        {
        odch::data_to_user($user, "<$botname> This server doesn't use the + commands sorry |");
        }

        if($data =~ /^.*Search.*(incesticide|scraped|nirvana|grape|drape)/i)
        {
        }
        else
        {
        if($data =~ /^.*Search.*(incest|preteen|pre-teen|rape)/i)
        {
        if($usertype =~ /(4|8)/)
        {
        $ip = odch::get_ip($user);
        chop($data);
        $data =~ s/^.Search.*\?//i;
        $data =~ s/\$/ /g;
        odch::data_to_user($user, "\$To: $user From: $botname \$Banned as you were searching for $data |");
        odch::kick_user($user);
        odch::add_ban_entry($ip);
        odch::data_to_all("<$botname> $user was banned as they were searching for $data!|");
        }
        }
        }

        if($usertype =~ /(16|32|64)/g)
        {

        if($data =~ /^<.*> !info .+/i)
        {
        my(@userdata) = split(/<$user> !info /,$data);
        chop($userdata[-1]);
        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]);
        $ip = odch::get_ip($userdata[-1]);
        $sharegb = ($share/1073741824);
        odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> User Name: $userdata[-1] |");
        odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> IP: $ip |");
        odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> DC Version: $dcVersion |");
        odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Mode A/P: $ModeAP |");
        odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> No of Hubs: $NbHubs |");
        odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> No of Slots: $NSlots |");
        odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> No of Upload Limit: $UploadLimit |");
        if($conn =~ m/1/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: 28.8K Modem |");}
        if($conn =~ m/2/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: 33.6K Modem |");}
        if($conn =~ m/3/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: 56K Modem |");}
        if($conn =~ m/4/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: Satellite |");}
        if($conn =~ m/5/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: ISDN |");}
        if($conn =~ m/6/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: DSL |");}
        if($conn =~ m/7/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: Cable |");}
        if($conn =~ m/8/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: LAN T1 |");}
        if($conn =~ m/9/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: LAN T3 |");}
        odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Share Size: $sharegb GB |");
        }

        if($data =~ /^<.*> !lock .+/i)
        {
        $data =~ s/<$user> !lock //ig;
        chop($data);
        my($rnd1) = int(rand(10));
        my($rnd2) = int(rand(10));
        my($rnd3) = int(rand(10));
        my($rnd4) = int(rand(10));
        my($rnd5) = int(rand(10));
        my($rnda)  = chr(int(rand(25))+65);
        my($rndb)  = chr(int(rand(25))+65);
        my($rndc)  = chr(int(rand(25))+65);
        my($rnd0) = $rnda . $rndb . $rndc . $rnd1 . $rnd2 . $rnd3 . $rnd4 . $rnd5;
        odch::data_to_user($user, "<$botname> $data is now passworded|");
        odch::add_reg_user($data, $rnd0, 0);
        }

        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|");
        }
        }
        }

        } #end of op + admin

        my($usertype) = odch::get_type($user);
        if($usertype =~ /(32|64)/g)
        {

        if($data =~ /^<.*> !announce .+/i)
        {
        $data =~ s/<$user> !announce //ig;
        chop($data);
        odch::data_to_all("<$botname> $data|");
        }

        } #end of admin
        } #end one

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

         
    • Matthew Holmes

      Matthew Holmes - 2003-03-04

      Ok i posted the wrong one there :\ thats an old one. This is the one you want.

      #The Bots name
      $botname = "FRED";

      #Minshare
      $minshare=5368709120;

      #Hub and Slot info 28.8k modem
      $m28hub = 1;
      $m28slot = 2;

      #Hub and Slot info 33.6k modem
      $m33hub = 1;
      $m33slot = 2;

      #Hub and Slot info 56k modem
      $m56hub = 1;
      $m56slot = 3;

      #Hub and Slot info for ISDN
      $isdnhub = 2;
      $isdnslot = 3;

      #Hub and Slot info for SAT
      $sathub = 2;
      $satslot = 4;

      #Hub and Slot info for DSL
      $dslhub = 7;
      $dslslot = 10;

      #Hub and Slot info for Cable
      $cablehub = 7;
      $cableslot = 10;

      #Hub and Slot info for LAN T1
      $lan1hub = 20;
      $lan1slot = 30;

      #Hub and Slot info for LAN T3
      $lan3hub = 30;
      $lan3slot = 50;

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

      sub new_user_connected()
      {
      my($user) = @_;
      $useripadd = odch::get_ip($user);
      my(@uservalues) = values %usersList;
      while (@uservalues)
      {
      my($userval) = pop(@uservalues);
      $usersip = odch::get_ip($userval);
      if($useripadd eq $usersip)
      {
      odch::data_to_user($user, "<$botname> You can only log into the hub once at a time |");
      odch::kick_user($user);
      odch::remove_ban_entry($useripadd);
      }
      }
      $usersList{$user} = ($user);
      my($tmpdata) = odch::get_description($user);
      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];
      $NbHubs = (split(/:/, $tmpdata[2]))[1];
      $NSlots = (split(/:/, $tmpdata[3]))[1];
      $UploadLimit = (split(/:/, $tmpdata[4]))[1];
      $conn = odch::get_connection($user);

      if(odch::get_description($user) =~ /mldonkey client/)
      {
      odch::data_to_user($user, "\$To: $nick From: $botname \$ Mldonkey is banned in this hub |");
      odch::kick_user($user);
      }

      if($NbHubs > $NSlots)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$Please open at least one slot per hub|");
      odch::kick_user($user);
      }

      if($conn =~ m/1/)
      {
      if($NbHubs > $m28hub)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $m28hub |");
      odch::kick_user($user);
      }
      if($NSlots > $m28slot)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $m28slot |");
      odch::kick_user($user);
      }
      }

      if($conn =~ m/2/)
      {
      if($NbHubs > $m33hub)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $m33hub |");
      odch::kick_user($user);
      }
      if($NSlots > $m33slot)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $m33slot |");
      odch::kick_user($user);
      }
      }

      if($conn =~ m/3/)
      {
      if($NbHubs > $m56hub)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $m56hub |");
      odch::kick_user($user);
      }
      if($NSlots > $m56slot)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $m56slot |");
      odch::kick_user($user);
      }
      }

      if($conn =~ m/4/)
      {
      if($NbHubs > $isdnhub)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $isdnhub |");
      odch::kick_user($user);
      }
      if($NSlots > $isdnslot)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $isdnslot |");
      odch::kick_user($user);
      }
      }

      if($conn =~ m/5/)
      {
      if($NbHubs > $sathub)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $sathub |");
      odch::kick_user($user);
      }
      if($NSlots > $satslot)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $satslot |");
      odch::kick_user($user);
      }
      }

      if($conn =~ m/6/)
      {
      if($NbHubs > $dslhub)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $dslhub |");
      odch::kick_user($user);
      }
      if($NSlots > $dslslot)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $dslslot |");
      odch::kick_user($user);
      }
      }

      if($conn =~ m/7/)
      {
      if($NbHubs > $cablehub)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $cablehub |");
      odch::kick_user($user);
      }
      if($NSlots > $cableslot)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $cableslot |");
      odch::kick_user($user);
      }
      }

      if($conn =~ m/8/)
      {
      if($NbHubs > $lan1hub)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $lan1hub |");
      odch::kick_user($user);
      }
      if($NSlots > $lan1slot)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $lan1slot |");
      odch::kick_user($user);
      }
      }

      if($conn =~ m/9/)
      {
      if($NbHubs > $lan3hub)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You are in too many hubs, the limit for your connection is $lan3hub |");
      odch::kick_user($user);
      }
      if($NSlots > $lan3slot)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$You have too many slots open, the limit for your connection is $lan3slot |");
      odch::kick_user($user);
      }
      }

      } #final one

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

      sub data_arrival()
      {
      my($user, $data) = @_;
      my($usertype) = odch::get_type($user);
      if($data =~ /<$user>/)
      {
      }
      else
      {
      if($data =~ /^.*Search.*(incesticide|scraped|nirvana|grape|drape|byterapers)/i)
      {
      }
      else
      {
      if($data =~ /^.*Search.*(incest|preteen|pre-teen|rape)/i)
      {
      if($usertype =~ /(4|8)/)
      {
      $ip = odch::get_ip($user);
      chop($data);
      $data =~ s/^.Search.*\?//i;
      $data =~ s/\$/ /g;
      odch::data_to_user($user, "\$To: $user From: $botname \$Banned as you were searching for $data |");
      odch::add_ban_entry($ip);
      odch::kick_user($user);
      odch::data_to_all("<$botname> $user was banned as they were looking for $data!|");
      odch::data_to_all("<$botname> Added $ip to the ban list|");
      }
      }
      }
      }

      if($data =~ /myinfo/i)
      {
      $share = odch::get_share($user);
      if($share < $minshare)
      {
      if($usertype =~ /4/)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$Please share at least 5GB |");
      odch::kick_user($user);
      }
      }
      }

      if($data =~ /^<.*> \+rules/i)
      {
      odch::data_to_user($user, "<$botname> Please use !rules instead |");
      }

      if($data =~ /^<.*> \+op/i)
      {
      odch::data_to_user($user, "<$botname> Please use !op instead |");
      }

      if($data =~ /^<.*> \+help/i)
      {
      odch::data_to_user($user, "<$botname> Please use !help instead|");
      }

      if($data =~ /^<.*> \+away/i)
      {
      odch::data_to_user($user, "<$botname> This hub does not support the +away command, if you are using dc++ try /away instead |");
      }

      if($data =~ /^<.*> \+admin/i)
      {
      odch::data_to_user($user, "<$botname> Please use !op instead|");
      }

      if($data =~ /^<.*> \+op/i)
      {
      odch::data_to_user($user, "<$botname> Please use !op instead|");
      }

      if($data =~ /^<.*> !help/i)
      {
      my($usertype) = odch::get_type($user);
      if($usertype =~ /(16)/g)
      {
      odch::data_to_user($user, "\$To: $nick From: $botname \$*** OP Help ***|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$ |");
      odch::data_to_user($user, "\$To: $nick From: $botname \$To see what commands you have type !commands |");
      }
      else
      {
      odch::data_to_user($user, "\$To: $nick From: $botname \$*** Hub Help ***|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$ |");
      odch::data_to_user($user, "\$To: $nick From: $botname \$If you dont know what to do ask an op|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$To read the rules type !rules|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$To see who the op's are type !op|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$For more informatin visit our discussion forums: http://lostie.dyns.cx/ |");
      }
      }

      if($data =~ /^<.*> !rules/i)
      {
      odch::data_to_user($user, "\$To: $nick From: $botname \$*** Hub rules ***|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$ |");
      odch::data_to_user($user, "\$To: $nick From: $botname \$1.\) Share at least 5 gig of USEFUL files (sharing VOBs, installed apps, etc. for the sole purpose of boosting your share will get you banned)|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$2.\) Have at least 1 slot per hub|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$3.\) People using hacked clients will be banned|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$4.\) No underage porn|");
      }

      if($data =~ /^<.*> !op/i)
      {
      odch::data_to_user($user, "\$To: $nick From: $botname \$***OP List***|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$ |");
      odch::data_to_user($user, "\$To: $nick From: $botname \$Owner|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$Lostie|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$ |");
      odch::data_to_user($user, "\$To: $nick From: $botname \$Admin's |");
      odch::data_to_user($user, "\$To: $nick From: $botname \$Candidate|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$Neon|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$Godfather|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$ |");
      odch::data_to_user($user, "\$To: $nick From: $botname \$OP's |");
      odch::data_to_user($user, "\$To: $nick From: $botname \$LUC1FER|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$Tallen|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$Rollins|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$s-p|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$WALES|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$[UK]Sassy_Girl|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$Diakatarnis|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$[-Stash-]|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$[1mbit]BrenOS|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$NOIZEY|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$Chewie|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$[UK]Darkhorse|");
      odch::data_to_user($user, "\$To: $nick From: $botname \$Iycanthropy|");
      }

      if($usertype =~ /(16|32|64)/g)
      {

      if($data =~ /^<.*> !info/i)
      {
      my(@userdata) = split(/!info /,$data);
      chop($userdata[-1]);
      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]);
      $ip = odch::get_ip($userdata[-1]);
      $sharegb = ($share/1073741824);
      $usertype = odch::get_type($userdata[-1]);
      $desc = odch::get_description($userdata[-1]);
      if($usertype =~ m/0/)
      {
      odch::data_to_user($user, "<$botname> User $userdata[-1] not in hub |");
      }
      else
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> User Name: $userdata[-1] |");
      odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Description: $desc |");
      odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> ip: $ip |");
      odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> DC Version: $dcVersion |");
      odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Mode A/P: $ModeAP |");
      odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> No of Hubs: $NbHubs |");
      odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> No of Slots: $NSlots |");
      odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Upload Limit: $UploadLimit |");
      if($conn =~ m/1/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: 28.8K Modem |");}
      if($conn =~ m/2/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: 33.6K Modem |");}
      if($conn =~ m/3/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: 56K Modem |");}
      if($conn =~ m/4/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: Satellite |");}
      if($conn =~ m/5/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: ISDN |");}
      if($conn =~ m/6/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: DSL |");}
      if($conn =~ m/7/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: Cable |");}
      if($conn =~ m/8/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: LAN T1 |");}
      if($conn =~ m/9/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Connection Type: LAN T3 |");}
      odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Share Size: $sharegb GB |");
      if($usertype =~ m/4/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> User Type: Regular |");}
      if($usertype =~ m/8/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> User Type: Registered |");}
      if($usertype =~ m/16/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> User Type: OP |");}
      if($usertype =~ m/32/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> User Type: Admin |");}
      if($usertype =~ m/64/){ odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> User Type: Telnet Admin |");}
      }
      }

      if($data =~ /^<.*> !lock/i)
      {
      my(@userdata) = split(/$Userip /,$data);
      chop($userdata[-1]);
      $usertype = odch::check_if_registered($userdata[-1]);
      if($usertype =~ /2/)
      {
      odch::data_to_user($user, "<$botname> User: $userdata[-1] is an OP you cannot lock their name|");
      }
      if($usertype =~ /3/)
      {
      odch::data_to_user($user, "<$botname> User: $userdata[-1] is an ADMIN you cannot lock their name|");
      }
      if($usertype =~ /(0|1)/)
      {
      if($usertype =~ /1/)
      {
      odch::remove_reg_user($userdata[-1]);
      }
      my($rand1) = chr(int(rand(25))+65);
      my($rand2) = chr(int(rand(25))+65);
      my($rand3) = chr(int(rand(25))+65);
      my($rand4) = int(rand(10));
      my($rand5) = int(rand(10));
      my($rand6) = int(rand(10));
      my($rand7) = int(rand(10));
      my($rand8) = int(rand(10));
      my($rand) = $rand1 . $rand2 . $rand3 . $rand4 . $rand5 . $rand6 . $rand7 . $rand8;
      odch::data_to_user($user, "<$botname> $userdata[-1] is now passworded|");
      odch::add_reg_user($userdata[-1], $rand, 0);
      }
      }

      if($data =~ /\$Userip/i)
      {
      my(@userdata) = split(/$Userip /,$data);
      chop($userdata[-1]);
      $ip = odch::get_ip($userdata[-1]);
      odch::data_to_user($user, "<$botname> $userdata[-1] has ip: $ip |");
      }

      if($data =~ /^<.*> !nickban/i)
      {
      my(@userdata) = split(/!nickban /,$data);
      chop($userdata[-1]);
      $tmpdata = odch::get_ip($userdata[-1]);
      $usertype = odch::get_type($userdata[-1]);
      if($usertype =~ m/0/)
      {
      odch::data_to_user($user, "<$botname> User $userdata[-1] not in hub |");
      }
      else
      {
      $banned = "0";
      open(banlist, "/root/.opendchub/banlist");
      @banlist = <banlist>;
      close(banlist);
      foreach $ban (@banlist)
      {
      $bantext = "$ban";
      if($bantext =~ "$tmpdata 0")
      {
      $banned = "1";
      }
      }
      if($banned =~ /1/)
      {
      odch::data_to_user($user, "<$botname> ip: $userdata[-1] is already in the ban list |");
      }
      else
      {
      odch::data_to_user($user, "<$botname> ip: $tmpdata added to banlist |");
      odch::add_ban_entry($tmpdata);
      }
      }
      }

      if($data =~ /^<.*> !checkban/i)
      {
      $banned = "0";
      my(@userdata) = split(/!checkban /,$data);
      chop($userdata[-1]);
      open(banlist, "/root/.opendchub/banlist");
      @banlist = <banlist>;
      close(banlist);
      foreach $ban (@banlist)
      {
      $bantext = "$ban";
      if($bantext =~ "$userdata[-1]")
      {
      $banned = "1";
      }
      }
      if($banned =~ /1/)
      {
      odch::data_to_user($user, "<$botname> ip: $userdata[-1] is in the ban list |");
      }
      else
      {
      odch::data_to_user($user, "<$botname> ip: $userdata[-1] is not in the ban list |");
      }
      }

      } #end of op + admin

      my($usertype) = odch::get_type($user);
      if($usertype =~ /(32|64)/g)
      {

      if($data =~ /^<.*> !announce/i)
      {
      my(@userdata) = split(/!announce /,$data);
      chop($userdata[-1]);
      odch::data_to_all("<$botname> $userdata[-1]|");
      }

      } #end of admin

      if($usertype =~ /16/g)
      {

      if($data =~ /^<.*> !ban/i)
      {
      my(@userdata) = split(/!ban /,$data);
      chop($userdata[-1]);
      $banned = "0";
      open(banlist, "/root/.opendchub/banlist");
      @banlist = <banlist>;
      close(banlist);
      foreach $ban (@banlist)
      {
      $bantext = "$ban";
      if($bantext =~ "$userdata[-1] 0")
      {
      $banned = "1";
      }
      }
      if($banned =~ /1/)
      {
      odch::data_to_user($user, "<$botname> ip: $userdata[-1] is already in the ban list |");
      }
      else
      {
      odch::data_to_user($user, "<$botname> ip: $userdata[-1] added to banlist |");
      odch::add_ban_entry($userdata[-1]);
      }
      }

      if($data =~ /^<.*> !unban/i)
      {
      my(@userdata) = split(/!unban /,$data);
      chop($userdata[-1]);
      $banned = "0";
      open(banlist, "/root/.opendchub/banlist");
      @banlist = <banlist>;
      close(banlist);
      foreach $ban (@banlist)
      {
      $bantext = "$ban";
      if($bantext =~ "$userdata[-1] 0")
      {
      $banned = "1";
      }
      }
      if($banned =~ /0/)
      {
      odch::data_to_user($user, "<$botname> ip: $userdata[-1] is not in the ban list |");
      }
      else
      {
      odch::data_to_user($user, "<$botname> ip: $userdata[-1] removed from banlist |");
      odch::remove_ban_entry($userdata[-1]);
      }
      }

      if($data =~ /^<.*> !allow/i)
      {
      my(@userdata) = split(/!allow /,$data);
      chop($userdata[-1]);
      $allowed = "0";
      open(allowlist, "/root/.opendchub/allowlist");
      @allowlist = <allowlist>;
      close(banlist);
      foreach $allow (@allowlist)
      {
      $allowtext = "$allow";
      if($allowtext =~ "$userdata[-1] 0")
      {
      $allowed = "1";
      }
      }
      if($allowed =~ /1/)
      {
      odch::data_to_user($user, "<$botname> ip: $userdata[-1] is already in the allow list |");
      }
      else
      {
      odch::data_to_user($user, "<$botname> ip: $userdata[-1] added to allow list |");
      odch::add_allow_entry($userdata[-1]);
      }
      }

      if($data =~ /^<.*> !unallow/i)
      {
      my(@userdata) = split(/!unallow /,$data);
      chop($userdata[-1]);
      $allowed = "0";
      open(allowlist, "/root/.opendchub/allowlist");
      @allowlist = <allowlist>;
      close(banlist);
      foreach $allow (@allowlist)
      {
      $allowtext = "$allow";
      if($allowtext =~ "$userdata[-1] 0")
      {
      $allowed = "1";
      }
      }
      if($allowed =~ /0/)
      {
      odch::data_to_user($user, "<$botname> ip: $userdata[-1] is not in the allow list |");
      }
      else
      {
      odch::data_to_user($user, "<$botname> ip: $userdata[-1] removed to allow list |");
      odch::remove_allow_entry($userdata[-1]);
      }
      }

      if($data =~ /^<.*> !getip/i)
      {
      my(@userdata) = split(/!getip /,$data);
      chop($userdata[-1]);
      $userdata = odch::get_ip($userdata[-1]);
      $usertype = odch::get_type($userdata[-1]);
      if($usertype =~ m/0/)
      {
      odch::data_to_user($user, "<$botname> User $userdata[-1] not in hub |");
      }
      else
      {
      odch::data_to_user($user, "<$botname> $userdata[-1] has ip: $userdata |");
      }
      }

      if($data =~ /^<.*> !gethost/i)
      {
      my(@userdata) = split(/!gethost /,$data);
      chop($userdata[-1]);
      $userdata = odch::get_hostname($userdata[-1]);
      $usertype = odch::get_type($userdata[-1]);
      if($usertype =~ m/0/)
      {
      odch::data_to_user($user, "<$botname> User $userdata[-1] not in hub |");
      }
      else
      {
      odch::data_to_user($user, "<$botname> $userdata[-1] has hostname: $userdata |");
      }
      }

      if($data =~ /^<.*> !commands/i)
      {
      odch::data_to_user($user, "\$To: $user From: $botname \$<$botname> Commands available to OP's |");
      odch::data_to_user($user, "\$To: $user From: $botname \$|");
      odch::data_to_user($user, "\$To: $user From: $botname \$!commands (Shows this list of commands)|");
      odch::data_to_user($user, "\$To: $user From: $botname \$!info 'nick' (Tells you the User Name, Description, ip, DC Version, Mode A/P, Number of Hubs, Number of Slots, Upload limit, Connection Type, Share Size and User Type)|");
      odch::data_to_user($user, "\$To: $user From: $botname \$!lock 'nick' (Locks a username with a random password)|");
      odch::data_to_user($user, "\$To: $user From: $botname \$!getip 'nick' (Gets the users ip)|");
      odch::data_to_user($user, "\$To: $user From: $botname \$!gethost 'nick' (Gets the users hostname)|");
      odch::data_to_user($user, "\$To: $user From: $botname \$!nickban 'nick' (Bans a users ip)|");
      odch::data_to_user($user, "\$To: $user From: $botname \$!ban 'ip' (Bans the ip)|");
      odch::data_to_user($user, "\$To: $user From: $botname \$!unban 'ip' (Unbans the ip)|");
      odch::data_to_user($user, "\$To: $user From: $botname \$!checkban 'ip' (Checks if the ip is banned)|");
      odch::data_to_user($user, "\$To: $user From: $botname \$!allow 'ip' (Adds ip to the allow list)|");
      odch::data_to_user($user, "\$To: $user From: $botname \$!unallow 'ip' (Removes ip off the allow list)|");
      }

      } #end of op only

      } #end one

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

      sorry about the confusion.

       
    • Robin Hill

      Robin Hill - 2003-03-05

      Looks a nice script - a few comments/suggestions on the perl though:

      I'd suggest using a hash for the connection types, max slots & max hubs - then you can just loop through it.  That should simplify the on_connect function.

      I'd've thought a regex would be an easier way to pull out dc++ info as well - not looked into that though.

      Also, rather than:
      >my(@uservalues) = values %usersList;
      >while (@uservalues)
      >{
      >my($userval) = pop(@uservalues);
      use:
      >foreach $userval (values %usersList) {

      And finally, use elsif where your if statements are mutually exclusive, last to exit loops after you've found a match, and return if you've finished processing in the middle of a function.

       

Log in to post a comment.