aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--irc.c1
-rw-r--r--irc.h3
-rw-r--r--irc_channel.c54
3 files changed, 50 insertions, 8 deletions
diff --git a/irc.c b/irc.c
index 835bffa0..563f230f 100644
--- a/irc.c
+++ b/irc.c
@@ -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);
diff --git a/irc.h b/irc.h
index c579e618..5ce7b07d 100644
--- a/irc.h
+++ b/irc.h
@@ -314,9 +314,10 @@ 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 irc_channel_user_get_prefix(irc_channel_user_t *icu);
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 e8564da7..8ea348f2 100644
--- a/irc_channel.c
+++ b/irc_channel.c
@@ -245,7 +245,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);
if (iu == ic->irc->user || iu == ic->irc->root) {
- 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) {
@@ -679,14 +680,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)
@@ -700,12 +720,32 @@ 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 0;
+}
+
/* Channel-type dependent functions, for control channels: */
static gboolean control_channel_privmsg(irc_channel_t *ic, const char *msg)
{