|
@@ -45,6 +45,7 @@
|
|
|
#include "userrec.h"
|
|
#include "userrec.h"
|
|
|
#include "main.h"
|
|
#include "main.h"
|
|
|
#include "debug.h"
|
|
#include "debug.h"
|
|
|
|
|
+#include "set.h"
|
|
|
#include "dccutil.h"
|
|
#include "dccutil.h"
|
|
|
#include "botmsg.h"
|
|
#include "botmsg.h"
|
|
|
#if HAVE_GETRUSAGE
|
|
#if HAVE_GETRUSAGE
|
|
@@ -743,68 +744,6 @@ int isowner(char *name)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/* this method is slow, but is only called when sharing and adding/removing chans */
|
|
|
|
|
-
|
|
|
|
|
-int
|
|
|
|
|
-botshouldjoin(struct userrec *u, struct chanset_t *chan)
|
|
|
|
|
-{
|
|
|
|
|
- /* just return 1 for now */
|
|
|
|
|
- return 1;
|
|
|
|
|
-/*
|
|
|
|
|
- char *chans = NULL;
|
|
|
|
|
- struct userrec *u = NULL;
|
|
|
|
|
-
|
|
|
|
|
- u = get_user_by_handle(userlist, bot);
|
|
|
|
|
- if (!u)
|
|
|
|
|
- return;
|
|
|
|
|
- chans = get_user(&USERENTRY_CHANS, u);
|
|
|
|
|
-*/
|
|
|
|
|
-}
|
|
|
|
|
-/* future use ?
|
|
|
|
|
-void
|
|
|
|
|
-chans_addbot(const char *bot, struct chanset_t *chan)
|
|
|
|
|
-{
|
|
|
|
|
- char *chans = NULL;
|
|
|
|
|
- struct userrec *u = NULL;
|
|
|
|
|
-
|
|
|
|
|
- u = get_user_by_handle(userlist, bot);
|
|
|
|
|
- if (!u)
|
|
|
|
|
- return;
|
|
|
|
|
- chans = get_user(&USERENTRY_CHANS, u);
|
|
|
|
|
- if (!botshouldjoin(u, chan)) {
|
|
|
|
|
- size_t size;
|
|
|
|
|
- char *buf = NULL;
|
|
|
|
|
-
|
|
|
|
|
- size = strlen(chans) + strlen(chan->dname) + 2;
|
|
|
|
|
- buf = (char *) my_calloc(1, size);
|
|
|
|
|
- simple_snprintf(buf, size, "%s %s", chans, chan->dname);
|
|
|
|
|
- set_user(&USERENTRY_CHANS, u, buf);
|
|
|
|
|
- free(buf);
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void
|
|
|
|
|
-chans_delbot(const char *bot, struct chanset_t *chan)
|
|
|
|
|
-{
|
|
|
|
|
- char *chans = NULL;
|
|
|
|
|
- struct userrec *u = NULL;
|
|
|
|
|
-
|
|
|
|
|
- u = get_user_by_handle(userlist, bot);
|
|
|
|
|
- if (!u)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- if (botshouldjoin(u, chan)) {
|
|
|
|
|
- char *chans = NULL, *buf = NULL;
|
|
|
|
|
- size_t size;
|
|
|
|
|
-
|
|
|
|
|
- chans = get_user(&USERENTRY_CHANS, u);
|
|
|
|
|
- size = strlen(chans) - strlen(chan->dname) + 2;
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-*/
|
|
|
|
|
-
|
|
|
|
|
bool bot_shouldjoin(struct userrec* u, struct flag_record* fr, struct chanset_t* chan, bool ignore_inactive)
|
|
bool bot_shouldjoin(struct userrec* u, struct flag_record* fr, struct chanset_t* chan, bool ignore_inactive)
|
|
|
{
|
|
{
|
|
|
// If restarting, keep this channel.
|
|
// If restarting, keep this channel.
|
|
@@ -827,8 +766,9 @@ bool bot_shouldjoin(struct userrec* u, struct flag_record* fr, struct chanset_t*
|
|
|
}
|
|
}
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
- // Am I in the groups that this channel has?
|
|
|
|
|
- bd::Array<bd::String> my_groupsArray(bd::String(groups).split(','));
|
|
|
|
|
|
|
+ // Is this bot in the groups that this channel has?
|
|
|
|
|
+ const char *botgroups = u == conf.bot->u ? groups : var_get_bot_data(u, "groups");
|
|
|
|
|
+ bd::Array<bd::String> my_groupsArray(bd::String(botgroups).split(','));
|
|
|
bool group_match = 0;
|
|
bool group_match = 0;
|
|
|
|
|
|
|
|
if (chan->groups && chan->groups->length()) {
|
|
if (chan->groups && chan->groups->length()) {
|