Attempt to send messages via the Operations bot as private messages.
This commit is contained in:
parent
2be48a13f7
commit
d98f013a51
|
@ -808,6 +808,25 @@ static void unload_ssl_certificates(struct hub_info* hub)
|
|||
|
||||
// #ifdef BOT_SUPPORT
|
||||
|
||||
static void route_privmsg_to_operators(struct hub_user* bot, sid_t from, const char* escaped_msg, int action)
|
||||
{
|
||||
struct hub_info* hub = bot->hub;
|
||||
struct hub_user* user = (struct hub_user*) list_get_first(hub->users->list);
|
||||
while (user)
|
||||
{
|
||||
if (from != user->id.sid && user_flag_get(user, flag_opnotify))
|
||||
{
|
||||
struct adc_message* msg = adc_msg_construct_source_dest(ADC_CMD_EMSG, from, user->id.sid, strlen(escaped_msg) + (action * 4) + 7);
|
||||
adc_msg_add_argument(msg, escaped_msg);
|
||||
adc_msg_add_named_argument(msg, ADC_MSG_FLAG_PRIVATE, sid_to_string(bot->id.sid));
|
||||
if (action) adc_msg_add_named_argument(msg, ADC_MSG_FLAG_ACTION, "1");
|
||||
route_to_user(hub, user, msg);
|
||||
adc_msg_free(msg);
|
||||
}
|
||||
user = (struct hub_user*) list_get_next(hub->users->list);
|
||||
}
|
||||
}
|
||||
|
||||
/// This receives private messages and transmits them to the connected operators.
|
||||
static void hub_bot_op_notify_handle(struct hub_user* bot, struct adc_message* msg)
|
||||
{
|
||||
|
@ -819,7 +838,7 @@ static void hub_bot_op_notify_handle(struct hub_user* bot, struct adc_message* m
|
|||
case ADC_CMD_DMSG:
|
||||
chat = adc_msg_get_argument(msg, 0);
|
||||
LOG_DEBUG("Hub chat: \"%s\"", chat);
|
||||
hub_notify(bot->hub, notify_info, chat);
|
||||
route_privmsg_to_operators(bot, msg->source, chat, adc_msg_has_named_argument(msg, ADC_MSG_FLAG_ACTION) ? 1 : 0);
|
||||
hub_free(chat);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -83,7 +83,7 @@ static const char* generate_bot_cid(struct hub_info* hub, const char* nick)
|
|||
struct hub_user* user_create_bot(struct hub_info* hub, const char* nick, const char* description, bot_recv_msg msg_handler)
|
||||
{
|
||||
struct hub_user* user = NULL;
|
||||
LOG_TRACE("user_create_bot(), hub=%p, con[sd=%d]", hub, net_con_get_sd(con));
|
||||
LOG_TRACE("user_create_bot(), hub=%p, nick=\"%s\"", hub, nick);
|
||||
|
||||
user = (struct hub_user*) hub_malloc_zero(sizeof(struct hub_user));
|
||||
if (user == NULL)
|
||||
|
|
Loading…
Reference in New Issue