#include <eggdrop/eggdrop.h>
#include "oldbotnet.h"
Go to the source code of this file.
Functions | |
static int | on_bcast (void *client_data, botnet_entity_t *src, const char *text, int len) |
Send a broadcast event out. | |
static int | on_privmsg (void *client_data, botnet_entity_t *src, partymember_t *dst, const char *text, int len) |
static int | on_nick (void *client_data, partymember_t *src, const char *oldnick) |
static int | on_quit (void *client_data, partymember_t *src, 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 *reason, int len) |
static int | on_new_bot (void *client_data, botnet_bot_t *bot, int linking) |
static int | on_lost_bot (void *client_data, botnet_bot_t *bot, const char *reason) |
static int | on_link (void *client_data, botnet_entity_t *from, botnet_bot_t *dst, const char *target) |
static int | on_unlink (void *client_data, botnet_entity_t *from, botnet_bot_t *bot, const char *reason) |
static int | on_botmsg (void *client_data, botnet_bot_t *src, botnet_bot_t *dst, const char *command, const char *text, int len) |
static int | on_botbroadcast (void *client_data, botnet_bot_t *src, const char *command, const char *text, int len) |
static int | on_extension (void *client_data, botnet_entity_t *src, botnet_bot_t *dst, const char *cmd, const char *text, int len) |
static const char * | filter (const char *text) |
Variables | |
static const char | rcsid [] = "$Id: events.c,v 1.14 2007-11-06 00:05:40 sven Exp $" |
botnet_handler_t | bothandler |
static const char* filter | ( | const char * | text | ) | [static] |
Definition at line 50 of file events.c.
Referenced by on_bcast(), on_botbroadcast(), on_botmsg(), on_chanmsg(), on_extension(), on_lost_bot(), on_part(), on_privmsg(), and on_unlink().
00051 { 00052 char *p; 00053 static char buf[512] = {0}; 00054 00055 if (!strchr(text, '\n')) return text; 00056 00057 strncpy(buf, text, 511); 00058 p = strchr(buf, '\n'); 00059 if (p) *p = 0; 00060 return buf; 00061 }
static int on_bcast | ( | void * | client_data, | |
botnet_entity_t * | src, | |||
const char * | text, | |||
int | len | |||
) | [static] |
Send a broadcast event out.
Send a broadcast (ct) out. eggdrop1.6 expects broadcasts to originate from a bot. If the source is a person, change it to the bot the person is on.
client_data | The oldbotnet_t struct of the bot. | |
src | The source of the broadcast. | |
text | The string to broadcast. | |
len | The string length. |
Definition at line 77 of file events.c.
References partymember::bot, botnet_get_name(), egg_iprintf(), ENTITY_BOT, entity_full_name, filter(), oldbotnet_t::idx, botnet_bot::name, botnet_entity::user, and botnet_entity::what.
00078 { 00079 const char *name; 00080 oldbotnet_t *obot = client_data; 00081 00082 if (src->what == ENTITY_BOT) name = entity_full_name(src); 00083 else if (src->user->bot) name = src->user->bot->name; 00084 else name = botnet_get_name(); 00085 00086 egg_iprintf(obot->idx, "ct %s %s\n", name, filter(text)); 00087 00088 return 0; 00089 }
static int on_botbroadcast | ( | void * | client_data, | |
botnet_bot_t * | src, | |||
const char * | command, | |||
const char * | text, | |||
int | len | |||
) | [static] |
Definition at line 202 of file events.c.
References botnet_get_name(), egg_iprintf(), filter(), oldbotnet_t::idx, and botnet_bot::name.
00203 { 00204 const char *srcname = src ? src->name : botnet_get_name(); 00205 oldbotnet_t *obot = client_data; 00206 00207 if (text && len > 0) egg_iprintf(obot->idx, "z %s %s %s\n", srcname, command, filter(text)); 00208 else egg_iprintf(obot->idx, "z %s %s\n", srcname, command); 00209 00210 return 0; 00211 }
static int on_botmsg | ( | void * | client_data, | |
botnet_bot_t * | src, | |||
botnet_bot_t * | dst, | |||
const char * | command, | |||
const char * | text, | |||
int | len | |||
) | [static] |
Definition at line 213 of file events.c.
References botnet_get_name(), egg_iprintf(), filter(), oldbotnet_t::idx, and botnet_bot::name.
00214 { 00215 const char *srcname = src ? src->name : botnet_get_name(); 00216 oldbotnet_t *obot = client_data; 00217 00218 if (text && len > 0) egg_iprintf(obot->idx, "zb %s %s %s %s\n", srcname, dst->name, command, filter(text)); 00219 else egg_iprintf(obot->idx, "zb %s %s %s\n", srcname, dst->name, command); 00220 00221 return 0; 00222 }
static int on_chanmsg | ( | void * | client_data, | |
partychan_t * | chan, | |||
botnet_entity_t * | src, | |||
const char * | text, | |||
int | len | |||
) | [static] |
Definition at line 118 of file events.c.
References assoc_get_id, b64enc_int(), egg_iprintf(), entity_full_name, filter(), oldbotnet_t::idx, and partychan::name.
00119 { 00120 const char *text = filter(t); 00121 oldbotnet_t *obot = client_data; 00122 00123 if (len >= 9 && !strncasecmp(text, "\1ACTION ", 8) && text[len - 1] == 1) { 00124 egg_iprintf(obot->idx, "a %s %s %.*s\n", entity_full_name(src), b64enc_int(assoc_get_id(chan->name)), len - 9, text + 8); 00125 } else { 00126 egg_iprintf(obot->idx, "c %s %s %s\n", entity_full_name(src), b64enc_int(assoc_get_id(chan->name)), text); 00127 } 00128 return 0; 00129 }
static int on_extension | ( | void * | client_data, | |
botnet_entity_t * | src, | |||
botnet_bot_t * | dst, | |||
const char * | cmd, | |||
const char * | text, | |||
int | len | |||
) | [static] |
Definition at line 224 of file events.c.
References b64enc_int(), partymember::bot, botnet_get_name(), egg_iprintf(), entity_full_id_name, ENTITY_PARTYMEMBER, filter(), partymember::id, oldbotnet_t::idx, botnet_bot::name, partymember::nick, botnet_entity::user, and botnet_entity::what.
00225 { 00226 const char *text = filter(t); 00227 oldbotnet_t *obot = client_data; 00228 00229 if (!strcmp(cmd, "note")) { 00230 egg_iprintf(obot->idx, "p %s %s\n", entity_full_id_name(src), text); 00231 } else if (!strcmp(cmd, "who")) { 00232 egg_iprintf(obot->idx, "w %s %s %s\n", entity_full_id_name(src), dst->name, text); 00233 } else if (!strcmp(cmd, "motd")) { 00234 egg_iprintf(obot->idx, "m %s %s\n", entity_full_id_name(src), dst->name); 00235 } else if (!strcmp(cmd, "versions") && src->what == ENTITY_PARTYMEMBER) { 00236 egg_iprintf(obot->idx, "v %s %s %d:%s\n", src->user->bot->name, dst->name, src->user->id, src->user->nick); 00237 } else if (!strcmp(cmd, "away") && src->what == ENTITY_PARTYMEMBER) { 00238 if (*text) egg_iprintf(obot->idx, "aw %s %s %s\n", src->user->bot ? src->user->bot->name : botnet_get_name(), b64enc_int(src->user->id), text); 00239 else egg_iprintf(obot->idx, "aw %s %s\n", src->user->bot ? src->user->bot->name : botnet_get_name(), b64enc_int(src->user->id)); 00240 } 00241 00242 return 0; 00243 }
static int on_join | ( | void * | client_data, | |
partychan_t * | chan, | |||
partymember_t * | src, | |||
int | linking | |||
) | [static] |
Definition at line 131 of file events.c.
References assoc_get_id, b64enc_int(), partymember::bot, botnet_get_name(), egg_iprintf(), partymember::host, partymember::id, partymember::ident, oldbotnet_t::idx, botnet_bot::name, partychan::name, and partymember::nick.
00132 { 00133 char *cid; 00134 oldbotnet_t *obot = client_data; 00135 00136 cid = strdup(b64enc_int(assoc_get_id(chan->name))); 00137 egg_iprintf(obot->idx, "j %s%s %s %s %c%s %s@%s\n", linking ? "!" : "", src->bot ? src->bot->name : botnet_get_name(), src->nick, cid, '*', b64enc_int(src->id), src->ident, src->host); 00138 free(cid); 00139 00140 return 0; 00141 }
static int on_link | ( | void * | client_data, | |
botnet_entity_t * | from, | |||
botnet_bot_t * | dst, | |||
const char * | target | |||
) | [static] |
Definition at line 184 of file events.c.
References egg_iprintf(), entity_full_id_name, oldbotnet_t::idx, and botnet_bot::name.
00185 { 00186 oldbotnet_t *obot = client_data; 00187 00188 egg_iprintf(obot->idx, "l %s %s %s\n", entity_full_id_name(from), dst->name, target); 00189 00190 return 0; 00191 }
static int on_lost_bot | ( | void * | client_data, | |
botnet_bot_t * | bot, | |||
const char * | reason | |||
) | [static] |
Definition at line 174 of file events.c.
References oldbotnet_t::bot, egg_iprintf(), filter(), oldbotnet_t::idx, and botnet_bot::name.
00175 { 00176 oldbotnet_t *obot = client_data; 00177 00178 if (bot == obot->bot) egg_iprintf(obot->idx, "bye %s\n", filter(reason)); 00179 else egg_iprintf(obot->idx, "un %s %s\n", bot->name, filter(reason)); 00180 00181 return 0; 00182 }
static int on_new_bot | ( | void * | client_data, | |
botnet_bot_t * | bot, | |||
int | linking | |||
) | [static] |
Definition at line 161 of file events.c.
References b64enc_int(), botnet_get_info(), botnet_get_name(), egg_iprintf(), oldbotnet_t::idx, botnet_bot::name, botnet_bot::uplink, and version.
00162 { 00163 int version = 1090000; 00164 const char *verstr; 00165 oldbotnet_t *obot = client_data; 00166 00167 verstr = botnet_get_info(bot, "numversion"); 00168 if (verstr) version = atoi(verstr); 00169 egg_iprintf(obot->idx, "n %s %s %c%s\n", bot->name, bot->uplink ? bot->uplink->name : botnet_get_name(), linking ? '-' : '!', b64enc_int(version)); 00170 00171 return 0; 00172 }
static int on_nick | ( | void * | client_data, | |
partymember_t * | src, | |||
const char * | oldnick | |||
) | [static] |
Definition at line 109 of file events.c.
References b64enc_int(), partymember::bot, botnet_get_name(), egg_iprintf(), partymember::id, oldbotnet_t::idx, botnet_bot::name, and partymember::nick.
00110 { 00111 oldbotnet_t *obot = client_data; 00112 00113 egg_iprintf(obot->idx, "nc %s %s %s\n", src->bot ? src->bot->name : botnet_get_name(), b64enc_int(src->id), src->nick); 00114 00115 return 0; 00116 }
static int on_part | ( | void * | client_data, | |
partychan_t * | chan, | |||
partymember_t * | src, | |||
const char * | reason, | |||
int | len | |||
) | [static] |
Definition at line 143 of file events.c.
References assoc_get_id, b64enc_int(), partymember::bot, botnet_get_name(), partymember::channels, egg_iprintf(), filter(), partymember::host, partymember::id, partymember::ident, oldbotnet_t::idx, partychan::name, botnet_bot::name, partymember::nchannels, and partymember::nick.
00144 { 00145 oldbotnet_t *obot = client_data; 00146 00147 if (!src->nchannels) { 00148 if (reason && *reason) egg_iprintf(obot->idx, "pt %s %s %s %s\n", src->bot ? src->bot->name : botnet_get_name(), src->nick, b64enc_int(src->id), filter(reason)); 00149 else egg_iprintf(obot->idx, "pt %s %s %s\n", src->bot ? src->bot->name : botnet_get_name(), src->nick, b64enc_int(src->id)); 00150 } else { 00151 char *cid; 00152 00153 cid = strdup(b64enc_int(assoc_get_id(src->channels[src->nchannels - 1]->name))); 00154 egg_iprintf(obot->idx, "j %s %s %s %c%s %s@%s\n", src->bot ? src->bot->name : botnet_get_name(), src->nick, cid, '*', b64enc_int(src->id), src->ident, src->host); 00155 free(cid); 00156 } 00157 00158 return 0; 00159 }
static int on_privmsg | ( | void * | client_data, | |
botnet_entity_t * | src, | |||
partymember_t * | dst, | |||
const char * | text, | |||
int | len | |||
) | [static] |
Definition at line 91 of file events.c.
References egg_iprintf(), entity_full_id_name, filter(), partymember::full_id_name, and oldbotnet_t::idx.
00092 { 00093 oldbotnet_t *obot = client_data; 00094 00095 egg_iprintf(obot->idx, "p %s %s %s\n", entity_full_id_name(src), dst->full_id_name, filter(text)); 00096 00097 return 0; 00098 }
static int on_quit | ( | void * | client_data, | |
partymember_t * | src, | |||
const char * | text, | |||
int | len | |||
) | [static] |
Definition at line 100 of file events.c.
References b64enc_int(), partymember::bot, botnet_get_name(), egg_iprintf(), partymember::id, oldbotnet_t::idx, botnet_bot::name, and partymember::nick.
00101 { 00102 oldbotnet_t *obot = client_data; 00103 00104 egg_iprintf(obot->idx, "pt %s %s %s\n", src->bot ? src->bot->name : botnet_get_name(), src->nick, b64enc_int(src->id)); 00105 00106 return 0; 00107 }
static int on_unlink | ( | void * | client_data, | |
botnet_entity_t * | from, | |||
botnet_bot_t * | bot, | |||
const char * | reason | |||
) | [static] |
Definition at line 193 of file events.c.
References egg_iprintf(), entity_full_id_name, filter(), oldbotnet_t::idx, botnet_bot::name, and botnet_bot::uplink.
00194 { 00195 oldbotnet_t *obot = client_data; 00196 00197 egg_iprintf(obot->idx, "ul %s %s %s %s\n", entity_full_id_name(from), bot->uplink->name, bot->name, filter(reason)); 00198 00199 return 0; 00200 }
Initial value:
const char rcsid[] = "$Id: events.c,v 1.14 2007-11-06 00:05:40 sven Exp $" [static] |