lib/eggdrop/partyline.h File Reference

Go to the source code of this file.

Data Structures

struct  partyline_event

Defines

#define PARTY_DELETED   1
#define PARTY_SELECTED   2
#define BTN_PARTYLINE_NEW   "partynew"
#define BTN_PARTYLINE_QUIT   "partyquit"
#define BTN_PARTYLINE_JOIN   "partyjoin"
#define BTN_PARTYLINE_NICK   "partynick"
#define BTN_PARTYLINE_PART   "partypart"
#define BTN_PARTYLINE_PUBLIC   "partypub"
#define BTN_PARTYLINE_CMD   "party"
#define BTN_PARTYLINE_OUT   "party_out"

Typedefs

typedef struct botnet_bot botnet_bot_t
typedef struct botnet_entity botnet_entity_t
typedef struct partymember partymember_t
typedef struct partychan partychan_t
typedef struct partychan_member partychan_member_t
typedef struct partymember_common partymember_common_t
typedef struct partyline_event partyline_event_t

Functions

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)
int partyline_init (void)
int partyline_shutdown (void)
int partyline_delete (partymember_t *p, const char *text)
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)


Define Documentation

#define BTN_PARTYLINE_CMD   "party"

Definition at line 36 of file partyline.h.

Referenced by partyline_init().

#define BTN_PARTYLINE_JOIN   "partyjoin"

Definition at line 32 of file partyline.h.

Referenced by partychan_init().

#define BTN_PARTYLINE_NEW   "partynew"

Definition at line 30 of file partyline.h.

Referenced by partymember_init().

#define BTN_PARTYLINE_NICK   "partynick"

Definition at line 33 of file partyline.h.

Referenced by partymember_init().

#define BTN_PARTYLINE_OUT   "party_out"

Definition at line 37 of file partyline.h.

Referenced by partyline_init().

#define BTN_PARTYLINE_PART   "partypart"

Definition at line 34 of file partyline.h.

Referenced by partychan_init().

#define BTN_PARTYLINE_PUBLIC   "partypub"

Definition at line 35 of file partyline.h.

Referenced by partychan_init().

#define BTN_PARTYLINE_QUIT   "partyquit"

Definition at line 31 of file partyline.h.

Referenced by partymember_init().

#define PARTY_DELETED   1

#define PARTY_SELECTED   2

Definition at line 27 of file partyline.h.

Referenced by partychan_get_common(), and partymember_set_nick().


Typedef Documentation

typedef struct botnet_bot botnet_bot_t

Definition at line 39 of file partyline.h.

Definition at line 40 of file partyline.h.

Definition at line 43 of file partyline.h.

typedef struct partychan partychan_t

Definition at line 42 of file partyline.h.

Definition at line 45 of file partyline.h.

Definition at line 44 of file partyline.h.

typedef struct partymember partymember_t

Definition at line 41 of file partyline.h.


Function Documentation

int partyline_delete ( partymember_t p,
const char *  text 
)

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   ) 

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 }


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