#include <eggdrop/eggdrop.h>
Go to the source code of this file.
Functions | |
static int | on_putlog (int flags, const char *chan, const char *text, int len) |
int | partychan_init (void) |
int | partychan_shutdown (void) |
int | partymember_init (void) |
int | partymember_shutdown (void) |
int | partyline_init (void) |
int | partyline_shutdown (void) |
int | partyline_is_command (const char *text) |
int | partyline_on_input (partychan_t *chan, partymember_t *p, const char *text, int len) |
int | partyline_on_command (partymember_t *p, const char *cmd, const char *text) |
int | partyline_update_info (partymember_t *p, const char *ident, const char *host) |
int | partyline_idx_privmsg (int idx, partymember_t *dest, botnet_entity_t *src, const char *text, int len) |
int | partyline_idx_nick (int idx, partymember_t *src, const char *oldnick, const char *newnick) |
int | partyline_idx_quit (int idx, partymember_t *src, const char *text, int len) |
int | partyline_idx_chanmsg (int idx, partychan_t *chan, botnet_entity_t *src, const char *text, int len) |
int | partyline_idx_join (int idx, partychan_t *chan, partymember_t *src) |
int | partyline_idx_part (int idx, partychan_t *chan, partymember_t *src, const char *text, int len) |
Variables | |
static const char | rcsid [] = "$Id: partyline.c,v 1.30 2007-11-06 00:05:40 sven Exp $" |
static char * | partyline_command_chars = NULL |
static bind_table_t * | BT_cmd = NULL |
static bind_table_t * | BT_party_out = NULL |
static bind_list_t | log_binds [] |
static int on_putlog | ( | int | flags, | |
const char * | chan, | |||
const char * | text, | |||
int | len | |||
) | [static] |
Definition at line 222 of file partyline.c.
References bot_entity, localchan_msg(), NULL, and partychan_lookup_name().
00223 { 00224 partychan_t *chanptr; 00225 botnet_entity_t me = bot_entity(NULL); 00226 00227 chanptr = partychan_lookup_name(chan); 00228 if (!chanptr) 00229 return(0); 00230 00231 localchan_msg(chanptr, &me, text, len); 00232 return(0); 00233 }
int partychan_init | ( | void | ) |
Definition at line 39 of file partychan.c.
References BIND_STACKABLE, bind_table_add(), BT_partypart, BT_partypub, BTN_PARTYLINE_JOIN, BTN_PARTYLINE_PART, BTN_PARTYLINE_PUBLIC, hash_table_create(), HASH_TABLE_INTS, MATCH_NONE, and NULL.
Referenced by partyline_init().
00040 { 00041 cid_ht = hash_table_create(NULL, NULL, 13, HASH_TABLE_INTS); 00042 00043 /* The first 3 args for each bind are: 00044 * channel name, channel id, partier */ 00045 BT_partyjoin = bind_table_add(BTN_PARTYLINE_JOIN, 3, "siP", MATCH_NONE, BIND_STACKABLE); /* DDD */ 00046 BT_partypart = bind_table_add(BTN_PARTYLINE_PART, 5, "siPsi", MATCH_NONE, BIND_STACKABLE); /* DDD */ 00047 BT_partypub = bind_table_add(BTN_PARTYLINE_PUBLIC, 5, "siEsi", MATCH_NONE, BIND_STACKABLE); /* DDD */ 00048 return(0); 00049 }
int partychan_shutdown | ( | void | ) |
Definition at line 51 of file partychan.c.
References bind_table_del(), BT_partypart, BT_partypub, garbage_run(), hash_table_delete(), partymember_common::members, partymember_common::next, partychan::next, NULL, and partychan_delete().
Referenced by partyline_shutdown().
00052 { 00053 partychan_t *chan, *next; 00054 partymember_common_t *common, *next_common; 00055 00056 if (partychan_head != NULL) { 00057 for (chan = partychan_head; chan; ) { 00058 next = chan->next; 00059 partychan_delete(chan); 00060 chan = next; 00061 } 00062 partychan_head = NULL; 00063 } 00064 00065 if (common_list_head) { 00066 for (common = common_list_head; common; ) { 00067 next_common = common->next; 00068 00069 free(common->members); 00070 free(common); 00071 00072 common = next_common; 00073 } 00074 common_list_head = NULL; 00075 } 00076 00077 bind_table_del(BT_partypub); 00078 bind_table_del(BT_partypart); 00079 bind_table_del(BT_partyjoin); 00080 00081 /* flush any pending partychan deletes */ 00082 garbage_run(); 00083 00084 hash_table_delete(cid_ht); 00085 00086 return (0); 00087 }
int partyline_idx_chanmsg | ( | int | idx, | |
partychan_t * | chan, | |||
botnet_entity_t * | src, | |||
const char * | text, | |||
int | len | |||
) |
Definition at line 266 of file partyline.c.
References egg_iprintf(), entity_common_name, partychan::name, and timer_get_timestamp().
Referenced by on_chanmsg().
00267 { 00268 char *ts; 00269 00270 ts = timer_get_timestamp(); 00271 00272 if (src) { 00273 if (len >= 9 && !strncasecmp(text, "\1ACTION ", 8) && text[len - 1] == 1) { 00274 egg_iprintf(idx, "%s %s* %s %.*s\r\n", chan->name, ts, entity_common_name(src), len - 9, text + 8); 00275 } else { 00276 egg_iprintf(idx, "%s %s<%s> %s\r\n", chan->name, ts, entity_common_name(src), text); 00277 } 00278 } else { 00279 egg_iprintf(idx, "%s %s%s\r\n", chan->name, ts, text); 00280 } 00281 return 0; 00282 }
int partyline_idx_join | ( | int | idx, | |
partychan_t * | chan, | |||
partymember_t * | src | |||
) |
Definition at line 284 of file partyline.c.
References partymember::common_name, egg_iprintf(), partymember::host, partymember::ident, partychan::name, and timer_get_timestamp().
Referenced by on_join().
00285 { 00286 egg_iprintf(idx, "%s %s*** %s (%s@%s) has joined the channel.\r\n", chan->name, timer_get_timestamp(), src->common_name, src->ident, src->host); 00287 return 0; 00288 }
int partyline_idx_nick | ( | int | idx, | |
partymember_t * | src, | |||
const char * | oldnick, | |||
const char * | newnick | |||
) |
Definition at line 253 of file partyline.c.
References partymember::bot, egg_iprintf(), botnet_bot::name, and timer_get_timestamp().
Referenced by on_nick().
00254 { 00255 if (src->bot) egg_iprintf(idx, "* %s*** %s@%s is now known as %s@%s.\n", timer_get_timestamp(), oldnick, src->bot->name, newnick, src->bot->name); 00256 else egg_iprintf(idx, "* %s*** %s is now known as %s.\n", timer_get_timestamp(), oldnick, newnick); 00257 return 0; 00258 }
int partyline_idx_part | ( | int | idx, | |
partychan_t * | chan, | |||
partymember_t * | src, | |||
const char * | text, | |||
int | len | |||
) |
Definition at line 290 of file partyline.c.
References partymember::common_name, egg_iprintf(), partymember::host, partymember::ident, partychan::name, and timer_get_timestamp().
Referenced by on_part().
00291 { 00292 egg_iprintf(idx, "%s %s*** %s (%s@%s) has left %s: %s\r\n", chan->name, timer_get_timestamp(), src->common_name, src->ident, src->host, chan->name, text); 00293 return 0; 00294 }
int partyline_idx_privmsg | ( | int | idx, | |
partymember_t * | dest, | |||
botnet_entity_t * | src, | |||
const char * | text, | |||
int | len | |||
) |
Definition at line 235 of file partyline.c.
References egg_iprintf(), entity_common_name, and timer_get_timestamp().
Referenced by on_privmsg().
00236 { 00237 char *ts; 00238 00239 ts = timer_get_timestamp(); 00240 00241 if (src) { 00242 if (len >= 9 && !strncasecmp(text, "\1ACTION ", 8) && text[len - 1] == 1) { 00243 egg_iprintf(idx, "%s* %s %.*s\r\n", ts, entity_common_name(src), len - 9, text + 8); 00244 } else { 00245 egg_iprintf(idx, "%s[%s] %s\r\n", ts, entity_common_name(src), text); 00246 } 00247 } else { 00248 egg_iprintf(idx, "%s\r\n", text); 00249 } 00250 return 0; 00251 }
int partyline_idx_quit | ( | int | idx, | |
partymember_t * | src, | |||
const char * | text, | |||
int | len | |||
) |
Definition at line 260 of file partyline.c.
References partymember::common_name, egg_iprintf(), partymember::host, partymember::ident, and timer_get_timestamp().
Referenced by on_quit().
00261 { 00262 egg_iprintf(idx, "* %s*** %s (%s@%s) has quit: %s\n", timer_get_timestamp(), src->common_name, src->ident, src->host, text); 00263 return 0; 00264 }
int partyline_init | ( | void | ) |
Definition at line 44 of file partyline.c.
References bind_add_list(), bind_table_add(), BTN_LOG, BTN_PARTYLINE_CMD, BTN_PARTYLINE_OUT, MATCH_FLAGS, MATCH_NONE, MATCH_PARTIAL, partychan_init(), partyline_command_chars, partymember_init(), and str_redup().
Referenced by eggdrop_init().
00045 { 00046 partychan_init(); 00047 partymember_init(); 00048 str_redup(&partyline_command_chars, "./"); 00049 BT_cmd = bind_table_add(BTN_PARTYLINE_CMD, 5, "PsUss", MATCH_PARTIAL | MATCH_FLAGS, 0); /* DDD */ 00050 BT_party_out = bind_table_add(BTN_PARTYLINE_OUT, 5, "isUsi", MATCH_NONE, 0); /* DDD */ 00051 bind_add_list(BTN_LOG, log_binds); 00052 return(0); 00053 }
int partyline_is_command | ( | const char * | text | ) |
Definition at line 72 of file partyline.c.
References partyline_command_chars.
00073 { 00074 return strchr(partyline_command_chars, *text) ? 1 : 0; 00075 }
int partyline_on_command | ( | partymember_t * | p, | |
const char * | cmd, | |||
const char * | text | |||
) |
Definition at line 120 of file partyline.c.
References _, bind_check_hits(), BIND_RET_BREAK, BIND_RET_LOG, BIND_RET_LOG_COMMAND, user_setting_t::flags, LOG_MISC, partymember::nick, partymember_printf(), putlog(), user::settings, and partymember::user.
Referenced by partyline_on_input().
00121 { 00122 int r, hits; 00123 00124 if (!p) return(-1); 00125 00126 r = bind_check_hits(BT_cmd, &p->user->settings[0].flags, cmd, &hits, p, p->nick, p->user, cmd, text); 00127 00128 /* if we have no hits then there's no such command */ 00129 if (hits == 0) 00130 partymember_printf (p, _("Unknown command '%s', perhaps you need '.help'?"), 00131 cmd); 00132 else { 00133 switch (r) { 00134 /* logs everything */ 00135 case (BIND_RET_LOG): 00136 putlog(LOG_MISC, "*", "#%s# %s %s", p->nick, cmd, (text) ? text : ""); 00137 break; 00138 /* usefull if e.g. a .chpass is issued */ 00139 case (BIND_RET_LOG_COMMAND): 00140 putlog(LOG_MISC, "*", "#%s# %s ...", p->nick, cmd); 00141 break; 00142 /* command doesn't want any lo entry at all */ 00143 case (BIND_RET_BREAK): 00144 break; 00145 } 00146 00147 } 00148 00149 return(r); 00150 }
int partyline_on_input | ( | partychan_t * | chan, | |
partymember_t * | p, | |||
const char * | text, | |||
int | len | |||
) |
Definition at line 80 of file partyline.c.
References cmd, partymember::flags, NULL, PARTY_DELETED, partychan_get_default(), partychan_msg(), partyline_command_chars, partyline_on_command(), and user_entity.
Referenced by dcc_on_read(), got_privmsg(), on_read(), and telnet_on_read().
00081 { 00082 if (!p || p->flags & PARTY_DELETED || !len) return(0); 00083 if (!chan) chan = partychan_get_default(p); 00084 00085 /* See if we should interpret it as a command. */ 00086 if (strchr(partyline_command_chars, *text)) { 00087 text++; 00088 len--; 00089 /* If there are 2 command chars in a row, then it's not a 00090 * command. We skip the command char and treat it as text. */ 00091 if (*text != *(text-1)) { 00092 const char *space; 00093 00094 space = strchr(text, ' '); 00095 if (space) { 00096 char *cmd; 00097 00098 len = space-text; 00099 cmd = malloc(len+1); 00100 memcpy(cmd, text, len); 00101 cmd[len] = 0; 00102 while (isspace(*space)) space++; 00103 partyline_on_command(p, cmd, space); 00104 free(cmd); 00105 } 00106 else { 00107 partyline_on_command(p, text, NULL); 00108 } 00109 return(0); 00110 } 00111 } 00112 /* It's not a command, so it's public text. */ 00113 botnet_entity_t src = user_entity(p); 00114 partychan_msg(chan, &src, text, len); 00115 return(0); 00116 }
int partyline_shutdown | ( | void | ) |
Definition at line 55 of file partyline.c.
References bind_rem_list(), bind_table_del(), BTN_LOG, NULL, partychan_shutdown(), partyline_command_chars, and partymember_shutdown().
Referenced by eggdrop_shutdown().
00056 { 00057 bind_rem_list(BTN_LOG, log_binds); 00058 bind_table_del(BT_party_out); 00059 bind_table_del(BT_cmd); 00060 00061 if (partyline_command_chars) 00062 free(partyline_command_chars); 00063 partyline_command_chars = NULL; 00064 00065 partymember_shutdown(); 00066 partychan_shutdown(); 00067 00068 return (0); 00069 }
int partyline_update_info | ( | partymember_t * | p, | |
const char * | ident, | |||
const char * | host | |||
) |
Definition at line 152 of file partyline.c.
References partymember::host, partymember::ident, and str_redup().
Referenced by process_results().
00153 { 00154 if (!p) return(-1); 00155 if (ident) str_redup(&p->ident, ident); 00156 if (host) str_redup(&p->host, host); 00157 return(0); 00158 }
int partymember_init | ( | void | ) |
Definition at line 40 of file partymember.c.
References bind_add_list(), BIND_STACKABLE, bind_table_add(), BT_new, BT_quit, BTN_PARTYLINE_NEW, BTN_PARTYLINE_NICK, BTN_PARTYLINE_QUIT, BTN_USER_DELETE, MATCH_MASK, and MATCH_NONE.
Referenced by partyline_init().
00041 { 00042 bind_add_list(BTN_USER_DELETE, partymember_udelete_binds); 00043 BT_nick = bind_table_add(BTN_PARTYLINE_NICK, 3, "Pss", MATCH_NONE, BIND_STACKABLE); 00044 BT_new = bind_table_add(BTN_PARTYLINE_NEW, 1, "P", MATCH_MASK, BIND_STACKABLE); 00045 BT_quit = bind_table_add(BTN_PARTYLINE_QUIT, 2, "Ps", MATCH_MASK, BIND_STACKABLE); 00046 return(0); 00047 }
int partymember_shutdown | ( | void | ) |
Definition at line 49 of file partymember.c.
References _, bind_rem_list(), bind_table_del(), BT_new, BT_quit, BTN_USER_DELETE, garbage_run(), NULL, and partymember_delete().
Referenced by partyline_shutdown().
00050 { 00051 while (party_head) partymember_delete(party_head, NULL, _("Bot shutdown")); 00052 bind_rem_list(BTN_USER_DELETE, partymember_udelete_binds); 00053 bind_table_del(BT_nick); 00054 bind_table_del(BT_new); 00055 bind_table_del(BT_quit); 00056 00057 /* force a garbage run since we might have some partymembers 00058 * marked as deleted and w/o a garbage_run we may not destroy 00059 * our hashtable */ 00060 garbage_run(); 00061 00062 return (0); 00063 }
bind_table_t* BT_cmd = NULL [static] |
Definition at line 28 of file partyline.c.
bind_table_t* BT_party_out = NULL [static] |
Definition at line 29 of file partyline.c.
bind_list_t log_binds[] [static] |
char* partyline_command_chars = NULL [static] |
Definition at line 26 of file partyline.c.
Referenced by partyline_init(), partyline_is_command(), partyline_on_input(), and partyline_shutdown().
const char rcsid[] = "$Id: partyline.c,v 1.30 2007-11-06 00:05:40 sven Exp $" [static] |
Definition at line 21 of file partyline.c.