modules/ircparty/events.c File Reference

#include <eggdrop/eggdrop.h>
#include "ircparty.h"

Go to the source code of this file.

Functions

static int on_privmsg (void *client_data, partymember_t *dest, botnet_entity_t *src, const char *text, int len)
static int on_nick (void *client_data, partymember_t *src, const char *oldnick, const char *newnick)
static int on_quit (void *client_data, partymember_t *src, const botnet_bot_t *lostbot, const char *text, int len)
static int on_chanmsg (void *client_data, partychan_t *chan, botnet_entity_t *src, const char *text, int len)
static int on_join (void *client_data, partychan_t *chan, partymember_t *src, int linking)
static int on_part (void *client_data, partychan_t *chan, partymember_t *src, const char *text, int len)

Variables

static const char rcsid [] = "$Id: events.c,v 1.11 2007-04-14 15:21:12 sven Exp $"
partyline_event_t irc_party_handler


Function Documentation

static int on_chanmsg ( void *  client_data,
partychan_t chan,
botnet_entity_t src,
const char *  text,
int  len 
) [static]

Definition at line 77 of file events.c.

References botnet_entity::bot, partymember::bot, botnet_get_name(), egg_iprintf(), ENTITY_PARTYMEMBER, partymember::host, partymember::id, partymember::ident, irc_session_t::idx, partychan::name, botnet_bot::name, partymember::nick, irc_session_t::party, botnet_entity::user, and botnet_entity::what.

00078 {
00079   irc_session_t *session = client_data;
00080 
00081   if (src->what == ENTITY_PARTYMEMBER && src->user == session->party) return 0;
00082   if (src && src->what == ENTITY_PARTYMEMBER && src->user->bot) egg_iprintf(session->idx, ":%s*%s:%d!%s@%s PRIVMSG #%s :%s\r\n", src->user->nick, src->user->bot->name, src->user->id, src->user->ident, src->user->host, chan->name, text);
00083   else if (src && src->what == ENTITY_PARTYMEMBER) egg_iprintf(session->idx, ":%s:%d!%s@%s PRIVMSG #%s :%s\r\n", src->user->nick, src->user->id, src->user->ident, src->user->host, chan->name, text);
00084   else if (src && src->bot) egg_iprintf(session->idx, ":%s!%s@%s PRIVMSG #%s :%s\r\n", src->user->bot->name, src->user->bot->name, src->user->bot->name, chan->name, text);
00085   else if (src) egg_iprintf(session->idx, ":%s!%s@%s PRIVMSG #%s :%s\r\n", botnet_get_name(), botnet_get_name(), botnet_get_name(), chan->name, text);
00086   else egg_iprintf(session->idx, ":* PRIVMSG #%s :%s\r\n", chan->name, text);
00087   return 0;
00088 }

static int on_join ( void *  client_data,
partychan_t chan,
partymember_t src,
int  linking 
) [static]

Definition at line 90 of file events.c.

References partymember::bot, egg_iprintf(), partychan_member::flags, partymember::host, partymember::id, partymember::ident, irc_session_t::idx, partychan::members, partychan::name, botnet_bot::name, irc_session_t::nick, partymember::nick, partychan::nmembers, partychan_member::p, irc_session_t::party, and PARTY_DELETED.

00091 {
00092   irc_session_t *session = client_data;
00093   partychan_member_t *m;
00094   partymember_t *p;
00095   int i, cur, len;
00096   char buf[510], nick[128];
00097 
00098   if (session->party != src) {
00099     if (src->bot) egg_iprintf(session->idx, ":%s*%s:%d!%s@%s JOIN #%s\r\n", src->nick, src->bot->name, src->id, src->ident, src->host, chan->name);
00100     else egg_iprintf(session->idx, ":%s:%d!%s@%s JOIN #%s\r\n", src->nick, src->id, src->ident, src->host, chan->name);
00101     return(0);
00102   }
00103 
00104   egg_iprintf(session->idx, ":%s!%s@%s JOIN #%s\r\n", src->nick, src->ident, src->host, chan->name);
00105 
00106   sprintf(buf, ":eggdrop.bot 353 %s @ #%s :", session->nick, chan->name);
00107   cur = strlen(buf);
00108 
00109   for (i = 0; i < chan->nmembers; i++) {
00110     m = chan->members+i;
00111     if (chan->members[i].flags & PARTY_DELETED) continue;
00112     p = m->p;
00113     if (session->party == p) snprintf(nick, sizeof(nick), "%s", p->nick);
00114     else if (p->bot) snprintf(nick, sizeof(nick), "%s*%s:%d", p->nick, p->bot->name, p->id);
00115     else snprintf(nick, sizeof(nick), "%s:%d", p->nick, p->id);
00116     len = strlen(nick);
00117     if (cur + len > 500) {
00118       cur--;
00119       buf[cur] = 0;
00120       egg_iprintf(session->idx, "%s\r\n", buf);
00121       sprintf(buf, ":eggdrop.bot 353 %s @ #%s :", session->nick, chan->name);
00122       cur = strlen(buf);
00123     }
00124     strcpy(buf+cur, nick);
00125     cur += len;
00126     buf[cur++] = ' ';
00127   }
00128 
00129   if (cur > 0) {
00130     cur--;
00131     buf[cur] = 0;
00132     egg_iprintf(session->idx, "%s\r\n", buf);
00133   }
00134   egg_iprintf(session->idx, ":eggdrop.bot 366 %s #%s :End of /NAMES list.\r\n", session->nick, chan->name);
00135   return(0);
00136 }

