Development > Module Requests

problem with invite command, need fix

(1/2) > >>

kinbaku:
If you try to invite the bot to its own channel it results in a crash. ie if your bot is named bob, and u do !invite bob, the bot disconnects with this error in the console window:

Read error: EOF
[CONN] [ERROR] Bot has disconnected. Reconnecting in 60 seconds.
The bot is restarting.

Wondering if anybody could write a fix for me, i cant seem to fix it myself. Thanks.

PS - one would assume you could just NOT invite the bot to its own channel, but some friends of mine seem to find it funny to do so just to crash the bot. Thanks.

Khalem:
This is a theoretical fix.

Open modules/PrivGroup.php
Find function invite
Replace it with

--- Code: ---
    function invite($from, $type, $who)
    {
        if (($this -> bot -> guildbot && $this -> bot -> is_member($from)) ||
                             $this -> bot -> admin -> in_group($from, "raidleader") ||
                                         $this -> bot -> admin -> in_group($from, "admin") ||
                                         $this -> bot -> admin -> in_group($from, "superadmin"))
        {
                if ($this -> bot -> botname == $who)
                {
                  $msg = "You cannot invite the bot to its own chat group";
                }
                else if ($this -> bot -> aoc -> get_uid($who))
                {
                  $this -> bot -> aoc -> privategroup_invite($who);
                  $this -> bot -> send_tell($who, "You have been invited to the privategroup by " . $from . ".");
                  $msg = "<font color=#ffff00>" . $who . "</font> has been invited.";
                }
                else
                {
                  $msg = "Player <font color=#ffff00>" . $who . "</font> does not exist.";
                }
        }
      else
        $msg = "You do not have permission to use this command.";


      if ($type == "tell")
        $this -> bot -> send_tell($from, $msg);
      else
        $this -> bot -> send_pgroup($msg);
    }
  }

--- End code ---


Untested, but should work.

Xenixa:
Yep, works like a champ.  :D

Solerna:
Works like a charm IF i suply the bot name all in lowercase letters "bot" However if I invite "Bot" or "bOt" or any other version it still crashes =/

Xenixa:
Replace
--- Code: ---if ($this -> bot -> botname == $who)
--- End code ---

With
--- Code: ---if ($this -> bot -> botname == strtolower($who))
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version