fix some channels not auto join
This commit is contained in:
@@ -1110,13 +1110,21 @@ static int srv_alloc(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void srv_add_autojoin(int si, const char *chanlist) {
|
static void srv_add_autojoin(int si, const char *chanlist) {
|
||||||
char tmp[512]; strncpy(tmp,chanlist,511);
|
char tmp[MAX_LINE]; strncpy(tmp, chanlist, MAX_LINE-1);
|
||||||
char *tok = strtok(tmp, ",");
|
char *tok = strtok(tmp, ",");
|
||||||
while (tok) {
|
while (tok) {
|
||||||
|
/* trim leading and trailing spaces */
|
||||||
while (*tok == ' ') tok++;
|
while (*tok == ' ') tok++;
|
||||||
|
char *end = tok + strlen(tok) - 1;
|
||||||
|
while (end > tok && *end == ' ') *end-- = '\0';
|
||||||
if (*tok && g_srv[si].autojoin_count < MAX_AUTOJOIN) {
|
if (*tok && g_srv[si].autojoin_count < MAX_AUTOJOIN) {
|
||||||
char ch[MAX_CHAN]; strncpy(ch, tok, MAX_CHAN-1);
|
char ch[MAX_CHAN]; strncpy(ch, tok, MAX_CHAN-1);
|
||||||
if (ch[0] != '#') { memmove(ch+1, ch, strlen(ch)+1); ch[0]='#'; }
|
if (ch[0] != '#') { memmove(ch+1, ch, strlen(ch)+1); ch[0]='#'; }
|
||||||
|
/* avoid duplicates */
|
||||||
|
int dup = 0;
|
||||||
|
for (int i = 0; i < g_srv[si].autojoin_count; i++)
|
||||||
|
if (strcasecmp(g_srv[si].autojoin[i], ch) == 0) { dup=1; break; }
|
||||||
|
if (!dup)
|
||||||
strncpy(g_srv[si].autojoin[g_srv[si].autojoin_count++], ch, MAX_CHAN-1);
|
strncpy(g_srv[si].autojoin[g_srv[si].autojoin_count++], ch, MAX_CHAN-1);
|
||||||
}
|
}
|
||||||
tok = strtok(NULL, ",");
|
tok = strtok(NULL, ",");
|
||||||
@@ -1492,15 +1500,20 @@ static void build_windows(void) {
|
|||||||
/* ── event handler ─────────────────────────────────────────────────────────── */
|
/* ── event handler ─────────────────────────────────────────────────────────── */
|
||||||
|
|
||||||
static void do_rejoin_channels(int si) {
|
static void do_rejoin_channels(int si) {
|
||||||
int any=0;
|
/* always join every configured autojoin channel */
|
||||||
for (int i=0;i<g_chan_count;i++) {
|
|
||||||
if (g_chans[i].srv==si && g_chans[i].name[0]=='#') {
|
|
||||||
srv_sendf(si,"JOIN %s",g_chans[i].name); any=1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!any) {
|
|
||||||
for (int j = 0; j < g_srv[si].autojoin_count; j++)
|
for (int j = 0; j < g_srv[si].autojoin_count; j++)
|
||||||
srv_sendf(si, "JOIN %s", g_srv[si].autojoin[j]);
|
srv_sendf(si, "JOIN %s", g_srv[si].autojoin[j]);
|
||||||
|
|
||||||
|
/* also rejoin any channels open from a previous session that aren't
|
||||||
|
in the autojoin list (e.g. channels joined manually before disconnect) */
|
||||||
|
for (int i = 0; i < g_chan_count; i++) {
|
||||||
|
if (g_chans[i].srv != si || g_chans[i].name[0] != '#') continue;
|
||||||
|
int already = 0;
|
||||||
|
for (int j = 0; j < g_srv[si].autojoin_count; j++)
|
||||||
|
if (strcasecmp(g_srv[si].autojoin[j], g_chans[i].name) == 0)
|
||||||
|
{ already = 1; break; }
|
||||||
|
if (!already)
|
||||||
|
srv_sendf(si, "JOIN %s", g_chans[i].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user