1 #ifndef __INCLUDE_IRCBOT_PLUGINS_H__
2 #define __INCLUDE_IRCBOT_PLUGINS_H__
4 #define IRCBOT_PLUGIN_VERSION 0x0E
5 #define IRCBOT_VERSION_FLAG_DEBUG 0x00000001
6 #define IRCBOT_VERSION_FLAG_LITE 0x00000002
13 #include "../../Common/ircbot-config.h"
14 #include <drift/dsl.h>
17 #if defined(WIN32) || defined(XBOX)
20 typedef int socklen_t;
21 typedef signed __int64
int64;
22 typedef unsigned __int64
uint64;
23 typedef signed __int32
int32;
24 typedef unsigned __int32
uint32;
25 typedef signed __int16
int16;
26 typedef unsigned __int16
uint16;
27 typedef signed __int8
int8;
28 typedef unsigned __int8
uint8;
29 #define DL_HANDLE HINSTANCE
30 #define DSL_CC __stdcall
36 #define BYTE unsigned char
40 #define DL_HANDLE HANDLE
56 #include <curl/curl.h>
65 #define PLUGIN_EXPORT extern "C" __declspec(dllexport)
66 #define DEPRECATE __declspec(deprecated)
69 #define PLUGIN_EXPORT extern "C" __attribute__ ((visibility("default")))
71 #define PLUGIN_EXPORT extern "C"
73 #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
74 #define DEPRECATE __attribute__((__deprecated__))
79 #define PLUGIN_EXPORT_NAME GetIRCBotPlugin
80 #define PLUGIN_EXPORT_FULL PLUGIN_EXPORT PLUGIN_PUBLIC * PLUGIN_EXPORT_NAME() { return &plugin; }
82 #define MAX_IRC_SERVERS 16
83 #define MAX_IRC_CHANNELS 16
84 #define MAX_PLUGINS 32
85 #define MAX_SOUND_SERVERS 32
86 #define MAX_HOSTMASKS 16
91 #include "../../Common/remote_protocol.h"
137 #define REF_TRACKING_DEPTH 16
140 #define RefUser(x) (x)->ref(x)
141 #define UnrefUser(x) (x)->unref(x)
143 #define RefUser(x) (x)->ref(x, nopathA(__FILE__), __LINE__)
144 #define UnrefUser(x) (x)->unref(x, nopathA(__FILE__), __LINE__)
157 char LastHostmask[256];
181 void (*ref)(
USER *,
const char * fn,
int line);
182 void (*unref)(
USER *,
const char * fn,
int line);
227 void (*ref)(USER_PRESENCE * pres);
234 void (*unref)(USER_PRESENCE * pres);
236 void (*ref)(USER_PRESENCE *,
const char * fn,
int line);
237 void (*unref)(USER_PRESENCE *,
const char * fn,
int line);
265 #if defined(OLD_COMTRACK)
282 #define COMMAND_ACTION 0x00
283 #define COMMAND_PROC 0x01
284 #define CM_ALLOW_IRC_PUBLIC 0x00000001
285 #define CM_ALLOW_IRC_PRIVATE 0x00000002
286 #define CM_ALLOW_CONSOLE_PUBLIC 0x00000004
287 #define CM_ALLOW_CONSOLE_PRIVATE 0x00000008
288 #define CM_FLAG_FROM_TEXT 0x20000000
289 #define CM_FLAG_SLOW 0x10000000
290 #define CM_FLAG_ASYNC 0x40000000
291 #define CM_FLAG_NOHANG 0x80000000
292 #define CM_NO_FLAGS(x) (x & 0x0000000F)
294 #define CM_ALLOW_ALL_PUBLIC CM_ALLOW_IRC_PUBLIC|CM_ALLOW_CONSOLE_PUBLIC
295 #define CM_ALLOW_ALL_PRIVATE CM_ALLOW_IRC_PRIVATE|CM_ALLOW_CONSOLE_PRIVATE
296 #define CM_ALLOW_ALL CM_ALLOW_ALL_PUBLIC|CM_ALLOW_ALL_PRIVATE
326 char admin_pass[128];
365 #define MAX_FIND_RESULTS 100
403 bool (*request)(
USER_PRESENCE * pres,
const char * txt,
char * reply,
size_t replySize);
413 #endif // DOXYGEN_SKIP
426 int (*replace)(
char * str,
int32 bufsize,
const char *findstr,
const char * replstr);
427 char * (*trim)(
char *buf,
const char * strtrim);
428 char * (*duration)(
uint32 num,
char * buf);
429 int32 (*decode_duration)(
const char * buf);
430 int (*wildcmp)(
const char *wild,
const char *string);
431 int (*wildicmp)(
const char *wild,
const char *string);
432 bool (*get_range)(
const char * buf,
int32 * imin,
int32 * imax);
442 COMMAND * (*FindCommand)(
const char * command);
443 COMMAND * (*RegisterCommand_Action)(
int pluginnum,
const char * command,
const COMMAND_ACL * acl,
uint32 mask,
const char * action,
const char * desc);
454 void (*UnregisterCommandsByPlugin)(
int pluginnum);
455 void (*UnregisterCommandByName)(
const char * command);
458 char (*PrimaryCommandPrefix)();
459 bool (*IsCommandPrefix)(
char ch);
471 struct ci_less : binary_function<string, string, bool> {
474 struct nocase_compare :
public binary_function<unsigned char,unsigned char,bool>
476 bool operator() (
const unsigned char& c1,
const unsigned char& c2)
const
477 {
return tolower (c1) < tolower (c2); }
480 bool operator() (
const string & s1,
const string & s2)
const
483 return lexicographical_compare
484 (s1.begin (), s1.end (),
485 s2.begin (), s2.end (),
490 typedef std::map<std::string, std::string, ci_less> sql_row;
491 typedef std::map<int, sql_row> sql_rows;
502 sqlite3 * (*GetHandle)();
503 int (*Query)(
const char * query, sqlite3_callback cb,
void * parm,
char ** error);
504 void (*Free)(
char * ptr);
505 int (*GetTable)(
const char * query,
char ***resultp,
int *nrow,
int *ncolumn,
char **errmsg);
506 const char * (*GetTableEntry)(
int row,
int col,
char **result,
int nrow,
int ncol);
507 void (*FreeTable)(
char **result);
508 char * (*MPrintf)(
const char* fmt,...);
520 CURL * (*easy_init)(void);
521 CURLcode (*easy_setopt)(CURL *curl, CURLoption option, ...);
522 CURLcode (*easy_perform)(CURL *curl);
523 void (*easy_cleanup)(CURL *curl);
524 const char * (*easy_strerror)(CURLcode);
525 CURLcode (*easy_getinfo)(CURL *curl, CURLINFO info, ...);
527 CURLM * (*multi_init)(void);
528 CURLMcode (*multi_add_handle)(CURLM *multi_handle, CURL *curl_handle);
529 CURLMcode (*multi_remove_handle)(CURLM *multi_handle, CURL *curl_handle);
530 CURLMcode (*multi_perform)(CURLM *multi_handle,
int *running_handles);
531 CURLMcode (*multi_cleanup)(CURLM *multi_handle);
532 CURLMsg * (*multi_info_read)(CURLM *multi_handle,
int *msgs_in_queue);
533 const char * (*multi_strerror)(CURLMcode);
535 CURLFORMcode (*formadd)(
struct curl_httppost **httppost,
struct curl_httppost **last_post, ...);
536 void (*formfree)(
struct curl_httppost *form);
538 struct curl_slist * (*slist_append)(
struct curl_slist *,
const char *);
539 void (*slist_free_all)(
struct curl_slist *);
541 char * (*escape)(
const char *string,
int length);
542 char * (*unescape)(
const char *string,
int length);
544 void (*free)(
void *p);
552 void * (
DSL_CC * alloc)(
uint32 lSize,
const char * file,
int line);
553 void * (
DSL_CC *realloc)(
void * ptr,
uint32 lSize,
const char * file,
int line);
554 char * (
DSL_CC *strdup)(
const char * ptr,
const char * file,
int line);
555 wchar_t * (
DSL_CC *wcsdup)(
const wchar_t * ptr,
const char * file,
int line);
556 void (
DSL_CC *free)(
void * ptr,
const char * file,
int line);
557 char * (
DSL_CC *mprintf)(
const char * ptr, ...);
565 bool (*is_nick_in_chan)(
int netno,
const char * chan,
const char * nick);
566 bool (*is_bot_in_chan)(
int netno,
const char * chan);
567 int (*num_nicks_in_chan)(
int netno,
const char * chan);
568 bool (*get_nick_in_chan)(
int netno,
const char * chan,
int num,
char * nick,
int nickSize);
586 USER * (*GetUser)(
const char * hostmask);
592 USER * (*GetUserByNick)(
const char * nick);
593 bool (*IsValidUserName)(
const char * nick);
598 uint32 (*GetUserFlags)(
const char * hostmask);
599 USER * (*AddUser)(
const char * nick,
const char * pass,
uint32 flags,
bool temp);
626 void (*uflag_to_string)(
uint32 flags,
char * buf,
size_t bufSize);
653 bool (*Mask)(
const char * hostmask,
char * msgbuf,
size_t bufSize,
int type);
656 void (*SetLevelFlags)(
int level,
uint32 flags);
682 bool (*GetConfigSectionValueBuf)(
DS_CONFIG_SECTION * section,
const char * name,
char * buf,
size_t bufSize);
764 int (*TouchYP)(
YP_HANDLE * yp,
const char * cur_playing);
790 bool (*LogToChan)(
const char * buf);
800 int (*SendIRC_Priority)(
int32 netno,
const char * buf,
int32 datalen,
uint8 priority);
826 void (*SetDoSpam)(
bool dospam);
827 void (*SetDoSpamChannel)(
bool dospam,
int netno,
const char * chan);
828 void (*SetDoOnJoin)(
bool doonjoin);
829 void (*SetDoOnJoinChannel)(
bool doonjoin,
int netno,
const char * chan);
836 const char *(*GetCurrentNick)(
int32 net);
842 const char *(*GetDefaultNick)(
int32 net);
843 int (*NumNetworks)();
854 #define REQUESTS_ON(x) (x >= REQ_MODE_NORMAL)
855 #define HAVE_DJ(x) (x >= REQ_MODE_DJ_NOREQ)
869 void (*EnableRequests)(
bool activate);
872 bool (*AreRatingsEnabled)();
873 int (*GetMaxRating)();
875 void (*RateSong)(
const char * song,
const char * nick,
uint32 rating);
911 int (*message)(
unsigned int msg,
char * data,
int datalen);
940 int (*raw)(
int netno,
char * msg);
962 const char * (*GetVersionString)();
963 const char * (*GetIP)();
971 const char * (*GetBasePath)();
972 char * (*GetBindIP)(
char * buf,
size_t bufSize);
974 const char * (*get_argv)(
int i);
976 void (*ib_printf2)(
int pluginnum,
const char * fmt, ...);
977 void (*Rehash)(
const char * fn);
981 bool (*LoadPlugin)(
const char * fn);
990 bool (*LoadMessage)(
const char * name,
char * msgbuf,
int32 bufSize);
999 void (*ProcText)(
char * text,
int32 bufSize);
1000 void (*SetCustomVar)(
const char * name,
const char * val);
1001 void (*DeleteCustomVar)(
const char * name);
1009 const char * (*GetLangString)(
const char * str);
1011 void (*safe_sleep_seconds)(
int32 sleepfor);
1012 void (*safe_sleep_milli)(
int32 sleepfor);
1014 int (*get_rand)(
int min,
int max);
1017 int (*SendMessage)(
int toplug,
uint32 MsgID,
char * data,
int32 datalen);
1029 #if !defined(IRCBOT_LITE)
1033 void * unused_lite[2];
1041 #define SendIRC(x,y,z) SendIRC_Priority(x,y,z,PRIORITY_DEFAULT)
1046 #define SendSock(x,y,z) SendSock_Priority(x,y,z,PRIORITY_DEFAULT)
1048 #if !defined(__INCLUDE_IRCBOT_MAIN_H__)
1049 #define BOTAPI_DEF BOTAPI
1050 #define API_SS SOUND_SERVER
1051 #if defined(_ADJ_PLUGIN_H_) && !defined(_AUTODJ_)
1052 #define _(x) api->botapi->GetLangString(x)
1053 #define ib_printf(x, ...) ib_printf2(api->GetPluginNum(), x, ##__VA_ARGS__)
1054 #elif defined(_SDJ_PLUGIN_H_) && !defined(_SIMPLEDJ_)
1055 #define _(x) api->botapi->GetLangString(x)
1056 #define ib_printf(x, ...) ib_printf2(api->GetPluginNum(), x, ##__VA_ARGS__)
1058 #define _(x) api->GetLangString(x)
1059 #define ib_printf(x, ...) ib_printf2(pluginnum, x, ##__VA_ARGS__)
1075 #endif // __INCLUDE_IRCBOT_PLUGINS_H__
Definition: plugins.h:848
Definition: plugins.h:779
time_t Created
When the user was created (only persistent for non-temporary users)
Definition: plugins.h:161
Definition: plugins.h:857
void * T_SOCKET
Definition: plugins.h:51
unsigned char plugin_ver
The bot binary ABI identifier, you should always set this to IRCBOT_PLUGIN_VERSION instead of setting...
Definition: plugins.h:882
bool has_source
Does this sound server have a source connected to it? (ie. is there a stream active right now) ...
Definition: plugins.h:329
Definition: plugins.h:441
signed int int32
Definition: plugins.h:43
#define DL_HANDLE
Definition: plugins.h:40
API_ss * ss
Definition: plugins.h:1031
const char * Hostmask
The user's hostmask.
Definition: plugins.h:201
COMMAND_ACL acl
The flags needed (and not allowed) to use this command.
Definition: plugins.h:275
uint32 ref_cnt
DO NOT TOUCH!!! Only the ref and unref commands should alter ref_cnt.
Definition: plugins.h:187
Definition: plugins.h:723
CommandProcType proc
The command handler (if proc_type == COMMAND_PROC)
Definition: plugins.h:272
uint32 ref_cnt
DO NOT TOUCH!!!
Definition: plugins.h:278
const char * Nick
The user's username/nick.
Definition: plugins.h:200
REQUEST_MODES
Definition: plugins.h:847
signed short int16
Definition: plugins.h:45
void * DS_CONFIG_SECTION
Definition: plugins.h:52
userPresSendFunc send_chan_notice
Send a NOTICE to the channel the user is in (ONLY valid if Channel != NULL)
Definition: plugins.h:216
void * Ptr1
Data for the USER_PRESENCE provider, ptr to their own data structure.
Definition: plugins.h:210
uint32 flags_any
user must have at least one of these to be allowed
Definition: plugins.h:255
int num_songs
Definition: plugins.h:386
Definition: plugins.h:307
unsigned char uint8
Definition: plugins.h:48
int bitrate
Definition: plugins.h:340
int NetNo
The network # if applicable (for multiple server protocols like IRC), -1 otherwise.
Definition: plugins.h:203
uint32 flags_not
user cannot have any of these flags and be allowed
Definition: plugins.h:256
#define REF_TRACKING_DEPTH
Definition: plugins.h:137
char * fn
At a minimum fn must be set so the bot has something to display. The bot will automatically show only...
Definition: plugins.h:373
uint32 yp_id
Definition: plugins.h:724
void * private_struct
Definition: plugins.h:957
Definition: plugins.h:323
const char * Desc
Description of the medium this presence is on. ie. IRC, Jabber, etc.
Definition: plugins.h:206
char * plugin_name_short
The short name of your plugin, it should be 3 or less words and NOT have a version number or anything...
Definition: plugins.h:885
unsigned short uint16
Definition: plugins.h:46
Definition: plugins.h:400
REMOTE_COMMANDS cmd
The command to execute, or reply if from the bot to client.
Definition: plugins.h:308
Definition: plugins.h:253
void * unused
Definition: plugins.h:968
const char * source_name
Definition: plugins.h:734
#define DEPRECATE
Definition: plugins.h:76
Definition: plugins.h:778
Definition: plugins.h:357
SS_TYPES
Definition: plugins.h:129
Definition: plugins.h:960
int peak
Definition: plugins.h:342
const char * command
A string containing the command name.
Definition: plugins.h:264
Definition: plugins.h:154
Definition: plugins.h:263
uint32 Rating
The song rating from 0-5 (0 = not rated)
Definition: plugins.h:358
Definition: plugins.h:551
void(* find_finish_type)(USER_PRESENCE *ut, FIND_RESULTS *qRes, int max)
Definition: plugins.h:392
#define DSL_CC
Definition: plugins.h:49
char * guid
The unique GUID for your plugin. It should be in "registry" format, and please use a real GUID genera...
Definition: plugins.h:884
uint32 ref_cnt
DO NOT TOUCH!!! Only the ref and unref commands should alter ref_cnt.
Definition: plugins.h:239
CommandProcType help_proc
Optional handler to provide extended help beyond the desc field above.
Definition: plugins.h:269
uint32 Flags
IRC letter-based flag system (+o/-x/etc.)
Definition: plugins.h:159
A SHOUTcast v2 (Ultravox protocol) server.
Definition: plugins.h:131
bool online
Is your radio online (depends on setting of PullNameFromAnyServer how it is calculated) ...
Definition: plugins.h:338
Definition: plugins.h:789
Definition: plugins.h:782
Definition: plugins.h:850
Definition: plugins.h:381
uint32 datalen
The length of data following the header (little-endian)
Definition: plugins.h:309
REMOTE_COMMANDS
Definition: remote_protocol.h:39
bool title_changed
Did the title change from the last scrape?
Definition: plugins.h:339
const char * mime_type
Definition: plugins.h:735
Definition: plugins.h:580
Definition: plugins.h:133
unsigned long long uint64
Definition: plugins.h:42
Definition: plugins.h:733
bool Temporary
The user was gotten from a remote source (auth plugin). The user account won't be loaded again the ne...
Definition: plugins.h:160
const char * platform
The platform the bot is running on.
Definition: plugins.h:964
Definition: plugins.h:781
uint32 Votes
The number of votes on this song.
Definition: plugins.h:359
Definition: plugins.h:851
const char * cur_playing
Definition: plugins.h:736
Definition: plugins.h:519
const char * Channel
If presence was caused by something in a channel/group, it will be here, otherwise it will be NULL...
Definition: plugins.h:204
uint32 id
Optional member the source plugin can use however it wants.
Definition: plugins.h:374
USER * User
A ptr to a USER structure if the person here matched a hostmask and is an IRCBot user, or NULL if it isn't an IRCBot user.
Definition: plugins.h:197
userPresSendFunc send_notice
Send a NOTICE to the user. On protocols where there is no distinction between notices, PMs, etc., it will be the same as send_msg.
Definition: plugins.h:218
int32 streamid
Definition: plugins.h:327
userPresSendFunc send_chan
Send a message to the channel the user is in (ONLY valid if Channel != NULL)
Definition: plugins.h:215
A SHOUTcast v1 server.
Definition: plugins.h:130
API_ial * ial
Definition: plugins.h:1020
const char * genre
Definition: plugins.h:737
DL_HANDLE hInstance
Definition: plugins.h:954
T_SOCKET * Sock
Data for the USER_PRESENCE provider, a socket.
Definition: plugins.h:209
Definition: plugins.h:134
API_memory * mem
Definition: plugins.h:1027
API_config * config
Definition: plugins.h:1024
API_yp * yp
Definition: plugins.h:1030
int plugin
Plugin number that registered this command, or -1 for an IRCBot internal command. ...
Definition: plugins.h:277
API_textfunc * textfunc
Definition: plugins.h:1021
int(* CommandProcType)(const char *command, const char *parms, USER_PRESENCE *ut, uint32 type)
type is one of the CM_ALLOW_* defines below
Definition: plugins.h:244
Definition: plugins.h:664
const char * desc
A string containing the help text for the command.
Definition: plugins.h:268
API_user * user
Definition: plugins.h:1023
char * plugin_author
The name of the author of this plugin. (Can be a person, company, URL, whatever). ...
Definition: plugins.h:887
Definition: plugins.h:780
signed long long int64
Definition: plugins.h:41
const char int line
Definition: plugins.h:556
uint32 mask
A bitmask of the CM_ALLOW_* defines below, specifies from which contexts a command may be used...
Definition: plugins.h:276
Definition: plugins.h:501
int listeners
Definition: plugins.h:341
Definition: plugins.h:849
Definition: plugins.h:564
An icecast2 server.
Definition: plugins.h:132
userPresSendFunc std_reply
This is for a command reply to simplify code for IRC. If the user said something in the channel to ac...
Definition: plugins.h:214
Definition: plugins.h:745
Definition: plugins.h:852
unsigned int uint32
Definition: plugins.h:44
char * plugin_name_long
The long name of your plugin with version info (if you want).
Definition: plugins.h:886
int32 NumHostmasks
Definition: plugins.h:164
#define MAX_FIND_RESULTS
Definition: plugins.h:365
int maxusers
Definition: plugins.h:343
API_commands * commands
Definition: plugins.h:1022
Definition: plugins.h:418
uint32 proc_type
COMMAND_ACTION or COMMAND_PROC.
Definition: plugins.h:274
API_db * db
Definition: plugins.h:1025
signed char int8
Definition: plugins.h:47
API_irc * irc
Definition: plugins.h:1019
uint32 flags_all
user must have all these flags to be allowed
Definition: plugins.h:254
Definition: plugins.h:196
Definition: plugins.h:337
API_curl * curl
Definition: plugins.h:1026
bool(* EnumUsersByLastHostmaskCallback)(USER *user, void *ptr)
Definition: plugins.h:572
const char * action
The raw IRC command to send (if proc_type == COMMAND_ACTION)
Definition: plugins.h:271
bool have_more
Definition: plugins.h:387
Definition: plugins.h:881
Definition: plugins.h:372
int start
Definition: plugins.h:383
uint32 Flags
The user's flags.
Definition: plugins.h:202
SS_TYPES type
The sound server type.
Definition: plugins.h:328
time_t Seen
When the user was last seen.
Definition: plugins.h:162
#define MAX_HOSTMASKS
Definition: plugins.h:86
userPresSendFunc send_msg
Send a PRIVMSG to the user.
Definition: plugins.h:217
int plugin
Definition: plugins.h:389