summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Wienand <iwienand@redhat.com>2018-08-02 14:23:04 +1000
committerIan Wienand <iwienand@redhat.com>2018-08-02 14:28:00 +1000
commit78f18d9b0e3003798e8ae92d5930d26fbae60262 (patch)
tree698d83091e8b6723adfbf541d56f019ac1c818be
parent4e23eb18a09fd3187599e8c00e5a84557b505109 (diff)
Add mlock setting and op_channel optionHEADmaster
Add a mode option, which is passed through to mlock to set the modes on channels. Individual channels can override the global setting. Because you must be an operator in the channel you are forwarding to when using the +f mode, add a op_channel option that pre-joins a given channel and promotes ourselves to ops in there. [1] https://wiki.swiftirc.net/wiki/Chanserv#Mlock Change-Id: Ic3ea018f1dd3032a628030ed56cfd863de2f159d
Notes
Notes (review): Code-Review+2: Monty Taylor <mordred@inaugust.com> Code-Review+1: Andreas Jaeger <jaegerandi@gmail.com> Code-Review+2: Clark Boylan <cboylan@sapwetik.org> Code-Review+2: James E. Blair <corvus@inaugust.com> Workflow+1: Ian Wienand <iwienand@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 06 Aug 2018 00:07:12 +0000 Reviewed-on: https://review.openstack.org/588134 Project: openstack-infra/puppet-accessbot Branch: refs/heads/master
-rwxr-xr-xfiles/accessbot.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/files/accessbot.py b/files/accessbot.py
index 15c1baf..7c968e3 100755
--- a/files/accessbot.py
+++ b/files/accessbot.py
@@ -81,6 +81,11 @@ class SetAccess(irc.client.SimpleIRCClient):
81 if auth == '+' and nick == 'NickServ' and not self.identified: 81 if auth == '+' and nick == 'NickServ' and not self.identified:
82 if msg.startswith('You are now identified'): 82 if msg.startswith('You are now identified'):
83 self.identified = True 83 self.identified = True
84 # Prejoin and set ourselves as op in these channels,
85 # to facilitate +f forwarding.
86 for channel in self.config.get('op_channels', []):
87 c.join("#%s" % channel)
88 c.privmsg("chanserv", "op #%s" % channel)
84 self.advance() 89 self.advance()
85 return 90 return
86 if auth != '+' or nick != 'ChanServ': 91 if auth != '+' or nick != 'ChanServ':
@@ -93,6 +98,7 @@ class SetAccess(irc.client.SimpleIRCClient):
93 def _get_access_list(self, channel_name): 98 def _get_access_list(self, channel_name):
94 ret = {} 99 ret = {}
95 alumni = [] 100 alumni = []
101 mode = ''
96 channel = None 102 channel = None
97 for c in self.config['channels']: 103 for c in self.config['channels']:
98 if c['name'] == channel_name: 104 if c['name'] == channel_name:
@@ -108,12 +114,15 @@ class SetAccess(irc.client.SimpleIRCClient):
108 if access == 'alumni': 114 if access == 'alumni':
109 alumni += nicks 115 alumni += nicks
110 continue 116 continue
117 if access == 'mode':
118 mode = nicks
119 continue
111 flags = self.config['access'].get(access) 120 flags = self.config['access'].get(access)
112 if flags is None: 121 if flags is None:
113 continue 122 continue
114 for nick in nicks: 123 for nick in nicks:
115 ret[nick] = flags 124 ret[nick] = flags
116 return mask, ret, alumni 125 return mask, ret, alumni, mode
117 126
118 def _get_access_change(self, current, target, mask): 127 def _get_access_change(self, current, target, mask):
119 remove = '' 128 remove = ''
@@ -140,11 +149,12 @@ class SetAccess(irc.client.SimpleIRCClient):
140 return change 149 return change
141 150
142 def _get_access_changes(self): 151 def _get_access_changes(self):
143 mask, target, alumni = self._get_access_list(self.current_channel) 152 mask, target, alumni, mode = self._get_access_list(self.current_channel)
144 self.log.debug("Mask for %s: %s" % (self.current_channel, mask)) 153 self.log.debug("Mask for %s: %s" % (self.current_channel, mask))
145 self.log.debug("Target for %s: %s" % (self.current_channel, target)) 154 self.log.debug("Target for %s: %s" % (self.current_channel, target))
146 all_nicks = set() 155 all_nicks = set()
147 global_alumni = self.config.get('alumni', {}) 156 global_alumni = self.config.get('alumni', {})
157 global_mode = self.config.get('mode', '')
148 current = {} 158 current = {}
149 changes = [] 159 changes = []
150 for nick, flags, msg in self.current_list: 160 for nick, flags, msg in self.current_list:
@@ -162,6 +172,19 @@ class SetAccess(irc.client.SimpleIRCClient):
162 if change: 172 if change:
163 changes.append('access #%s add %s %s' % (self.current_channel, 173 changes.append('access #%s add %s %s' % (self.current_channel,
164 nick, change)) 174 nick, change))
175
176 # Set the mode. Note we always just hard-set the mode for
177 # simplicity (per the man page mlock always clears and sets
178 # anyway). Channel mode overrides global mode.
179 #
180 # Note for +f you need to be op in the target channel; see
181 # op_channel option.
182 if not mode and global_mode:
183 mode = global_mode
184 self.log.debug("Setting mode to : %s" % mode)
185 if mode:
186 changes.append('set #%s mlock %s' % (self.current_channel, mode))
187
165 return changes 188 return changes
166 189
167 def advance(self, msg=None): 190 def advance(self, msg=None):