bip_use_notice option + fix

add bip_use_notice option to user-level configuration.
fix typo in bip_notify()
This commit is contained in:
Loc Gomez 2007-09-28 13:20:32 +02:00
parent 72b028221d
commit d3a5c40a40
9 changed files with 28 additions and 6 deletions

View File

@ -187,6 +187,12 @@ The server port to connect to.
This section allows you to define the users allowed to connect to BIP and their
options. It may appear more than once in the configuration file.
.TP
\fBbip_use_notice\fP (default: \fBfalse\fP)
If \fBbip_use_notice\fP is true, bip's notifications to the clients will be
send as notices instead of private messages. For example, this setting applies
to disconnection notifications or /BIP command replies.
.TP
\fBdefault_nick\fP
The default nick option for each \fBconnection section\fP where no \fBnick\fP

View File

@ -85,6 +85,11 @@ user {
# He'll be able to RELOAD bip and see all users' configuration (except pass)
admin = true;
# When bip_use_notice is true, bip will send internal messages like
# disconnection notifications or /BIP commands replies as notices
# instead of private messages. The default is false.
#bip_use_notice = true;
# SSL certificates checking mode for user:
# - "none" to accept anything;
# - "basic" to accept if the certificate is contained in the store;

View File

@ -77,7 +77,7 @@ syn keyword bipUKeyword contained nextgroup=bipNumericV backlog_lines
syn keyword bipUKeyword contained nextgroup=bipBoolV admin
\ no_backlog always_backlog bl_msg_only blreset_on_talk
\ backlog_no_timestamp backlog log_system backlog_reset_on_talk
\ backlog_msg_only backlog_always
\ backlog_msg_only backlog_always bip_use_notice
" Connection block (level 2)
syn region bipConnection contained matchgroup=Macro

View File

@ -517,6 +517,7 @@ static int add_user(bip_t *bip, list_t *data)
u->backlog_lines = DEFAULT_BACKLOG_LINES;
u->backlog_no_timestamp = DEFAULT_BACKLOG_NO_TIMESTAMP;
u->blreset_on_talk = DEFAULT_BLRESET_ON_TALK;
u->bip_use_notice = DEFAULT_BIP_USE_NOTICE;
} else {
FREE(u->name);
FREE(u->password);
@ -567,7 +568,9 @@ static int add_user(bip_t *bip, list_t *data)
case LEX_BLRESET_ON_TALK:
u->blreset_on_talk = t->ndata;
break;
case LEX_BIP_USE_NOTICE:
u->bip_use_notice = t->ndata;
break;
case LEX_CONNECTION:
r = add_connection(bip, u, t->pdata);
free(t->pdata);
@ -1418,9 +1421,10 @@ void _bip_notify(struct link_client *ic, char *fmt, va_list ap)
else
nick = LINK(ic)->prev_nick;
snprintf(str, 4095, fmt, ap);
vsnprintf(str, 4095, fmt, ap);
str[4095] = 0;
WRITE_LINE2(CONN(ic), P_IRCMASK, "PRIVMSG", nick, str);
WRITE_LINE2(CONN(ic), P_IRCMASK, (LINK(ic)->user->bip_use_notice ?
"NOTICE" : "PRIVMSG"), nick, str);
}
void bip_notify(struct link_client *ic, char *fmt, ...)

View File