static int on_nick ( void *  client_data,
partymember_t src,
const char *  oldnick,
const char *  newnick 
) [static]

Definition at line 56 of file events.c.

References partymember::bot, egg_iprintf(), partymember::host, partymember::id, partymember::ident, irc_session_t::idx, botnet_bot::name, and irc_session_t::party.

00057 {
00058   irc_session_t *session = client_data;
00059 
00060   if (src != session->party && src->bot) egg_iprintf(session->idx, ":%s*%s:%d!%s@%s NICK %s*%s:%d\r\n", oldnick, src->bot->name, src->id, src->ident, src->host, newnick, src->bot->name, src->id);
00061   else if (src != session->party) egg_iprintf(session->idx, ":%s:%d!%s@%s NICK %s:%d\r\n", oldnick, src->id, src->ident, src->host, newnick, src->bot->name, src->id); 
00062   else egg_iprintf(session->idx, ":%s!%s@%s NICK %s\r\n", oldnick, src->ident, src->host, newnick);
00063   return(0);
00064 }

static int on_part ( void *  client_data,
partychan_t chan,
partymember_t src,
const char *  text,
int  len 
) [static]

Definition at line 138 of file events.c.

References partymember::bot, egg_iprintf(), partymember::host, partymember::id, partymember::ident, irc_session_t::idx, botnet_bot::name, partychan::name, partymember::nick, and irc_session_t::party.

00139 {
00140   irc_session_t *session = client_data;
00141 
00142   if (session->party == src) egg_iprintf(session->idx, ":%s!%s@%s PART #%s :%s\r\n", src->nick, src->ident, src->host, chan->name, text);
00143   else if (src->bot) egg_iprintf(session->idx, ":%s*%s:%d!%s@%s PART #%s :%s\r\n", src->nick, src->bot->name, src->id, src->ident, src->host, chan->name, text);
00144   else egg_iprintf(session->idx, ":%s:%d!%s@%s PART #%s :%s\r\n", src->nick, src->id, src->ident, src->host, chan->name, text);
00145   return(0);
00146 }

static int on_privmsg ( void *  client_data,
partymember_t dest,
botnet_entity_t src,
const char *  text,
int  len 
) [static]

Definition at line 44 of file events.c.

References botnet_entity::bot, partymember::bot, botnet_get_name(), egg_iprintf(), ENTITY_PARTYMEMBER, partymember::host, partymember::id, partymember::ident, irc_session_t::idx, botnet_bot::name, partymember::nick, botnet_entity::user, and botnet_entity::what.

00045 {
00046   irc_session_t *session = client_data;
00047 
00048   if (src && src->what == ENTITY_PARTYMEMBER && src->user->bot) egg_iprintf(session->idx, ":%s*%s:%d!%s@%s PRIVMSG %s :%s\r\n", src->user->nick, src->user->bot->name, src->user->id, src->user->ident, src->user->host, dest->nick, text);
00049   else if (src && src->what == ENTITY_PARTYMEMBER) egg_iprintf(session->idx, ":%s:%d!%s@%s PRIVMSG %s :%s\r\n", src->user->nick, src->user->id, src->user->ident, src->user->host, dest->nick, text); 
00050   else if (src && src->bot) egg_iprintf(session->idx, ":%s!%s@%s PRIVMSG %s :%s\r\n", src->bot->name, src->bot->name, src->bot->name, dest->nick, text);
00051   else if (src) egg_iprintf(session->idx, ":%s!%s@%s PRIVMSG %s :%s\r\n", botnet_get_name(), botnet_get_name(), botnet_get_name(), dest->nick, text);
00052   else egg_iprintf(session->idx, ":* NOTICE * :%s\r\n", text);
00053   return(0);
00054 }

static int on_quit ( void *  client_data,
partymember_t src,
const botnet_bot_t lostbot,
const char *  text,
int  len 
) [static]

Definition at line 66 of file events.c.

References partymember::bot, egg_iprintf(), partymember::host, partymember::id, partymember::ident, irc_session_t::idx, botnet_bot::name, partymember::nick, and irc_session_t::party.

00067 {
00068   irc_session_t *session = client_data;
00069 
00070   if (src != session->party && src->bot) egg_iprintf(session->idx, ":%s*%s:%d!%s@%s QUIT :%s\r\n", src->nick, src->bot->name, src->id, src->ident, src->host, text);
00071   else if (src != session->party) egg_iprintf(session->idx, ":%s:%d!%s@%s QUIT :%s\r\n", src->nick, src->id, src->ident, src->host, text);
00072   else egg_iprintf(session->idx, "ERROR :%s\r\n", text);
00073 
00074   return(0);
00075 }


Variable Documentation

Initial value:

Definition at line 35 of file events.c.

const char rcsid[] = "$Id: events.c,v 1.11 2007-04-14 15:21:12 sven Exp $" [static]

Definition at line 21 of file events.c.


Generated on Sun Nov 30 18:43:35 2008 for eggdrop1.9 by  doxygen 1.5.6