4
0

egg_chancontrol.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (C) 2000,2001 Florian Sander
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. static void egg_check_chan_desynch()
  19. {
  20. struct stats_chan *chan;
  21. struct chanset_t *eggchan;
  22. memberlist *m;
  23. int eggmembers, statsmembers;
  24. for (eggchan = chanset; eggchan; eggchan = eggchan->next) {
  25. if (!schan_find(eggchan->dname))
  26. schan_add(eggchan->dname);
  27. }
  28. for (chan = schan_getfirst(); chan; chan = schan_getnext()) {
  29. eggchan = findchan_by_dname(chan->chan);
  30. if (!eggchan) {
  31. debug1("Eggdrop doesn't know '%s'. Removing from schanlist...", chan->chan);
  32. schan_remove(chan->chan);
  33. continue;
  34. }
  35. statsmembers = schan_members_count(&chan->members);
  36. eggmembers = eggchan->channel.members;
  37. if (statsmembers != eggmembers) {
  38. debug3("Channel '%s' desynched: %d eggmembers vs %d statsmembers. Resynching...",
  39. chan->chan, eggmembers, statsmembers);
  40. ci_clearchan(chan);
  41. for (m = eggchan->channel.member; m && m->nick && *m->nick; m = m->next) {
  42. if (m->userhost)
  43. schan_join(chan, m->nick, m->userhost, m->user ? m->user->handle : NULL);
  44. }
  45. }
  46. }
  47. }
  48. static int egg_chan_active(char *chan)
  49. {
  50. if (!list_secret_chans && secretchan(chan))
  51. return 0;
  52. if (inactivechan(chan))
  53. return 0;
  54. return 1;
  55. }