]>
Commit | Line | Data |
---|---|---|
edb26b39 | 1 | # HG changeset patch |
ec9258d4 | 2 | # Parent 911ee97f60c6e2686d82d9117aecb6ea3e5afa3c |
edb26b39 | 3 | |
ec9258d4 P |
4 | diff -r 911ee97f60c6 include/channel.h |
5 | --- a/include/channel.h Sat Jul 20 12:01:08 2013 +0100 | |
6 | +++ b/include/channel.h Sat Jul 20 13:28:59 2013 +0100 | |
edb26b39 P |
7 | @@ -372,6 +372,7 @@ |
8 | int parc, char *parv[], int badop, int mtype); | |
9 | extern struct Channel *get_channel(struct Client *cptr, | |
10 | char *chname, ChannelGetType flag); | |
11 | +extern int SetAutoChanModes(struct Channel *chptr); | |
12 | extern struct Membership* find_member_link(struct Channel * chptr, | |
13 | const struct Client* cptr); | |
14 | extern int sub1_from_channel(struct Channel* chptr); | |
ec9258d4 P |
15 | diff -r 911ee97f60c6 include/ircd_features.h |
16 | --- a/include/ircd_features.h Sat Jul 20 12:01:08 2013 +0100 | |
17 | +++ b/include/ircd_features.h Sat Jul 20 13:28:59 2013 +0100 | |
edb26b39 P |
18 | @@ -61,6 +61,8 @@ |
19 | FEAT_LOCAL_CHANNELS, | |
20 | FEAT_TOPIC_BURST, | |
21 | FEAT_DISABLE_GLINES, | |
22 | + FEAT_AUTOCHANMODES, | |
23 | + FEAT_AUTOCHANMODES_LIST, | |
24 | ||
25 | /* features that probably should not be touched */ | |
26 | FEAT_KILLCHASETIMELIMIT, | |
ec9258d4 P |
27 | diff -r 911ee97f60c6 ircd/channel.c |
28 | --- a/ircd/channel.c Sat Jul 20 12:01:08 2013 +0100 | |
29 | +++ b/ircd/channel.c Sat Jul 20 13:28:59 2013 +0100 | |
edb26b39 P |
30 | @@ -1272,6 +1272,53 @@ |
31 | return chptr; | |
32 | } | |
33 | ||
34 | +int SetAutoChanModes(struct Channel *chptr) | |
35 | +{ | |
ec9258d4 | 36 | + static unsigned int chan_flags[] = { |
edb26b39 P |
37 | + MODE_PRIVATE, 'p', |
38 | + MODE_SECRET, 's', | |
39 | + MODE_MODERATED, 'm', | |
40 | + MODE_TOPICLIMIT, 't', | |
41 | + MODE_INVITEONLY, 'i', | |
42 | + MODE_NOPRIVMSGS, 'n', | |
43 | + MODE_REGONLY, 'r', | |
44 | +/* MODE_NOCOLOUR, 'c', | |
45 | + MODE_NOCTCP, 'C', | |
46 | + MODE_NONOTICE, 'N',*/ | |
47 | + MODE_DELJOINS, 'D', | |
48 | + MODE_NOQUITPARTS, 'u' | |
49 | + }; | |
50 | + | |
51 | + unsigned int *flag_p; | |
52 | + unsigned int t_mode; | |
53 | + const char *modestr; | |
54 | + | |
55 | + t_mode = 0; | |
56 | + | |
57 | + assert(0 != chptr); | |
58 | + | |
59 | + if (!feature_bool(FEAT_AUTOCHANMODES) || !feature_str(FEAT_AUTOCHANMODES_LIST) || strlen(feature_str(FEAT_AUTOCHANMODES_LIST)) <= 1) | |
60 | + return(-1); | |
61 | + | |
62 | + modestr = feature_str(FEAT_AUTOCHANMODES_LIST); | |
63 | + | |
64 | + for (; *modestr; modestr++) { | |
65 | + for (flag_p = chan_flags; flag_p[0]; flag_p += 2) /* look up flag */ | |
66 | + if (flag_p[1] == *modestr) | |
67 | + break; | |
68 | + | |
69 | + if (!flag_p[0]) /* didn't find it */ | |
70 | + continue; | |
71 | + | |
72 | + t_mode |= flag_p[0]; | |
73 | + | |
74 | + } /* for (; *modestr; modestr++) { */ | |
75 | + | |
76 | + if (t_mode != 0) | |
77 | + chptr->mode.mode = t_mode; | |
78 | + return(0); | |
79 | +} | |
80 | + | |
81 | /** invite a user to a channel. | |
82 | * | |
83 | * Adds an invite for a user to a channel. Limits the number of invites | |
84 | @@ -3602,6 +3649,15 @@ | |
85 | case JOINBUF_TYPE_CREATE: | |
86 | sendcmdto_serv_butone(jbuf->jb_source, CMD_CREATE, jbuf->jb_connect, | |
87 | "%s %Tu", chanlist, jbuf->jb_create); | |
88 | + if (MyUser(jbuf->jb_source) && (feature_bool(FEAT_AUTOCHANMODES) && | |
89 | + feature_str(FEAT_AUTOCHANMODES_LIST) && (strlen(feature_str(FEAT_AUTOCHANMODES_LIST)) > 0))) { | |
90 | + char *name; | |
91 | + char *p = 0; | |
92 | + for (name = ircd_strtok(&p, chanlist, ","); name; name = ircd_strtok(&p, 0, ",")) { | |
93 | + sendcmdto_serv_butone(jbuf->jb_source, CMD_MODE, jbuf->jb_connect, | |
94 | + "%s %s%s", name, "+", feature_str(FEAT_AUTOCHANMODES_LIST)); | |
95 | + } | |
96 | + } | |
97 | break; | |
98 | ||
99 | case JOINBUF_TYPE_PART: | |
ec9258d4 P |
100 | diff -r 911ee97f60c6 ircd/ircd_features.c |
101 | --- a/ircd/ircd_features.c Sat Jul 20 12:01:08 2013 +0100 | |
102 | +++ b/ircd/ircd_features.c Sat Jul 20 13:28:59 2013 +0100 | |
edb26b39 P |
103 | @@ -326,6 +326,8 @@ |
104 | F_B(LOCAL_CHANNELS, 0, 1, 0), | |
105 | F_B(TOPIC_BURST, 0, 0, 0), | |
106 | F_B(DISABLE_GLINES, 0, 0, 0), | |
107 | + F_B(AUTOCHANMODES, 0, 1, 0), | |
108 | + F_S(AUTOCHANMODES_LIST, FEAT_CASE | FEAT_NULL, "ntCN", 0), | |
109 | ||
110 | /* features that probably should not be touched */ | |
111 | F_I(KILLCHASETIMELIMIT, 0, 30, 0), | |
ec9258d4 P |
112 | diff -r 911ee97f60c6 ircd/m_join.c |
113 | --- a/ircd/m_join.c Sat Jul 20 12:01:08 2013 +0100 | |
114 | +++ b/ircd/m_join.c Sat Jul 20 13:28:59 2013 +0100 | |
edb26b39 P |
115 | @@ -174,6 +174,8 @@ |
116 | } | |
117 | ||
118 | joinbuf_join(&create, chptr, CHFL_CHANOP | CHFL_CHANNEL_MANAGER); | |
119 | + if (feature_bool(FEAT_AUTOCHANMODES) && feature_str(FEAT_AUTOCHANMODES_LIST) && strlen(feature_str(FEAT_AUTOCHANMODES_LIST)) > 0) | |
120 | + SetAutoChanModes(chptr); | |
121 | } else if (find_member_link(chptr, sptr)) { | |
122 | continue; /* already on channel */ | |
123 | } else if (check_target_limit(sptr, chptr, chptr->chname, 0)) { |