diff options
-rw-r--r-- | doc/user-guide/commands.xml | 11 | ||||
-rw-r--r-- | irc.c | 1 | ||||
-rw-r--r-- | irc.h | 3 | ||||
-rw-r--r-- | irc_channel.c | 58 |
4 files changed, 65 insertions, 8 deletions
diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index 0de4dfcf..1060962e 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -1680,6 +1680,17 @@ </description> </bitlbee-setting> + <bitlbee-setting name="ops_mode" type="string" scope="global"> + <default>@</default> + <possible-values>~, &, @, %, +</possible-values> + + <description> + <para> + Use the specified mode for root/user. + </para> + </description> + </bitlbee-setting> + <bitlbee-command name="rename"> <short-description>Rename (renick) a buddy</short-description> <syntax>rename <oldnick> <newnick></syntax> @@ -116,6 +116,7 @@ irc_t *irc_new(int fd) s = set_add(&b->set, "nick_format", "%-@nick", NULL, irc); s = set_add(&b->set, "offline_user_quits", "true", set_eval_bool, irc); s = set_add(&b->set, "ops", "both", set_eval_irc_channel_ops, irc); + s = set_add(&b->set, "ops_mode", "@", set_eval_irc_channel_ops_mode, irc); s = set_add(&b->set, "paste_buffer", "false", set_eval_bool, irc); s->old_key = g_strdup("buddy_sendbuffer"); s = set_add(&b->set, "paste_buffer_delay", "200", set_eval_int, irc); @@ -302,8 +302,9 @@ void irc_channel_name_strip(char *name); int irc_channel_name_cmp(const char *a_, const char *b_); char *irc_channel_name_gen(irc_t *irc, const char *name); gboolean irc_channel_name_hint(irc_channel_t *ic, const char *name); -void irc_channel_update_ops(irc_channel_t *ic, char *value); +void irc_channel_update_ops(irc_channel_t *ic, char *ops, char *ops_mode); char *set_eval_irc_channel_ops(struct set *set, char *value); +char *set_eval_irc_channel_ops_mode(struct set *set, char *value); gboolean irc_channel_wants_user(irc_channel_t *ic, irc_user_t *iu); /* irc_commands.c */ diff --git a/irc_channel.c b/irc_channel.c index acae85a7..04eb0c4f 100644 --- a/irc_channel.c +++ b/irc_channel.c @@ -239,7 +239,8 @@ int irc_channel_add_user(irc_channel_t *ic, irc_user_t *iu) ic->users = g_slist_insert_sorted(ic->users, icu, irc_channel_user_cmp); - irc_channel_update_ops(ic, set_getstr(&ic->irc->b->set, "ops")); + irc_channel_update_ops(ic, set_getstr(&ic->irc->b->set, "ops"), + set_getstr(&ic->irc->b->set, "ops_mode")); if (iu == ic->irc->user || ic->flags & IRC_CHANNEL_JOINED) { ic->flags |= IRC_CHANNEL_JOINED; @@ -642,14 +643,33 @@ static gint irc_channel_user_cmp(gconstpointer a_, gconstpointer b_) return irc_user_cmp(a->iu, b->iu); } -void irc_channel_update_ops(irc_channel_t *ic, char *value) +static int irc_channel_prefix_to_mode(char *value) { + if (g_strcasecmp(value, "~") == 0) { + return IRC_CHANNEL_USER_OWNER; + } else if (g_strcasecmp(value, "&") == 0) { + return IRC_CHANNEL_USER_ADMIN; + } else if (g_strcasecmp(value, "@") == 0) { + return IRC_CHANNEL_USER_OP; + } else if (g_strcasecmp(value, "%") == 0) { + return IRC_CHANNEL_USER_HALFOP; + } else if (g_strcasecmp(value, "+") == 0) { + return IRC_CHANNEL_USER_VOICE; + } else { + return 0; + } +} + +void irc_channel_update_ops(irc_channel_t *ic, char *ops, char *ops_mode) +{ + int mode = irc_channel_prefix_to_mode(ops_mode); + irc_channel_user_set_mode(ic, ic->irc->root, - (strcmp(value, "both") == 0 || - strcmp(value, "root") == 0) ? IRC_CHANNEL_USER_OP : 0); + (strcmp(ops, "both") == 0 || + strcmp(ops, "root") == 0) ? mode : 0); irc_channel_user_set_mode(ic, ic->irc->user, - (strcmp(value, "both") == 0 || - strcmp(value, "user") == 0) ? IRC_CHANNEL_USER_OP : 0); + (strcmp(ops, "both") == 0 || + strcmp(ops, "user") == 0) ? mode : 0); } char *set_eval_irc_channel_ops(set_t *set, char *value) @@ -663,7 +683,27 @@ char *set_eval_irc_channel_ops(set_t *set, char *value) } for (l = irc->channels; l; l = l->next) { - irc_channel_update_ops(l->data, value); + irc_channel_update_ops(l->data, value, set_getstr(&irc->b->set, "ops_mode")); + } + + return value; +} + +char *set_eval_irc_channel_ops_mode(set_t *set, char *value) +{ + irc_t *irc = set->data; + GSList *l; + + if (g_strcasecmp(value, "~") != 0 && + g_strcasecmp(value, "&") != 0 && + g_strcasecmp(value, "@") != 0 && + g_strcasecmp(value, "%") != 0 && + g_strcasecmp(value, "+") != 0) { + return SET_INVALID; + } + + for (l = irc->channels; l; l = l->next) { + irc_channel_update_ops(l->data, set_getstr(&irc->b->set, "ops"), value); } return value; @@ -887,6 +927,10 @@ static char *set_eval_show_users(set_t *set, char *value) modechar = IRC_CHANNEL_USER_HALFOP; } else if (last == '@') { modechar = IRC_CHANNEL_USER_OP; + } else if (last == '&') { + modechar = IRC_CHANNEL_USER_ADMIN; + } else if (last == '~') { + modechar = IRC_CHANNEL_USER_OWNER; } if (strncmp(*part, "offline", 7) == 0) { |