[Plugin SDK] Requesting data like ban list / complain list

Does anyone know how I get the actual ban list / complain list in the plugin SDK?
The functions do not make sense for me.

The function for requesting the ban list is:
unsigned int (*requestBanList)(uint64 serverConnectionHandlerID, uint64 start, unsigned int duration, const char* returnCode); (defined in ts3_functions.h, line 201)

I know that you call it with ts3Function.requestBanList(…
It returns an int which represents errors like ERROR_ok
According to the documentation, the parameter returnCode β€œcan be used to find
out which action results in a later server error”

But is there a way to get the ban list like in an array with entries or such?

I quickly wrote this:

It is a minimal example to read out all bans. (Also it’s not safe because you can actually buffer overflow it pretty easy so use with caution)

#include <stdio.h>
#include "ts3_functions.h"
#include "plugin.h"

static struct TS3Functions ts3Functions;

#define PLUGIN_API_VERSION 24

const char* ts3plugin_name() {
	return "Test Plugin";
}

const char* ts3plugin_version() {
    return "0.1";
}

int ts3plugin_apiVersion() {
	return PLUGIN_API_VERSION;
}

const char* ts3plugin_author() {
    return "Gamer92000";
}

const char* ts3plugin_description() {
    return "This plugin demonstrates something?.";
}

void ts3plugin_setFunctionPointers(const struct TS3Functions funcs) {
    ts3Functions = funcs;
}

int ts3plugin_init() {
    return 0;
}

void ts3plugin_shutdown() {
}

/*
 * This function was just the first best to abuse as a trigger to request ban data.
 * */
void ts3plugin_currentServerConnectionChanged(uint64 serverConnectionHandlerID) {
	/*
	 * This will request all bans. However it seems there is no way to know when you received all.
	 * The only thing I can think of atm is a polling for how long the BanListEvent was called ago 
	 * and if this time is greater than some offset for safty reasons block said Event until the processing is done 
	 * and consider the data complete. If you want to block until you received all bans
	 * consider moving the functionality to another thread and setting a mutex.
	 * */
	ts3Functions.requestBanList(serverConnectionHandlerID, 0, -1, NULL);
	ts3Functions.logMessage("ASKED FOR β– β– β– β– ", LogLevel_INFO, "TESTSTUFF", 0);
}

void ts3plugin_onBanListEvent(uint64 serverConnectionHandlerID, uint64 banid, const char* ip,
							  const char* name, const char* uid, const char* mytsid,
							  uint64 creationTime, uint64 durationTime, const char* invokerName,
							  uint64 invokercldbid, const char* invokeruid, const char* reason,
							  int numberOfEnforcements, const char* lastNickName) {
	/*
	 * This callback is called once per requested ban entry!
	 * To iterate through them you need to create a list outside of this function and
	 * write to it from here.
	 * */
	char text[80];
	sprintf(text, "%s is banned from IP %s", name, ip);
	ts3Functions.logMessage(text, LogLevel_DEBUG, "TESTSTUFF", 0);
}

/*
 * WARNING: This would be nice to have but seems to be missing from the plugin API!
 * */
void ts3plugin_onBanListFinishedEvent(uint64 serverConnectionHandlerID, int last) {
	ts3Functions.logMessage("Nothing to see here!", LogLevel_INFO, "TESTSTUFF", 0);
}

1 Like

Thank you!

1 Like