#include <eggdrop/eggdrop.h>
#include "botnet.h"
Go to the source code of this file.
Functions | |
static int | on_login (void *client_data, partymember_t *src) |
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) |
Variables | |
static const char | rcsid [] = "$Id: events.c,v 1.4 2007-10-27 19:55:51 sven Exp $" |
botnet_handler_t | bothandler |
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 75 of file events.c.
References egg_iprintf(), entity_net_name, and bot_t::idx.
00076 { 00077 bot_t *b = client_data; 00078 00079 egg_iprintf(b->idx, ":%s broadcast :%s", entity_net_name(src), text ? text : ""); 00080 00081 return 0; 00082 }
static int on_botbroadcast | ( | void * | client_data, | |
botnet_bot_t * | src, | |||
const char * | command, | |||
const char * | text, | |||
int | len | |||
) | [static] |
Definition at line 183 of file events.c.
References bot_t::idx, botnet_bot::name, and sockbuf_write().
00184 { 00185 int printlen, totallen; 00186 char sbuf[512], *obuf; 00187 bot_t *b = client_data; 00188 00189 if (src) totallen = 1 + strlen(src->name) + 12 + strlen(command) + 2 + len; 00190 else totallen = 11 + strlen(command) + 2 + len; 00191 if (totallen < 512) obuf = sbuf; 00192 else obuf = malloc(totallen + 1); 00193 00194 if (src) printlen = sprintf(obuf, ":%s bbroadcast %s :", src->name, command); 00195 else printlen = sprintf(obuf, "bbroadcast %s :", command); 00196 memcpy(obuf + printlen, text, len); 00197 sockbuf_write(b->idx, obuf, totallen); 00198 if (obuf != sbuf) free(obuf); 00199 00200 return 0; 00201 }
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 203 of file events.c.
References bot_t::idx, botnet_bot::name, and sockbuf_write().
00204 { 00205 int printlen, totallen; 00206 char sbuf[512], *obuf; 00207 bot_t *b = client_data; 00208 00209 if (src) totallen = 1 + strlen(src->name) + 8 + strlen(dst->name) + 1 + strlen(command) + 2 + len; 00210 else totallen = 7 + strlen(dst->name) + 1 + strlen(command) + 2 + len; 00211 if (totallen < 512) obuf = sbuf; 00212 else obuf = malloc(totallen + 1); 00213 00214 if (src) printlen = sprintf(obuf, ":%s botmsg %s %s :", src->name, dst->name, command); 00215 else printlen = sprintf(obuf, "botmsg %s %s :", dst->name, command); 00216 memcpy(obuf + printlen, text, len); 00217 sockbuf_write(b->idx, obuf, totallen); 00218 if (obuf != sbuf) free(obuf); 00219 00220 return 0; 00221 }
static int on_chanmsg | ( | void * | client_data, | |
partychan_t * | chan, | |||
botnet_entity_t * | src, | |||
const char * | text, | |||
int | len | |||
) | [static] |
Definition at line 111 of file events.c.
References egg_iprintf(), entity_net_name, bot_t::idx, and partychan::name.
00112 { 00113 bot_t *b = client_data; 00114 00115 egg_iprintf(b->idx, ":%s chanmsg %s :%s", entity_net_name(src), chan->name, text ? text : ""); 00116 00117 return 0; 00118 }
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 223 of file events.c.
References entity_net_name, bot_t::idx, botnet_bot::name, and sockbuf_write().
00224 { 00225 char sbuf[512], *obuf; 00226 int printlen, totallen = 1 + strlen(entity_net_name(src)) + 11 + strlen(dst->name) + 1 + strlen(cmd) + 2 + len; 00227 bot_t *b = client_data; 00228 00229 if (totallen < 512) obuf = sbuf; 00230 else obuf = malloc(totallen + 1); 00231 00232 printlen = sprintf(obuf, ":%s extension %s %s :", entity_net_name(src), dst->name, cmd); 00233 memcpy(obuf + printlen, text, len); 00234 sockbuf_write(b->idx, obuf, totallen); 00235 if (obuf != sbuf) free(obuf); 00236 00237 return 0; 00238 }
static int on_join | ( | void * | client_data, | |
partychan_t * | chan, | |||
partymember_t * | src, | |||
int | linking | |||
) | [static] |
Definition at line 120 of file events.c.
References egg_iprintf(), bot_t::idx, partychan::name, and partymember::net_name.
00121 { 00122 bot_t *b = client_data; 00123 00124 egg_iprintf(b->idx, ":%s join %s%s", src->net_name, chan->name, linking ? " B" : ""); 00125 00126 return 0; 00127 }
static int on_link | ( | void * | client_data, | |
botnet_entity_t * | from, | |||
botnet_bot_t * | dst, | |||
const char * | target | |||
) | [static] |
Definition at line 165 of file events.c.
References egg_iprintf(), entity_net_name, bot_t::idx, and botnet_bot::name.
00166 { 00167 bot_t *b = client_data; 00168 00169 egg_iprintf(b->idx, ":%s link %s %s", entity_net_name(from), dst->name, target); 00170 00171 return 0; 00172 }
static int on_login | ( | void * | client_data, | |
partymember_t * | src | |||
) | [static] |
Definition at line 51 of file events.c.
References b64enc_int(), partymember::bot, egg_iprintf(), partymember::host, partymember::id, partymember::ident, bot_t::idx, botnet_bot::name, and partymember::nick.
00052 { 00053 bot_t *b = client_data; 00054 00055 if (src->bot) egg_iprintf(b->idx, ":%s login %s %s %s %s", src->bot->name, src->nick, src->ident, src->host, b64enc_int(src->id)); 00056 else egg_iprintf(b->idx, "login %s %s %s %s", src->nick, src->ident, src->host, b64enc_int(src->id)); 00057 00058 return 0; 00059 }
static int on_lost_bot | ( | void * | client_data, | |
botnet_bot_t * | bot, | |||
const char * | reason | |||
) | [static] |
Definition at line 156 of file events.c.
References egg_iprintf(), bot_t::idx, and botnet_bot::name.
00157 { 00158 bot_t *b = client_data; 00159 00160 egg_iprintf(b->idx, ":%s bquit :%s", bot->name, reason ? reason : "No reason"); 00161 00162 return 0; 00163 }
static int on_new_bot | ( | void * | client_data, | |
botnet_bot_t * | bot, | |||
int | linking | |||
) | [static] |
Definition at line 138 of file events.c.
References b64enc_int(), botnet_get_info(), egg_iprintf(), bot_t::idx, botnet_bot::name, botnet_bot::uplink, and version.
00139 { 00140 int version = 1090000; 00141 const char *ver, *type, *fullversion; 00142 bot_t *b = client_data; 00143 00144 type = botnet_get_info(bot, "type"); 00145 ver = botnet_get_info(bot, "numversion"); 00146 fullversion = botnet_get_info(bot, "numversion"); 00147 if (!type) type = "unknown"; 00148 if (ver) version = atoi(ver); 00149 if (!fullversion) fullversion = "unknown"; 00150 if (bot->uplink) egg_iprintf(b->idx, ":%s newbot %s %s %s %s %s", bot->uplink->name, bot->name, type, b64enc_int(version), fullversion, linking ? "B" : "A"); 00151 else egg_iprintf(b->idx, "newbot %s %s %s %s%s", bot->name, type, b64enc_int(version), fullversion, linking ? " B" : ""); 00152 00153 return 0; 00154 }
static int on_nick | ( | void * | client_data, | |
partymember_t * | src, | |||
const char * | oldnick | |||
) | [static] |
Definition at line 102 of file events.c.
References egg_iprintf(), bot_t::idx, partymember::net_name, and partymember::nick.
00103 { 00104 bot_t *b = client_data; 00105 00106 egg_iprintf(b->idx, ":%s nick %s", src->net_name, src->nick); 00107 00108 return 0; 00109 }
static int on_part | ( | void * | client_data, | |
partychan_t * | chan, | |||
partymember_t * | src, | |||
const char * | reason, | |||
int | len | |||
) | [static] |
Definition at line 129 of file events.c.
References egg_iprintf(), bot_t::idx, partychan::name, and partymember::net_name.
00130 { 00131 bot_t *b = client_data; 00132 00133 egg_iprintf(b->idx, ":%s part %s :%s", src->net_name, chan->name, reason ? reason : ""); 00134 00135 return 0; 00136 }
static int on_privmsg | ( | void * | client_data, | |
botnet_entity_t * | src, | |||
partymember_t * | dst, | |||
const char * | text, | |||
int | len | |||
) | [static] |
Definition at line 84 of file events.c.
References egg_iprintf(), entity_net_name, bot_t::idx, and partymember::net_name.
00085 { 00086 bot_t *b = client_data; 00087 00088 egg_iprintf(b->idx, ":%s privmsg %s :%s", entity_net_name(src), dst->net_name, text); 00089 00090 return 0; 00091 }
static int on_quit | ( | void * | client_data, | |
partymember_t * | src, | |||
const char * | text, | |||
int | len | |||
) | [static] |
Definition at line 93 of file events.c.
References egg_iprintf(), bot_t::idx, and partymember::net_name.
00094 { 00095 bot_t *b = client_data; 00096 00097 egg_iprintf(b->idx, ":%s quit :%s", src->net_name, text ? text : ""); 00098 00099 return 0; 00100 }
static int on_unlink | ( | void * | client_data, | |
botnet_entity_t * | from, | |||
botnet_bot_t * | bot, | |||
const char * | reason | |||
) | [static] |
Definition at line 174 of file events.c.
References egg_iprintf(), entity_net_name, bot_t::idx, and botnet_bot::name.
00175 { 00176 bot_t *b = client_data; 00177 00178 egg_iprintf(b->idx, ":%s unlink %s :%s", entity_net_name(from), bot->name, reason); 00179 00180 return 0; 00181 }
Initial value:
const char rcsid[] = "$Id: events.c,v 1.4 2007-10-27 19:55:51 sven Exp $" [static] |