@ -80,7 +80,7 @@ struct tuple *tuple_l_new(int type, void *p)
%}
%token LEX_IP LEX_EQ LEX_PORT LEX_CSS LEX_SEMICOLON LEX_CONNECTION LEX_NETWORK LEX_LBRA LEX_RBRA LEX_USER LEX_NAME LEX_NICK LEX_SERVER LEX_PASSWORD LEX_SRCIP LEX_HOST LEX_VHOST LEX_SOURCE_PORT LEX_NONE LEX_COMMENT LEX_BUNCH LEX_REALNAME LEX_SSL LEX_SSL_CHECK_MODE LEX_SSL_CHECK_STORE LEX_CHANNEL LEX_KEY LEX_LOG_ROOT LEX_LOG_FORMAT LEX_LOG_LEVEL LEX_BACKLOG_LINES LEX_BACKLOG_NO_TIMESTAMP LEX_BACKLOG LEX_LOG LEX_LOG_SYSTEM LEX_LOG_SYNC_INTERVAL LEX_FOLLOW_NICK LEX_ON_CONNECT_SEND LEX_AWAY_NICK LEX_PID_FILE LEX_IGN_FIRST_NICK LEX_ALWAYS_BACKLOG LEX_BLRESET_ON_TALK LEX_DEFAULT_USER LEX_DEFAULT_NICK LEX_DEFAULT_REALNAME LEX_NO_CLIENT_AWAY_MSG LEX_BL_MSG_ONLY LEX_ADMIN
%token LEX_IP LEX_EQ LEX_PORT LEX_CSS LEX_SEMICOLON LEX_CONNECTION LEX_NETWORK LEX_LBRA LEX_RBRA LEX_USER LEX_NAME LEX_NICK LEX_SERVER LEX_PASSWORD LEX_SRCIP LEX_HOST LEX_VHOST LEX_SOURCE_PORT LEX_NONE LEX_COMMENT LEX_BUNCH LEX_REALNAME LEX_SSL LEX_SSL_CHECK_MODE LEX_SSL_CHECK_STORE LEX_CHANNEL LEX_KEY LEX_LOG_ROOT LEX_LOG_FORMAT LEX_LOG_LEVEL LEX_BACKLOG_LINES LEX_BACKLOG_NO_TIMESTAMP LEX_BACKLOG LEX_LOG LEX_LOG_SYSTEM LEX_LOG_SYNC_INTERVAL LEX_FOLLOW_NICK LEX_ON_CONNECT_SEND LEX_AWAY_NICK LEX_PID_FILE LEX_IGN_FIRST_NICK LEX_ALWAYS_BACKLOG LEX_BLRESET_ON_TALK LEX_DEFAULT_USER LEX_DEFAULT_NICK LEX_DEFAULT_REALNAME LEX_NO_CLIENT_AWAY_MSG LEX_BL_MSG_ONLY LEX_ADMIN LEX_BIP_USE_NOTICE
%union {
int number;
@ -138,6 +138,8 @@ usr_command:
| LEX_PASSWORD LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_PASSWORD,
$3); }
| LEX_ADMIN LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_ADMIN, $3); }
| LEX_BIP_USE_NOTICE LEX_EQ LEX_BOOL {
$$ = tuple_i_new(LEX_BIP_USE_NOTICE, $3); }
| LEX_SSL_CHECK_MODE LEX_EQ LEX_STRING { $$ = tuple_s_new(
LEX_SSL_CHECK_MODE, $3); }
| LEX_SSL_CHECK_STORE LEX_EQ LEX_STRING { $$ = tuple_s_new(

View File

@ -25,5 +25,6 @@
#define DEFAULT_LOG_SYNC_INTERVAL 5
#define DEFAULT_LOG_LEVEL LOG_INFO
#define DEFAULT_LOG_FORMAT "%u/%n/%Y-%m/%c.%d.log"
#define DEFAULT_BIP_USE_NOTICE 0
#endif /* DEFAULTS_H */

View File

@ -1091,7 +1091,9 @@ static int irc_dispatch_client(bip_t *bip, struct link_client *ic,
LINK(ic)->l_server->nick)
write_line(CONN(LINK(ic)->l_server), str);
else if (LINK(ic)->l_server->nick)
WRITE_LINE2(CONN(ic), P_IRCMASK, "PRIVMSG",
WRITE_LINE2(CONN(ic), P_IRCMASK,
(LINK(ic)->user->bip_use_notice ?
"NOTICE" : "PRIVMSG"),
LINK(ic)->l_server->nick,
":Not connected please try again "
"later...\r\n");

View File

@ -69,6 +69,7 @@ struct user {
unsigned char *password;
unsigned int seed;
int admin;
int bip_use_notice;
/* common link options */

View File

@ -99,6 +99,7 @@ list_t *parse_conf(FILE *file)
"on_connect_send" { return LEX_ON_CONNECT_SEND; }
"no_client_away_msg" { return LEX_NO_CLIENT_AWAY_MSG; }
"pid_file" { return LEX_PID_FILE; }
"bip_use_notice" { return LEX_BIP_USE_NOTICE; }
\"[^"]*\" {
size_t len = strlen(yytext) - 2;
yylval.string = malloc(len + 1);