예제 #1
0
    def do_mode(self, target, msg, nick, send):
        """reop and handle guard violations."""
        mode_changes = modes.parse_channel_modes(msg)
        with self.data_lock:
            for change in mode_changes:
                if change[1] == "v":
                    self.voiced[target][change[2]] = True if change[0] == "+" else False
                if change[1] == "o":
                    self.opers[target][change[2]] = True if change[0] == "+" else False
        # reop
        # FIXME: handle -o+o msbobBot msbobBot
        if [x for x in mode_changes if self.check_mode(x)]:
            send("%s: :(" % nick, target=target)
            # Assume bot admins know what they're doing.
            if not self.is_admin(None, nick):
                send("OP %s" % target, target="ChanServ")
                send("UNBAN %s" % target, target="ChanServ")

        if len(self.guarded) > 0:
            # if user is guarded and quieted, devoiced, or deopped, fix that
            regex = r"(.*(-v|-o|\+q|\+b)[^ ]*) (%s)" % "|".join(self.guarded)
            match = re.search(regex, msg)
            if match and nick not in [match.group(3), self.connection.real_nickname]:
                modestring = "+voe-qb %s" % (" ".join([match.group(3)] * 5))
                self.connection.mode(target, modestring)
                send("Mode %s on %s by the guard system" % (modestring, target), target=self.config["core"]["ctrlchan"])
예제 #2
0
 def update_key(self, modes):
     for sign, key, value in parse_channel_modes(" ".join(modes)):
         # update channel key
         if key == "k":
             value = None if sign == "-" else value
             if value != self.key:
                 self.key = value
                 if self.id is not None:
                     asyncio.ensure_future(self.save())
예제 #3
0
    def on_mode(self, conn, event) -> None:
        super().on_mode(conn, event)

        # when we get ops (or half-ops) get current ban list to see if we need to ban someone that has been banned on matrix
        modes = list(event.arguments)
        for sign, key, value in parse_channel_modes(" ".join(modes)):
            if sign == "+" and key in [
                    "o", "h"
            ] and value == self.network.conn.real_nickname:
                self.network.conn.mode(self.name, "+b")
예제 #4
0
파일: handler.py 프로젝트: srct/srctbot
    def do_mode(self, target, msg, nick, send):
        """ reop and handle guard violations """
        # reop
        mode_changes = list(filter(self.check_mode, modes.parse_channel_modes(msg)))
        if mode_changes:
            send("%s: :(" % nick, target=target)
            send("OP %s" % target, target='ChanServ')
            send("UNBAN %s" % target, target='ChanServ')

        if len(self.guarded) > 0:
            # if user is guarded and quieted, devoiced, or deopped, fix that
            regex = r"(.*(-v|-o|\+q|\+b)[^ ]*) (%s)" % "|".join(self.guarded)
            match = re.search(regex, msg)
            if match and nick not in [match.group(3), self.connection.real_nickname]:
                modestring = "+voe-qb %s" % (" ".join([match.group(3)] * 5))
                self.connection.mode(target, modestring)
                send('Mode %s on %s by the guard system' % (modestring, target), target=self.config['core']['ctrlchan'])
예제 #5
0
    def do_mode(self, target, msg, nick, send):
        """ reop and handle guard violations """
        # reop
        mode_changes = list(filter(self.check_mode, modes.parse_channel_modes(msg)))
        if mode_changes:
            send("%s: :(" % nick, target=target)
            send("OP %s" % target, target='ChanServ')
            send("UNBAN %s" % target, target='ChanServ')

        if len(self.guarded) > 0:
            # if user is guarded and quieted, devoiced, or deopped, fix that
            regex = r"(.*(-v|-o|\+q|\+b)[^ ]*) (%s)" % "|".join(self.guarded)
            match = re.search(regex, msg)
            if match and nick not in [match.group(3), self.connection.real_nickname]:
                modestring = "+voe-qb %s" % (" ".join([match.group(3)] * 5))
                self.connection.mode(target, modestring)
                send('Mode %s on %s by the guard system' % (modestring, target), target=self.config['core']['ctrlchan'])