Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * TeamSpeak 3 demo plugin
- *
- * Copyright (c) 2008-2010 TeamSpeak Systems GmbH
- */
- #ifdef WINDOWS
- #pragma warning (disable : 4100) /* Disable Unreferenced parameter warning */
- #endif
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <windows.h>
- #include <tchar.h>
- #include <iostream>
- #include "public_errors.h"
- #include "public_definitions.h"
- #include "public_rare_definitions.h"
- #include "ts3_functions.h"
- #include "plugin_events.h"
- #include "plugin.h"
- static struct TS3Functions ts3Functions;
- #ifdef WINDOWS
- #define _strcpy(dest, destSize, src) strcpy_s(dest, destSize, src)
- #define snprintf sprintf_s
- #else
- #define _strcpy(dest, destSize, src) { strncpy(dest, src, destSize-1); dest[destSize-1] = '\0'; }
- #endif
- #define PATH_BUFSIZE 512
- #define COMMAND_BUFSIZE 128
- #define INFODATA_BUFSIZE 128
- #define SERVERINFO_BUFSIZE 256
- #define CHANNELINFO_BUFSIZE 512
- static char* pluginCommandID = NULL;
- const char* winampTitle;
- /*********************************** Required functions ************************************/
- /*
- * If any of these required functions is not implemented, TS3 will refuse to load the plugin
- */
- /* Unique name identifying this plugin */
- const char* ts3plugin_name() {
- return "MusicBot";
- }
- /* Plugin version */
- const char* ts3plugin_version() {
- return "0.1";
- }
- /* Plugin API version. Must be the same as the clients API major version, else the plugin fails to load. */
- int ts3plugin_apiVersion() {
- return 8;
- }
- /* Plugin author */
- const char* ts3plugin_author() {
- return "SteZZz";
- }
- /* Plugin description */
- const char* ts3plugin_description() {
- return "This plugin makes a MusicBot out of your TS3 Client.";
- }
- /* Set TeamSpeak 3 callback functions */
- void ts3plugin_setFunctionPointers(const struct TS3Functions funcs) {
- ts3Functions = funcs;
- }
- /*
- * Custom code called right after loading the plugin. Returns 0 on success, 1 on failure.
- * If the function returns 1 on failure, the plugin will be unloaded again.
- */
- int ts3plugin_init() {
- //char appPath[PATH_BUFSIZE];
- //char resourcesPath[PATH_BUFSIZE];
- //char configPath[PATH_BUFSIZE];
- //char pluginPath[PATH_BUFSIZE];
- /* Your plugin init code here */
- // printf("PLUGIN: init\n");
- /* Show API versions */
- //printf("PLUGIN: Client API Version: %d, Plugin API Version: %d\n", ts3Functions.getAPIVersion(), ts3plugin_apiVersion());
- /* Example on how to query application, resources and configuration paths from client */
- /* Note: Console client returns empty string for app and resources path */
- // ts3Functions.getAppPath(appPath, PATH_BUFSIZE);
- // ts3Functions.getResourcesPath(resourcesPath, PATH_BUFSIZE);
- // ts3Functions.getConfigPath(configPath, PATH_BUFSIZE);
- //ts3Functions.getPluginPath(pluginPath, PATH_BUFSIZE);
- //printf("PLUGIN: App path: %s\nResources path: %s\nConfig path: %s\nPlugin path: %s\n", appPath, resourcesPath, configPath, pluginPath);
- return 0; /* 0 = success, 1 = failure */
- }
- /* Custom code called right before the plugin is unloaded */
- void ts3plugin_shutdown() {
- /* Your plugin cleanup code here */
- printf("MusicBot PLUGIN: shutdown\n");
- /* Free pluginCommandID if we registered it */
- if(pluginCommandID) {
- free(pluginCommandID);
- pluginCommandID = NULL;
- }
- }
- /****************************** Optional functions ********************************/
- /*
- * Following functions are optional, if not needed you don't need to implement them.
- */
- /* Tell client if plugin offers a configuration window. If this function is not implemented, it's an assumed "does not offer" (PLUGIN_OFFERS_NO_CONFIGURE). */
- //int ts3plugin_offersConfigure() {
- // printf("PLUGIN: offersConfigure\n");
- /*
- * Return values:
- * PLUGIN_OFFERS_NO_CONFIGURE - Plugin does not implement ts3plugin_configure
- * PLUGIN_OFFERS_CONFIGURE_NEW_THREAD - Plugin does implement ts3plugin_configure and requests to run this function in an own thread
- * PLUGIN_OFFERS_CONFIGURE_QT_THREAD - Plugin does implement ts3plugin_configure and requests to run this function in the Qt GUI thread
- */
- //return PLUGIN_OFFERS_NO_CONFIGURE; /* In this case ts3plugin_configure does not need to be implemented */
- //}
- /* Plugin might offer a configuration window.I f ts3plugin_offersConfigure returns 0, this function does not need to be implemented. */
- //void ts3plugin_configure(void* handle, void* qParentWidget) {
- // printf("PLUGIN: configure\n");
- //}
- /*
- * If the plugin wants to use plugin commands, it needs to register a command ID. This function will be automatically called after
- * the plugin was initialized. This function is optional. If you don't use plugin commands, the function can be omitted.
- * Note the passed commandID parameter is no longer valid after calling this function, so you *must* copy it and store it in the plugin.
- */
- void ts3plugin_registerPluginCommandID(const char* commandID) {
- const size_t sz = strlen(commandID) + 1;
- pluginCommandID = (char*)malloc(sz * sizeof(char));
- _strcpy(pluginCommandID, sz, commandID); /* The commandID buffer will invalidate after existing this function */
- printf("PLUGIN: registerPluginCommandID: %s\n", pluginCommandID);
- }
- /* Plugin command keyword. Return NULL or "" if not used. */
- const char* ts3plugin_commandKeyword() {
- return "";
- }
- /* Plugin processes console command. Return 0 if plugin handled the command, 1 if not handled. */
- int ts3plugin_processCommand(uint64 serverConnectionHandlerID, const char* command) {
- char buf[COMMAND_BUFSIZE];
- char *s, *param1 = NULL, *param2 = NULL;
- int i = 0;
- enum { CMD_NONE = 0, CMD_JOIN, CMD_COMMAND, CMD_SERVERINFO, CMD_CHANNELINFO } cmd = CMD_NONE;
- #ifdef WINDOWS
- char* context = NULL;
- #endif
- printf("PLUGIN: process command: '%s'\n", command);
- /* Test command: "join <channelID> [password]" */
- _strcpy(buf, COMMAND_BUFSIZE, command);
- #ifdef WINDOWS
- s = strtok_s(buf, " ", &context);
- #else
- s = strtok(buf, " ");
- #endif
- while(s != NULL) {
- if(i == 0) {
- if(!strcmp(s, "join")) {
- cmd = CMD_JOIN;
- } else if(!strcmp(s, "command")) {
- cmd = CMD_COMMAND;
- } else if(!strcmp(s, "serverinfo")) {
- cmd = CMD_SERVERINFO;
- } else if(!strcmp(s, "channelinfo")) {
- cmd = CMD_CHANNELINFO;
- }
- } else if(i == 1) {
- param1 = s;
- } else {
- param2 = s;
- }
- #ifdef WINDOWS
- s = strtok_s(NULL, " ", &context);
- #else
- s = strtok(NULL, " ");
- #endif
- i++;
- }
- switch(cmd) {
- case CMD_NONE:
- return 1; /* Command not handled by plugin */
- case CMD_JOIN:
- if(param1) {
- uint64 channelID = (uint64)atoi(param1);
- char* password = param2 ? param2 : "";
- anyID myID;
- /* Get own clientID */
- if(ts3Functions.getClientID(serverConnectionHandlerID, &myID) != ERROR_ok) {
- ts3Functions.logMessage("Error querying client ID", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
- break;
- }
- /* Join specified channel */
- if(ts3Functions.requestClientMove(serverConnectionHandlerID, myID, channelID, password, NULL) != ERROR_ok) {
- ts3Functions.logMessage("Error requesting client move", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
- }
- } else {
- ts3Functions.printMessageToCurrentTab("Missing channel ID parameter.");
- }
- break;
- case CMD_COMMAND:
- if(param1) {
- /* Send plugin command to all clients in current channel. In this case targetIds is unused and can be NULL. */
- if(pluginCommandID) {
- /* See ts3plugin_registerPluginCommandID for how to obtain pluginCommandID */
- printf("PLUGIN: Sending plugin command to current channel: %s\n", param1);
- ts3Functions.sendPluginCommand(serverConnectionHandlerID, pluginCommandID, param1, PluginCommandTarget_CURRENT_CHANNEL, NULL);
- } else {
- printf("PLUGIN: Failed to send plugin command, was not registered.\n");
- }
- } else {
- ts3Functions.printMessageToCurrentTab("Missing command parameter.");
- }
- break;
- case CMD_SERVERINFO: {
- /* Query host, port and server password of current server tab.
- * The password parameter can be NULL if the plugin does not want to receive the server password.
- * Note: Server password is only available if the user has actually used it when connecting. If a user has
- * connected with the permission to ignore passwords (b_virtualserver_join_ignore_password) and the password,
- * was not entered, it will not be available.
- * getServerConnectInfo returns 0 on success, 1 on error or if current server tab is disconnected. */
- char host[SERVERINFO_BUFSIZE];
- /*char password[SERVERINFO_BUFSIZE];*/
- char* password = NULL; /* Don't receive server password */
- unsigned short port;
- if(!ts3Functions.getServerConnectInfo(ts3Functions.getCurrentServerConnectionHandlerID(), host, &port, password, SERVERINFO_BUFSIZE)) {
- char msg[SERVERINFO_BUFSIZE];
- snprintf(msg, sizeof(msg), "Server Connect Info: %s:%d", host, port);
- ts3Functions.printMessageToCurrentTab(msg);
- } else {
- ts3Functions.printMessageToCurrentTab("No server connect info available.");
- }
- break;
- }
- case CMD_CHANNELINFO: {
- /* Query channel path and password of current server tab.
- * The password parameter can be NULL if the plugin does not want to receive the channel password.
- * Note: Channel password is only available if the user has actually used it when entering the channel. If a user has
- * entered a channel with the permission to ignore passwords (b_channel_join_ignore_password) and the password,
- * was not entered, it will not be available.
- * getChannelConnectInfo returns 0 on success, 1 on error or if current server tab is disconnected. */
- char path[CHANNELINFO_BUFSIZE];
- /*char password[CHANNELINFO_BUFSIZE];*/
- char* password = NULL; /* Don't receive channel password */
- /* Get own clientID and channelID */
- anyID myID;
- uint64 myChannelID;
- if(ts3Functions.getClientID(serverConnectionHandlerID, &myID) != ERROR_ok) {
- ts3Functions.logMessage("Error querying client ID", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
- break;
- }
- /* Get own channel ID */
- if(ts3Functions.getChannelOfClient(serverConnectionHandlerID, myID, &myChannelID) != ERROR_ok) {
- ts3Functions.logMessage("Error querying channel ID", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
- break;
- }
- /* Get channel connect info of own channel */
- if(!ts3Functions.getChannelConnectInfo(ts3Functions.getCurrentServerConnectionHandlerID(), myChannelID, path, password, CHANNELINFO_BUFSIZE)) {
- char msg[CHANNELINFO_BUFSIZE];
- snprintf(msg, sizeof(msg), "Channel Connect Info: %s", path);
- ts3Functions.printMessageToCurrentTab(msg);
- } else {
- ts3Functions.printMessageToCurrentTab("No channel connect info available.");
- }
- break;
- }
- }
- return 1; /* Plugin handled command */
- }
- /* Client changed current server connection handler */
- /**
- void ts3plugin_currentServerConnectionChanged(uint64 serverConnectionHandlerID) {
- printf("PLUGIN: currentServerConnectionChanged %llu (%llu)\n", (long long unsigned int)serverConnectionHandlerID, (long long unsigned int)ts3Functions.getCurrentServerConnectionHandlerID());
- }
- **/
- /**
- void ts3plugin_pluginEvent(unsigned short data, const char* message) {
- char type, subtype;
- printf("PLUGIN: pluginEvent data = %u\n", data);
- if(message) {
- printf("Message: %s\n", message);
- }
- type = data >> 8;
- subtype = data & 0xFF;
- printf("Type = %d, subtype = %d\n", type, subtype);
- switch(type) {
- case PLUGIN_EVENT_TYPE_HOTKEY:
- switch(subtype) {
- case PLUGIN_EVENT_SUBTYPE_HOTKEY_TOGGLE_MICRO_ON:
- printf("Micro on\n");
- break;
- case PLUGIN_EVENT_SUBTYPE_HOTKEY_TOGGLE_MICRO_OFF:
- printf("Micro off\n");
- break;
- case PLUGIN_EVENT_SUBTYPE_HOTKEY_TOGGLE_SPEAKER_ON:
- printf("Speaker on\n");
- break;
- case PLUGIN_EVENT_SUBTYPE_HOTKEY_TOGGLE_SPEAKER_OFF:
- printf("Speaker off\n");
- break;
- case PLUGIN_EVENT_SUBTYPE_HOTKEY_TOGGLE_AWAY_ON:
- printf("Away on\n");
- break;
- case PLUGIN_EVENT_SUBTYPE_HOTKEY_TOGGLE_AWAY_OFF:
- printf("Away off\n");
- break;
- case PLUGIN_EVENT_SUBTYPE_HOTKEY_ACTIVATE_MICRO:
- printf("Activate micro\n");
- break;
- case PLUGIN_EVENT_SUBTYPE_HOTKEY_ACTIVATE_SPEAKER:
- printf("Activate speaker\n");
- break;
- case PLUGIN_EVENT_SUBTYPE_HOTKEY_ACTIVATE_AWAY:
- printf("Activate away\n");
- break;
- case PLUGIN_EVENT_SUBTYPE_HOTKEY_DEACTIVATE_MICRO:
- printf("Deactivate micro\n");
- break;
- case PLUGIN_EVENT_SUBTYPE_HOTKEY_DEACTIVATE_SPEAKER:
- printf("Deactivate speakers\n");
- break;
- case PLUGIN_EVENT_SUBTYPE_HOTKEY_DEACTIVATE_AWAY:
- printf("Deactivate away\n");
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- }
- **/
- /* Required to release the memory for parameter "data" allocated in ts3plugin_infoData */
- void ts3plugin_freeMemory(void* data) {
- free(data);
- }
- /*
- * Plugin requests to be always automatically loaded by the TeamSpeak 3 client unless
- * the user manually disabled it in the plugin dialog.
- * This function is optional. If missing, no autoload is assumed.
- */
- int ts3plugin_requestAutoload() {
- return 1; /* 1 = request autoloaded, 0 = do not request autoload */
- }
- /************************** TeamSpeak callbacks ***************************/
- /*
- * Following functions are optional, feel free to remove unused callbacks.
- * See the clientlib documentation for details on each function.
- */
- /* Clientlib */
- void ts3plugin_onNewChannelEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 channelParentID) {
- }
- void ts3plugin_onNewChannelCreatedEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 channelParentID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier) {
- }
- void ts3plugin_onDelChannelEvent(uint64 serverConnectionHandlerID, uint64 channelID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier) {
- }
- void ts3plugin_onChannelMoveEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 newChannelParentID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier) {
- }
- void ts3plugin_onUpdateChannelEvent(uint64 serverConnectionHandlerID, uint64 channelID) {
- }
- void ts3plugin_onUpdateChannelEditedEvent(uint64 serverConnectionHandlerID, uint64 channelID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier) {
- }
- void ts3plugin_onUpdateClientEvent(uint64 serverConnectionHandlerID, anyID clientID) {
- }
- void ts3plugin_onClientMoveEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char* moveMessage) {
- }
- void ts3plugin_onClientMoveSubscriptionEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility) {
- }
- void ts3plugin_onClientMoveTimeoutEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char* timeoutMessage) {
- }
- void ts3plugin_onClientMoveMovedEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, anyID moverID, const char* moverName, const char* moverUniqueIdentifier, const char* moveMessage) {
- }
- void ts3plugin_onClientKickFromChannelEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, anyID kickerID, const char* kickerName, const char* kickerUniqueIdentifier, const char* kickMessage) {
- }
- void ts3plugin_onClientKickFromServerEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, anyID kickerID, const char* kickerName, const char* kickerUniqueIdentifier, const char* kickMessage) {
- }
- void ts3plugin_onServerEditedEvent(uint64 serverConnectionHandlerID, anyID editerID, const char* editerName, const char* editerUniqueIdentifier) {
- }
- void ts3plugin_onServerUpdatedEvent(uint64 serverConnectionHandlerID) {
- }
- void ts3plugin_onServerErrorEvent(uint64 serverConnectionHandlerID, const char* errorMessage, unsigned int error, const char* returnCode, const char* extraMessage) {
- }
- void ts3plugin_onServerStopEvent(uint64 serverConnectionHandlerID, const char* shutdownMessage) {
- }
- int ts3plugin_onTextMessageEvent(uint64 serverConnectionHandlerID, anyID targetMode, anyID toID, anyID fromID, const char* fromName, const char* fromUniqueIdentifier, const char* message, int ffIgnored) {
- printf("PLUGIN: onTextMessageEvent %llu %d %d %s %s %d\n", (long long unsigned int)serverConnectionHandlerID, targetMode, fromID, fromName, message, ffIgnored);
- ts3Functions.setClientSelfVariableAsString(serverConnectionHandlerID, CLIENT_META_DATA, titleWinamp());
- //const char* aMessage = message;
- //ts3plugin_TestWinamp()
- /* Friend/Foe manager has ignored the message, so ignore here as well. */
- if(ffIgnored) {
- return 0; /* Client will ignore the message anyways, so return value here doesn't matter */
- }
- #if 1
- {
- /* Example code: Autoreply to sender */
- /* Disabled because quite annoying, but should give you some ideas what is possible here */
- /* Careful, when two clients use this, they will get banned quickly... */
- anyID myID;
- if(ts3Functions.getClientID(serverConnectionHandlerID, &myID) != ERROR_ok) {
- ts3Functions.logMessage("Error querying own client id", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
- return 0;
- }
- if(fromID != myID) { /* Don't reply when source is own client */
- //if ( strcmp ( message, "!winamp" ) == 0 ){
- //if(starts_with("!winamp",message)){
- if(strcmp(message,"!winamp next") == 0){
- controlWinamp("next");
- return 0;
- } else if(strcmp(message,"!winamp prev") == 0){
- controlWinamp("prev");
- return 0;
- } else if(strcmp(message,"!winamp stop") == 0){
- controlWinamp("stop");
- return 0;
- } else if(strcmp(message,"!winamp play") == 0){
- controlWinamp("play");
- return 0;
- } else if(strcmp(message,"!winamp title") == 0){
- if(ts3Functions.requestSendPrivateTextMsg(serverConnectionHandlerID, titleWinamp() , fromID, NULL) != ERROR_ok) {
- ts3Functions.logMessage("Error requesting send text message", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
- }
- return 0;
- } else if(starts_with(message,"!winamp ")){
- if(ts3Functions.requestSendPrivateTextMsg(serverConnectionHandlerID, message , fromID, NULL) != ERROR_ok) {
- ts3Functions.logMessage("Error requesting send text message", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
- }
- return 0;
- } else if(ts3Functions.requestSendPrivateTextMsg(serverConnectionHandlerID, "Hoi" , fromID, NULL) != ERROR_ok) {
- ts3Functions.logMessage("Error requesting send text message", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
- }
- return 0;
- }
- }
- #endif
- return 0; /* 0 = handle normally, 1 = client will ignore the text message */
- }
- void ts3plugin_onTalkStatusChangeEvent(uint64 serverConnectionHandlerID, int status, int isReceivedWhisper, anyID clientID) {
- }
- void ts3plugin_onConnectionInfoEvent(uint64 serverConnectionHandlerID, anyID clientID) {
- }
- void ts3plugin_onServerConnectionInfoEvent(uint64 serverConnectionHandlerID) {
- }
- void ts3plugin_onChannelSubscribeEvent(uint64 serverConnectionHandlerID, uint64 channelID) {
- }
- void ts3plugin_onChannelSubscribeFinishedEvent(uint64 serverConnectionHandlerID) {
- }
- void ts3plugin_onChannelUnsubscribeEvent(uint64 serverConnectionHandlerID, uint64 channelID) {
- }
- void ts3plugin_onChannelUnsubscribeFinishedEvent(uint64 serverConnectionHandlerID) {
- }
- void ts3plugin_onChannelDescriptionUpdateEvent(uint64 serverConnectionHandlerID, uint64 channelID) {
- }
- void ts3plugin_onChannelPasswordChangedEvent(uint64 serverConnectionHandlerID, uint64 channelID) {
- }
- void ts3plugin_onCustomCaptureDeviceCloseEvent(uint64 serverConnectionHandlerID, void* fmodSystem) {
- }
- void ts3plugin_onCustomPlaybackDeviceCloseEvent(uint64 serverConnectionHandlerID, void* fmodSystem) {
- }
- void ts3plugin_onFMODChannelCreatedEvent(uint64 serverConnectionHandlerID, anyID clientID, void* fmodChannel) {
- }
- void ts3plugin_onPlaybackShutdownCompleteEvent(uint64 serverConnectionHandlerID) {
- }
- void ts3plugin_onUserLoggingMessageEvent(const char* logMessage, int logLevel, const char* logChannel, uint64 logID, const char* logTime, const char* completeLogString) {
- }
- void ts3plugin_onVoiceRecordDataEvent(const float* data, unsigned int dataSize) {
- }
- /* Clientlib rare */
- void ts3plugin_onClientBanFromServerEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, anyID kickerID, const char* kickerName, const char* kickerUniqueIdentifier, uint64 time, const char* kickMessage) {
- }
- int ts3plugin_onClientPokeEvent(uint64 serverConnectionHandlerID, anyID fromClientID, const char* pokerName, const char* pokerUniqueIdentity, const char* message, int ffIgnored) {
- anyID myID;
- printf("PLUGIN onClientPokeEvent: %llu %d %s %s %d\n", (long long unsigned int)serverConnectionHandlerID, fromClientID, pokerName, message, ffIgnored);
- /* Check if the Friend/Foe manager has already blocked this poke */
- if(ffIgnored) {
- return 0; /* Client will block anyways, doesn't matter what we return */
- }
- /* Example code: Send text message back to poking client */
- if(ts3Functions.getClientID(serverConnectionHandlerID, &myID) != ERROR_ok) { /* Get own client ID */
- ts3Functions.logMessage("Error querying own client id", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
- return 0;
- }
- if(fromClientID != myID) { /* Don't reply when source is own client */
- if(ts3Functions.requestSendPrivateTextMsg(serverConnectionHandlerID, "Received your poke!", fromClientID, NULL) != ERROR_ok) {
- ts3Functions.logMessage("Error requesting send text message", LogLevel_ERROR, "Plugin", serverConnectionHandlerID);
- }
- }
- return 0; /* 0 = handle normally, 1 = client will ignore the poke */
- }
- void ts3plugin_onClientSelfVariableUpdateEvent(uint64 serverConnectionHandlerID, int flag, const char* oldValue, const char* newValue) {
- }
- void ts3plugin_onFileListEvent(uint64 serverConnectionHandlerID, uint64 channelID, const char* path, const char* name, uint64 size, uint64 datetime, int type) {
- }
- void ts3plugin_onFileListFinishedEvent(uint64 serverConnectionHandlerID, uint64 channelID, const char* path) {
- }
- void ts3plugin_onFileInfoEvent(uint64 serverConnectionHandlerID, uint64 channelID, const char* name, uint64 size, uint64 datetime) {
- }
- void ts3plugin_onServerGroupListEvent(uint64 serverConnectionHandlerID, uint64 serverGroupID, const char* name, int type, int iconID, int saveDB) {
- }
- void ts3plugin_onServerGroupListFinishedEvent(uint64 serverConnectionHandlerID) {
- }
- void ts3plugin_onServerGroupByClientIDEvent(uint64 serverConnectionHandlerID, const char* name, uint64 serverGroupList, uint64 clientDatabaseID) {
- }
- void ts3plugin_onServerGroupPermListEvent(uint64 serverConnectionHandlerID, uint64 serverGroupID, anyID permissionID, int permissionValue, int permissionNegated, int permissionSkip) {
- }
- void ts3plugin_onServerGroupPermListFinishedEvent(uint64 serverConnectionHandlerID, uint64 serverGroupID) {
- }
- void ts3plugin_onServerGroupClientListEvent(uint64 serverConnectionHandlerID, uint64 serverGroupID, uint64 clientDatabaseID, const char* clientNameIdentifier, const char* clientUniqueID) {
- }
- void ts3plugin_onChannelGroupListEvent(uint64 serverConnectionHandlerID, uint64 channelGroupID, const char* name, int type, int iconID, int saveDB) {
- }
- void ts3plugin_onChannelGroupListFinishedEvent(uint64 serverConnectionHandlerID) {
- }
- void ts3plugin_onChannelGroupPermListEvent(uint64 serverConnectionHandlerID, uint64 channelGroupID, anyID permissionID, int permissionValue, int permissionNegated, int permissionSkip) {
- }
- void ts3plugin_onChannelGroupPermListFinishedEvent(uint64 serverConnectionHandlerID, uint64 channelGroupID) {
- }
- void ts3plugin_onChannelPermListEvent(uint64 serverConnectionHandlerID, uint64 channelID, anyID permissionID, int permissionValue, int permissionNegated, int permissionSkip) {
- }
- void ts3plugin_onChannelPermListFinishedEvent(uint64 serverConnectionHandlerID, uint64 channelID) {
- }
- void ts3plugin_onClientPermListEvent(uint64 serverConnectionHandlerID, uint64 clientDatabaseID, anyID permissionID, int permissionValue, int permissionNegated, int permissionSkip) {
- }
- void ts3plugin_onClientPermListFinishedEvent(uint64 serverConnectionHandlerID, uint64 clientDatabaseID) {
- }
- void ts3plugin_onChannelClientPermListEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 clientDatabaseID, anyID permissionID, int permissionValue, int permissionNegated, int permissionSkip) {
- }
- void ts3plugin_onChannelClientPermListFinishedEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 clientDatabaseID) {
- }
- void ts3plugin_onClientChannelGroupChangedEvent(uint64 serverConnectionHandlerID, uint64 channelGroupID, uint64 channelID, anyID clientID, anyID invokerClientID, const char* invokerName, const char* invokerUniqueIdentity) {
- }
- void ts3plugin_onServerPermissionErrorEvent(uint64 serverConnectionHandlerID, const char* errorMessage, unsigned int error, const char* returnCode, anyID failedPermissionID) {
- }
- void ts3plugin_onPermissionListEvent(uint64 serverConnectionHandlerID, anyID permissionID, const char* permissionName, const char* permissionDescription) {
- }
- void ts3plugin_onPermissionListFinishedEvent(uint64 serverConnectionHandlerID) {
- }
- void ts3plugin_onPermissionOverviewEvent(uint64 serverConnectionHandlerID, uint64 clientDatabaseID, uint64 channelID, int overviewType, uint64 overviewID1, uint64 overviewID2, anyID permissionID, int permissionValue, int permissionNegated, int permissionSkip) {
- }
- void ts3plugin_onPermissionOverviewFinishedEvent(uint64 serverConnectionHandlerID) {
- }
- void ts3plugin_onServerGroupClientAddedEvent(uint64 serverConnectionHandlerID, anyID clientID, const char* clientName, const char* clientUniqueIdentity, uint64 serverGroupID, anyID invokerClientID, const char* invokerName, const char* invokerUniqueIdentity) {
- }
- void ts3plugin_onServerGroupClientDeletedEvent(uint64 serverConnectionHandlerID, anyID clientID, const char* clientName, const char* clientUniqueIdentity, uint64 serverGroupID, anyID invokerClientID, const char* invokerName, const char* invokerUniqueIdentity) {
- }
- void ts3plugin_onClientNeededPermissionsEvent(uint64 serverConnectionHandlerID, anyID permissionID, int permissionValue) {
- }
- void ts3plugin_onClientNeededPermissionsFinishedEvent(uint64 serverConnectionHandlerID) {
- }
- void ts3plugin_onFileTransferStatusEvent(anyID transferID, unsigned int status, const char* statusMessage, uint64 remotefileSize, uint64 serverConnectionHandlerID) {
- }
- void ts3plugin_onClientChatClosedEvent(uint64 serverConnectionHandlerID, anyID clientID) {
- }
- void ts3plugin_onClientChatComposingEvent(uint64 serverConnectionHandlerID, anyID clientID) {
- }
- void ts3plugin_onServerLogEvent(uint64 serverConnectionHandlerID, const char* logTimestamp, const char* logChannel, int logLevel, const char* logMsg) {
- }
- void ts3plugin_onServerLogFinishedEvent(uint64 serverConnectionHandlerID) {
- }
- void ts3plugin_onServerQueryEvent(uint64 serverConnectionHandlerID, const char* result) {
- }
- void ts3plugin_onMessageListEvent(uint64 serverConnectionHandlerID, uint64 messageID, const char* fromClientUniqueIdentity, const char* subject, uint64 timestamp, int flagRead) {
- }
- void ts3plugin_onMessageGetEvent(uint64 serverConnectionHandlerID, uint64 messageID, const char* fromClientUniqueIdentity, const char* subject, const char* message, uint64 timestamp) {
- }
- void ts3plugin_onClientDBIDfromUIDEvent(uint64 serverConnectionHandlerID, const char* uniqueClientIdentifier, uint64 clientDatabaseID) {
- }
- void ts3plugin_onClientNamefromUIDEvent(uint64 serverConnectionHandlerID, const char* uniqueClientIdentifier, uint64 clientDatabaseID, const char* clientNickName) {
- }
- void ts3plugin_onClientNamefromDBIDEvent(uint64 serverConnectionHandlerID, const char* uniqueClientIdentifier, uint64 clientDatabaseID, const char* clientNickName) {
- }
- void ts3plugin_onComplainListEvent(uint64 serverConnectionHandlerID, uint64 targetClientDatabaseID, const char* targetClientNickName, uint64 fromClientDatabaseID, const char* fromClientNickName, const char* complainReason, uint64 timestamp) {
- }
- void ts3plugin_onBanListEvent(uint64 serverConnectionHandlerID, uint64 banid, const char* ip, const char* name, const char* uid, uint64 creationTime, uint64 durationTime, const char* invokerName,
- uint64 invokercldbid, const char* invokeruid, const char* reason, int numberOfEnforcements) {
- }
- void ts3plugin_onClientServerQueryLoginPasswordEvent(uint64 serverConnectionHandlerID, const char* loginPassword) {
- }
- void ts3plugin_onPluginCommandEvent(uint64 serverConnectionHandlerID, const char* pluginName, const char* pluginCommand) {
- printf("ON PLUGIN COMMAND: %s %s\n", pluginName, pluginCommand);
- }
- void controlWinamp(const char* option){
- HWND hwndWinamp = FindWindow(_T("Winamp v1.x"),NULL); //Finding window
- if(strcmp(option, "next") == 0){
- SendMessage(hwndWinamp,WM_COMMAND, 40048, 1); // Next track button 40048
- titleWinamp(); //update the winamp title
- } else if(strcmp(option, "prev") == 0){
- SendMessage(hwndWinamp,WM_COMMAND, 40044, 1); // Next track button 40048
- titleWinamp();
- } else if(strcmp(option, "stop") == 0){
- SendMessage(hwndWinamp,WM_COMMAND, 40047, 1); // Next track button 40048
- titleWinamp();
- } else if(strcmp(option, "play") == 0){
- SendMessage(hwndWinamp,WM_COMMAND, 40045, 1); // Next track button 40048
- titleWinamp();
- }
- }
- const char* titleWinamp(){
- HWND hwndWinamp = FindWindow(_T("Winamp v1.x"),NULL); //Finding window
- //------------------------------------------------
- //THIS IS HOW TO GET THE TITLE OF THE CURRENT SONG
- char this_title[2048],*p;
- //GetWindowText(hwndWinamp,this_title,sizeof(this_title));
- GetWindowTextA(hwndWinamp,this_title,sizeof(this_title));
- p = this_title+strlen(this_title)-8;
- while (p >= this_title)
- {
- if (!_strnicmp(p,"- Winamp",8)) break;
- p--;
- }
- if (p >= this_title) p--;
- while (p >= this_title && *p == ' ') p--;
- *++p=0;
- //THIS IS HOW TO GET THE TITLE OF THE CURRENT SONG
- //------------------------------------------------
- //std::cout << this_title; // Prints the current title
- winampTitle = this_title; //cast to const char*
- //Sleep(3000);
- //Sleep(1000);
- return winampTitle;
- }
- bool starts_with(const std::string& text, const std::string& token)
- {
- return token.length()>=text.length()
- && std::equal(text.begin(),text.end(),token.begin());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement