added broadcast message and getter for user count in plugin API
This commit is contained in:
parent
1da917e5b9
commit
2d45a37536
@ -65,6 +65,17 @@ static int cbfunc_send_message(struct plugin_handle* plugin, struct plugin_user*
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cbfunc_send_broadcast(struct plugin_handle* plugin, const char* message)
|
||||
{
|
||||
char* buffer = adc_msg_escape(message);
|
||||
struct adc_message* command = adc_msg_construct(ADC_CMD_IMSG, strlen(buffer) + 6);
|
||||
adc_msg_add_argument(command, buffer);
|
||||
route_to_all(plugin_get_hub(plugin), command);
|
||||
adc_msg_free(command);
|
||||
hub_free(buffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cbfunc_send_status(struct plugin_handle* plugin, struct plugin_user* user, int code, const char* message)
|
||||
{
|
||||
char code_str[4];
|
||||
@ -128,6 +139,12 @@ struct plugin_command_arg_data* cbfunc_command_arg_next(struct plugin_handle* pl
|
||||
return (struct plugin_command_arg_data*) hub_command_arg_next((struct hub_command*) cmd, (enum hub_command_arg_type) t);
|
||||
}
|
||||
|
||||
static size_t cbfunc_get_usercount(struct plugin_handle* plugin)
|
||||
{
|
||||
struct hub_info* hub = plugin_get_hub(plugin);
|
||||
return hub->users->count;
|
||||
}
|
||||
|
||||
static char* cbfunc_get_hub_name(struct plugin_handle* plugin)
|
||||
{
|
||||
struct hub_info* hub = plugin_get_hub(plugin);
|
||||
@ -183,12 +200,14 @@ static void cbfunc_set_hub_description(struct plugin_handle* plugin, const char*
|
||||
void plugin_register_callback_functions(struct plugin_handle* handle)
|
||||
{
|
||||
handle->hub.send_message = cbfunc_send_message;
|
||||
handle->hub.send_broadcast_message = cbfunc_send_broadcast;
|
||||
handle->hub.send_status_message = cbfunc_send_status;
|
||||
handle->hub.user_disconnect = cbfunc_user_disconnect;
|
||||
handle->hub.command_add = cbfunc_command_add;
|
||||
handle->hub.command_del = cbfunc_command_del;
|
||||
handle->hub.command_arg_reset = cbfunc_command_arg_reset;
|
||||
handle->hub.command_arg_next = cbfunc_command_arg_next;
|
||||
handle->hub.get_usercount = cbfunc_get_usercount;
|
||||
handle->hub.get_name = cbfunc_get_hub_name;
|
||||
handle->hub.set_name = cbfunc_set_hub_name;
|
||||
handle->hub.get_description = cbfunc_get_hub_description;
|
||||
|
@ -110,6 +110,7 @@ struct plugin_command;
|
||||
struct plugin_command_arg_data;
|
||||
|
||||
typedef int (*hfunc_send_message)(struct plugin_handle*, struct plugin_user* user, const char* message);
|
||||
typedef int (*hfunc_send_broadcast_message)(struct plugin_handle*, const char* message);
|
||||
typedef int (*hfunc_send_status)(struct plugin_handle*, struct plugin_user* to, int code, const char* message);
|
||||
typedef int (*hfunc_user_disconnect)(struct plugin_handle*, struct plugin_user* user);
|
||||
typedef int (*hfunc_command_add)(struct plugin_handle*, struct plugin_command_handle*);
|
||||
@ -118,6 +119,8 @@ typedef int (*hfunc_command_del)(struct plugin_handle*, struct plugin_command_ha
|
||||
typedef size_t (*hfunc_command_arg_reset)(struct plugin_handle*, struct plugin_command*);
|
||||
typedef struct plugin_command_arg_data* (*hfunc_command_arg_next)(struct plugin_handle*, struct plugin_command*, enum plugin_command_arg_type);
|
||||
|
||||
typedef size_t (*hfunc_get_usercount)(struct plugin_handle*);
|
||||
|
||||
typedef char* (*hfunc_get_hub_name)(struct plugin_handle*);
|
||||
typedef void (*hfunc_set_hub_name)(struct plugin_handle*, const char*);
|
||||
typedef char* (*hfunc_get_hub_description)(struct plugin_handle*);
|
||||
@ -130,12 +133,14 @@ typedef void (*hfunc_set_hub_description)(struct plugin_handle*, const char*);
|
||||
struct plugin_hub_funcs
|
||||
{
|
||||
hfunc_send_message send_message;
|
||||
hfunc_send_broadcast_message send_broadcast_message;
|
||||
hfunc_send_status send_status_message;
|
||||
hfunc_user_disconnect user_disconnect;
|
||||
hfunc_command_add command_add;
|
||||
hfunc_command_del command_del;
|
||||
hfunc_command_arg_reset command_arg_reset;
|
||||
hfunc_command_arg_next command_arg_next;
|
||||
hfunc_get_usercount get_usercount;
|
||||
hfunc_get_hub_name get_name;
|
||||
hfunc_set_hub_name set_name;
|
||||
hfunc_get_hub_description get_description;
|
||||
|
Loading…
Reference in New Issue
Block a user