Bot-detector/bot-detector

i had the same idea and found this project

extreme4all opened this issue · 10 comments

i have some experience in python & AI not so mutch on java, that is why i was looking for report hoks & and i found your project anyway we can collab?

Oh yeah that would be fun :) go ahead and fork and submit pull requests and I'll approve them if they're not malicious. That would be great!

i can't really figure out what you are sending in h variable, it looks like only the player who reports.
and do you have some place to access the reports too? and the python model is that in this repo aswell?

The h variable is a set string which collects all local players and removes duplicates.

`
public class BotDetectorPlugin extends Plugin {

HashSet<String> h = new HashSet<String>(); // open container to add names 
int x = 0; //timing variable 

public static final MediaType MEDIA_TYPE_MARKDOWN = MediaType.parse("text/x-markdown; charset=utf-8"); //sets media type
private final OkHttpClient okclient = new OkHttpClient(); //opens http client to send

public BotDetectorPlugin() throws IOException {
}

public void sendToServer() throws IOException {

    Request request = new Request.Builder() //send method
            .url("http://ferrariicpa.pythonanywhere.com/")
            .post(RequestBody.create(MEDIA_TYPE_MARKDOWN, h.toString()))
            .build();
    h.clear();
    try (Response response = okclient.newCall(request).execute()) {
    }
}

@Inject
private Client client;

@Inject
private BotDetectorConfig config;

@Provides
BotDetectorConfig provideConfig(ConfigManager configManager)
{
    return configManager.getConfig(BotDetectorConfig.class);
}
@Subscribe
public void onPlayerSpawned(PlayerSpawned event) throws IOException { //this adds local player names to the h.set which then automatically removes duplicates. 
    Player player = event.getPlayer();
    h.add(player.getName());
    System.out.println(player.getName());
    }

@Subscribe
public void onGameTick(GameTick event) throws IOException{ //this sends to the server after the timing condition has been met, and then clears the h.set file.
    if(config.sendAutomatic()){
        int timeSend = 100*(config.intConfig());
        if(timeSend < 500){
            timeSend = 500;
        }
        x++;
        if(x > timeSend){
            sendToServer();
            x = 0;
        }
    }
}

@Override
protected void startUp() throws Exception{
}

@Override
protected void shutDown() throws Exception { //sends to the server if the 
    sendToServer();
}

}
`

The 'reports' are just player names that have been sent by the plugin. To test this client you can run the flask app in jupyter notebook or on your desktop - and change the send IP of the plugin to local:port. Then you can run the plugin - and collect names to send to your local server. - I've changed the flask app a bit so I'll have to update that before you do so. Plus I'll make a guide on how you can locally collect player names soon.

nice, so the part below, it just collects all player names near the current player when he is spawned?

    public void onPlayerSpawned(PlayerSpawned event) throws IOException {
        Player player = event.getPlayer();
        h.add(player.getName());
        System.out.println(player.getName());
        }

and do you check every game tick? why not just when the report button is send?

    @Subscribe
    public void onGameTick(GameTick event) throws IOException{
        if(config.sendAutomatic()){
            int timeSend = 100*(config.intConfig());
            if(timeSend < 500){
                timeSend = 500;
            }
            x++;
            if(x > timeSend){
                sendToServer();
                x = 0;
            }
        }
    }

nice, so the part below, it just collects all player names near the current player when he is spawned?

A: Yes so any time a new player shows up on the screen, their name is added to the list.

and do you check every game tick? why not just when the report button is send?

A: this is just a timekeeping function so players can now send files automatically when this gets pushed out. Each game tick is 0.6 seconds, so 100 game ticks = 1 minute. It counts every game tick, and then once the internal counter hits the metric for 'send' it'll send the data and reset the clock

ah interesting, i originally had the idea that it would hook the report button, and send a record like
{reporter: player_name, reported: player_name, x: 0, y:0}
at least that is what i had in mind. Then you could also have a scoreboard for most verified reports etc (players that were previously on the highscores but now not anymore).

on the server side you'd have to fetch the highscores data of all reported users.

in hind sight i see a design issue, that i would not have, legitimate player data (however that could just be the data of the players reporting and or just random players)

ah interesting, i originally had the idea that it would hook the report button, and send a record like
{reporter: player_name, reported: player_name, x: 0, y:0}
at least that is what i had in mind. Then you could also have a scoreboard for most verified reports etc (players that were previously on the highscores but now not anymore).

on the server side you'd have to fetch the highscores data of all reported users.

in hind sight i see a design issue, that i would not have, legitimate player data (however that could just be the data of the players reporting and or just random players)

That's a fantastic idea! I think that's a great suggestion and would be excellent in improving the design here :)

but some option to tag real players and some option to bulk report (possibly exclude this one of the scoring)

in the future we can maybe push data to the client like % bot score (softmax result)

Yep that would be a great idea - good suggestions!