qKa / ghostplusplus

Automatically exported from code.google.com/p/ghostplusplus
Other
1 stars 0 forks source link

automated banning system #67

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
This is a new feature, as requested by an GHostGraz (a 1k+ DotA games/day)
admin:
 -> http://forum.ghostgraz.com/index.php?page=Thread&threadID=285&pageNo=1

Basically he wanted a !stats check done in the background whenever a player
joined the game lobby. Depending on the number of games played and the stay
percentage, that user may be kicked (and banned) on the spot. Also, if
server admins are present in the lobby, they should be notified.

Implementation details are bellow. I'll attach a patch against the current
svn trunk as soon as possible. If it's ok with you, I'd like to fork the
project onto github.org and keep my code there. You can take what you like
and merge it in your trunk. Also, I'll try to coordinate with the
codelain.org forum.

Greets,
-lordrt

---

When a player joins a game, a !stats check is done in the background. Based
on the returned gamesplayed and stay percentage, that player may be:
a) welcomed as a new player via a /w (played less
thanbot_autokickleaversonjoin_mingames);
b) kicked (and possibly banned) automatically if his stay ratio is really
bad (< bot_autokickleaversonjoin_threshold);
c) warned of an impeding ban if his stay ratio is bad, but not enough to
warrant a kick+ban (> bot_autokickleaversonjoin_threshold but <
bot_autokickleaversonjoin_warnthreashold);
d) welcomed with a thank you message, if his stay ratio is very good (> 90%).

Also, if there are admins present in the game, they'll be notified (via /w).

It's all controlled via a few new ghost.cfg settings:

bot_autokickleaversonjoin = 1                 # enable/disable the system
bot_autokickleaversonjoin_mingames = 3        # just welcome players that
hadn't played this many games - option a)
bot_autokickleaversonjoin_threshold = 70      # kick players with stay <
(70) - option b)
bot_autokickleaversonjoin_warnthreashold = 80 # notify admins of players
with stay < (80) 
bot_autokickleaversonjoin_banaswell = 0       # after kicking, issue a ban
as well - option b)

I've deployed and tested the code with my ghost (I host 6v6 games only).
The binaries are available here:
 -> http://tv.hehe.si/ghost/ (note: this will change to
http://ike.kiberpipa.org/dota/ghost soon)

It needs some further testing. I'm importing a substantial game database to
make that happen, but it will take some time.

Original issue reported on code.google.com by lord...@gmail.com on 11 Jan 2010 at 10:39

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I managed to do this with a custom php script that runs daily.  You won't get 
instant gratification but it will ban the leavers within a day.  Copy and paste 
the 
folowing into notepad or better yet a php parser like this free one.  
http://devphp.sourceforge.net  You of course need a webserver that can run php 
code 
as well as access to the sql database that your ghost++ bot reports to.  This 
particular code bans players that have played more than 5 games and have spent 
less 
that 50% of the time in game.

<html>
<body>
<Table class='outline'><TR><TD class='standard'>Rank</TD><TD 
class='standard'>Games 
Played</TD><TD class='standard'>Player's Name</TD><TD 
class='standard'>Realm</TD><TD 
class='standard'>Total Time in Game</TD><TD class='standard'>Total Game 
Time</TD><TD 
class='standard'>In Game Percent</TD><TD class='standard'>Last IP</TD></TR>
<?PHP
$gamesplayed = 5;
$query = "select count(name),gameplayers.name,gameplayers.spoofedrealm,sum
(gameplayers.left),sum(games.duration),sum(gameplayers.left)/sum(games.duration)
,ip 
from gameplayers,games where gameplayers.gameid = games.id and 
gameplayers.leftreason = 'has left the game voluntarily' group by 
name,spoofedrealm 
order by sum(gameplayers.left)/sum(games.duration)"; 
$result = mysql_query($query) or die('Q1 failed: ' . mysql_error());
$i=1;
while ($row = mysql_fetch_row($result))
{
if ($row[0] >= $gamesplayed) {
  if ($row[5] <= .500)
    {
    echo "<TD class='standard'>$i</TD><TD class='standard'>$row[0]</TD><TD 
class='standard'><a 
href='leavers.php?PlayerName=$row[1]&PlayerRealm=$row[2]'>$row[1]
</a></TD><TD class='standard'>$row[2]</TD><TD class='standard'>$row[3]</TD><TD 
class='standard'>$row[4]</TD><TD class='standard'>" . $row[5]*100 . "</TD><TD 
class='standard'>" . $row[6] . "</TD></TR>";
    $i++;
    $query2 = "select name from bans where name='" . $row[1] . "' and server='" . 
$row[2] . "'";
    $result2 = mysql_query($query2) or die ('Q2 failed: ' . mysql_error());
    if (mysql_num_rows($result2) == 0)
      {
      echo "New Entry " . $row[5] . "= insert " . $row[1] . $row[2];
      $query3 = "insert into bans (botid,server,name,ip,date,gamename,admin,reason) 
values ('0','$row[2]','$row[1]','$row[6]',now(),'Average of 5 
games','Anna','Leaver 
percentage below 50%')";
      $result3 = mysql_query($query3) or die ('Q3 failed: ' . mysql_error());
            }

    }
  }
?>
</table>
</body>

Original comment by ico...@gmail.com on 4 Feb 2010 at 5:04