Jelajahi Sumber

* Properly check the correct bots' groups in bot_shouldjoin

Bryan Drewery 14 tahun lalu
induk
melakukan
48d96d5baf
3 mengubah file dengan 6 tambahan dan 3 penghapusan
  1. 4 2
      src/chanprog.c
  2. 1 1
      src/set.c
  3. 1 0
      src/set.h

+ 4 - 2
src/chanprog.c

@@ -45,6 +45,7 @@
 #include "userrec.h"
 #include "main.h"
 #include "debug.h"
+#include "set.h"
 #include "dccutil.h"
 #include "botmsg.h"
 #if HAVE_GETRUSAGE
@@ -798,8 +799,9 @@ bool bot_shouldjoin(struct userrec* u, struct flag_record* fr, struct chanset_t*
   }
 #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;
 
   if (chan->groups && chan->groups->length()) {

+ 1 - 1
src/set.c

@@ -701,7 +701,7 @@ void var_userfile_share_line(char *line, int idx, bool share)
   set_noshare = 0;
 }
 
-static const char *var_get_bot_data(struct userrec *u, const char *name)
+const char *var_get_bot_data(struct userrec *u, const char *name)
 {
   if (!u)
     return NULL;

+ 1 - 0
src/set.h

@@ -86,6 +86,7 @@ void var_parse_my_botset();
 void init_vars();
 void var_set_by_name(const char *, const char *, const char *);
 void var_set_userentry(const char *, const char *, const char *);
+const char *var_get_bot_data(struct userrec *u, const char *name);
 int cmd_set_real(const char *, int idx, char *);
 const char *var_get_str_by_name(const char *);