Exemplo n.º 1
0
 def robocop(self, message, request_id, mode):
     request = Request.load(request_id, active=False)
     if request is None:
         return
     
     if mode == "cancel":
         reply = "Cancelled scan request %s" % (request.id,)
         message.privmsg(reply, self.scanchan())
         nicks = CUT.get_user_nicks(request.user.name)
         for nick in nicks:
             message.privmsg(reply, nick)
         return
     
     if mode == "block":
         reply = "Updated request %s dists to %s" % (request.id, request.dists,)
         message.privmsg(reply, self.scanchan())
         nicks = CUT.get_user_nicks(request.user.name)
         for nick in nicks:
             message.privmsg(reply, nick)
         return
     
     user = request.user
     planet = request.target
     
     requester = user.name if not Config.getboolean("Misc", "anonscans") else "Anon"
     dists_intel = planet.intel.dists if planet.intel else 0
     message.privmsg("[%s] %s requested a %s Scan of %s:%s:%s Dists(i:%s%s) " % (request.id, requester, request.type, planet.x,planet.y,planet.z, 
                                                     dists_intel, "/r:%s" % request.dists if request.dists > 0 else "") + request.link, self.scanchan())
Exemplo n.º 2
0
Arquivo: remuser.py Projeto: JDD/DLR
    def execute(self, message, user, params):

        username = params.group(1)
        member = User.load(name=username, active=False)
        if member is None:
            message.alert("No such user '%s'" % (username,))
            return
        if member.access > user.access:
            message.reply(
                "You may not remove %s, his or her access (%s) exceeds your own (%s)"
                % (member.name, member.access, user.access)
            )
            return

        mbraxx = Config.getint("Access", "member")
        home = Config.get("Channels", "home")
        coraxx = Config.getint("Access", "core")
        core = Config.get("Channels", "core")

        if member.active and member.access >= mbraxx:
            message.privmsg("remuser %s %s" % (home, member.name), "P")
        if member.active and member.access >= coraxx:
            message.privmsg("remuser %s %s" % (core, member.name), "P")
        session.delete(member)
        session.commit()
        message.reply("Removed user %s" % (member.name,))
        CUT.untrack_user(member.name)
Exemplo n.º 3
0
    def execute(self, message, user, params):

        username = params.group(1)
        member = User.load(name=username, active=False)
        if member is None:
            message.alert("No such user '%s'" % (username, ))
            return
        if member.access > user.access:
            message.reply(
                "You may not remove %s, his or her access (%s) exceeds your own (%s)"
                % (
                    member.name,
                    member.access,
                    user.access,
                ))
            return

        mbraxx = Config.getint("Access", "member")
        home = Config.get("Channels", "home")

        if member.active and member.access >= mbraxx:
            message.privmsg("remuser %s %s" % (
                home,
                member.name,
            ), Config.get("Services", "nick"))
#            message.privmsg("ban %s *!*@%s.%s GTFO, EAAD"%(home, member.name, Config.get("Services", "usermask"),), Config.get("Services", "nick"))
        session.delete(member)
        session.commit()
        message.reply("Removed user %s" % (member.name, ))
        CUT.untrack_user(member.name)
Exemplo n.º 4
0
 def robocop(self, message, request_id, mode):
     request = Request.load(request_id, active=False)
     if request is None:
         return
     
     if mode == "cancel":
         reply = "Cancelled scan request %s" % (request.id,)
         message.privmsg(reply, self.scanchan())
         nicks = CUT.get_user_nicks(request.user.name)
         for nick in nicks:
             message.privmsg(reply, nick)
         return
     
     if mode == "block":
         reply = "Updated request %s dists to %s" % (request.id, request.dists,)
         message.privmsg(reply, self.scanchan())
         nicks = CUT.get_user_nicks(request.user.name)
         for nick in nicks:
             message.privmsg(reply, nick)
         return
     
     user = request.user
     planet = request.target
     
     requester = user.name if not Config.getboolean("Misc", "anonscans") else "Anon"
     dists_intel = planet.intel.dists if planet.intel else 0
     message.privmsg("[%s] %s requested a %s Scan of %s:%s:%s Dists(i:%s%s) " % (request.id, requester, request.type, planet.x,planet.y,planet.z, 
                                                     dists_intel, "/r:%s" % request.dists if request.dists > 0 else "") + request.link, self.scanchan())
Exemplo n.º 5
0
def pnick(message):
    # Part of a WHOIS result
    if message.get_msg() == "is logged in as":
        nick = message.line.split()[3]
        pnick = message.line.split()[4]
        # Set the user's pnick
        CUT.get_user(nick, pnick=pnick)
Exemplo n.º 6
0
 def notice(self, text, target=None):
     # If we're opped in a channel in common with the user, we can reply with
     #  CNOTICE instead of NOTICE which doesn't count towards the flood limit.
     if hasattr(self, "_channel") and CUT.opped(self.get_chan()) and CUT.nick_in_chan(target or self.get_nick(), self.get_chan()):
         self.write("CNOTICE %s %s :%s" % (target or self.get_nick(), self.get_chan(), text))
     else:
         self.write("NOTICE %s :%s" % (target or self.get_nick(), text))
Exemplo n.º 7
0
 def notice(self, text, target=None, priority=0):
     # If we're opped in a channel in common with the user, we can reply with
     #  CNOTICE instead of NOTICE which doesn't count towards the flood limit.
     if hasattr(self, "_channel") and CUT.opped(self.get_chan()) and CUT.nick_in_chan(target or self.get_nick(), self.get_chan()):
         self.write("CNOTICE %s %s :%s" % (target or self.get_nick(), self.get_chan(), text), priority=priority)
     else:
         self.write("NOTICE %s :%s" % (target or self.get_nick(), text), priority=priority)
Exemplo n.º 8
0
 def privmsg(self, text, target=None, priority=0):
     if os.path.isfile("/tmp/meetingmode"):
         return
         # Privmsg someone. Target defaults to the person who triggered this line
         # Should we send colours?
     if (
         Config.has_option("Connection", "color")
         and not Config.has_option("NoColor", target)
         and not (target[0] in ["#", "&"] and Config.has_option("NoColorChan", target[1:]))
     ):
         text = "\x03" + Config.get("Connection", "color") + text + "\x0F"
         color = True
     else:
         color = False
     # If we're opped in a channel in common with the user, we can reply with
     #  CPRIVMSG instead of PRIVMSG which doesn't count towards the flood limit.
     if (
         (not target or target[0] not in "#&")
         and hasattr(self, "_channel")
         and CUT.opped(self.get_chan())
         and CUT.nick_in_chan(target or self.get_nick(), self.get_chan())
     ):
         self.write("CPRIVMSG %s %s :%s" % (target or self.get_nick(), self.get_chan(), text), color, priority)
     else:
         self.write("PRIVMSG %s :%s" % (target or self.get_nick(), text), color, priority)
Exemplo n.º 9
0
def part(message):
    # Someone is leaving a channel
    if message.get_nick() == Merlin.nick:
        # Bot is leaving the channel
        CUT.del_chan(message.get_chan())
    else:
        # Someone is leaving a channel we're in
        CUT.part(message.get_chan(), message.get_nick())
Exemplo n.º 10
0
def part(message):
    # Someone is leaving a channel
    if message.get_nick() == Merlin.nick:
        # Bot is leaving the channel
        CUT.del_chan(message.get_chan())
    else:
        # Someone is leaving a channel we're in
        CUT.part(message.get_nick(), message.get_chan())
Exemplo n.º 11
0
def channels(message):
    # Part of a WHOIS result
    if message.get_chan() == Merlin.nick:
        # Cycle through the list of channels
        for chan in message.get_msg().split():
            if chan[0] in ("@","+"): chan = chan[1:]
            # Reset the channel and get a list of nicks
            CUT.new_chan(chan)
            message.write("NAMES %s\nTOPIC %s" % (chan,chan,))
Exemplo n.º 12
0
def pnick(message):
    # Part of a WHOIS result
    hostmask = message.line.split()[5]
    m = pnickre.match(hostmask)
    if m:
        nick = message.line.split()[3]
        pnick = m.group(1)
        # Set the user's pnick
        CUT.get_user(nick, None, pnick=pnick)
Exemplo n.º 13
0
def kick(message):
    # Someone is kicked
    kname = message.line.split()[3]
    if Merlin.nick == kname:
        # Bot is kicked from the channel
        CUT.del_chan(message.get_chan())
    else:
        # Someone is kicked from a channel we're in
        CUT.part(message.get_chan(), kname)
Exemplo n.º 14
0
def kick(message):
    # Someone is kicked
    kname = message.line.split()[3]
    if Merlin.nick == kname:
        # Bot is kicked from the channel
        CUT.del_chan(message.get_chan())
    else:
        # Someone is kicked from a channel we're in
        CUT.part(kname, message.get_chan())
Exemplo n.º 15
0
def names(message):
    # List of users in a channel
    for nick in message.get_msg().split():
        if nick == "@"+Merlin.nick:
            CUT.opped(message.get_chan(), True)
        if nick[0] in ("@","+"): nick = nick[1:]
        CUT.join(message.get_chan(), nick)
        if Config.get("Misc","usercache") == "join":
            # Use whois to get the user's pnick
            message.write("WHOIS %s" % (nick,))
Exemplo n.º 16
0
 def execute(self, message, user, params):
     
     username = params.group(1)
     access = params.group(2).lower()
     if access.isdigit():
         access = int(access)
     elif access in self.true:
         access = True
     elif access in self.false:
         access = False
     else:
         try:
             access = Config.getint("Access",access)
         except Exception:
             message.reply("Invalid access level '%s'" % (access,))
             return
     
     member = User.load(name=username, active=False)
     if member is None:
         message.alert("No such user '%s'" % (username,))
         return
     
     if type(access) is int and not member.active:
         message.reply("You should first re-activate user %s" %(member.name,))
         return
     
     if access > user.access or member.access > user.access:
         message.reply("You may not change access higher than your own")
         return
     
     mbraxx = Config.getint("Access","member")
     home = Config.get("Channels","home")
     
     if type(access) == int:
         if member.active == True and member.access < mbraxx and access >= mbraxx:
             message.privmsg("adduser %s %s 399" %(home, member.name,), Config.get("Services", "nick"))
             message.reply("%s has been added to %s"%(member.name, home,))
         if member.active == True and member.access >= mbraxx and access < mbraxx:
             message.privmsg("remuser %s %s"%(home, member.name,), Config.get("Services", "nick"))
             message.privmsg("ban %s *!*@%s.%s GTFO, EAAD"%(home, member.name, Config.get("Services", "usermask"),), Config.get("Services", "nick"))
         member.access = access
     else:
         if member.active != access and access == True and member.access >= mbraxx:
             message.privmsg("adduser %s %s 399" %(home, member.name,), Config.get("Services", "nick"))
             message.reply("%s has been added to %s"%(member.name, home,))
         if member.active != access and access == False and member.access >= mbraxx:
             message.privmsg("remuser %s %s"%(home, member.name,), Config.get("Services", "nick"))
             message.privmsg("ban %s *!*@%s.%s GTFO, EAAD"%(home, member.name, Config.get("Services", "usermask"),), Config.get("Services", "nick"))
         member.active = access
     session.commit()
     message.reply("Editted user %s access: %s" % (member.name, access,))
     if not member.active:
         CUT.untrack_user(member.name)
Exemplo n.º 17
0
def channels(message):
    # Part of a WHOIS result
    if message.get_chan() == Merlin.nick:
        # Cycle through the list of channels
        for chan in message.get_msg().split():
            modes, chan = chanre.match(chan).groups()
            opped = "@" in modes
            # Reset the channel and get a list of nicks
            CUT.new_chan(chan)
            CUT.opped(chan, opped)
            if CUT.mode_is("rapid", "join"):
                message.write("NAMES %s\nTOPIC %s" % (chan,chan,))
Exemplo n.º 18
0
    def run(self):
        # Import elements of Core we need
        # These will be refreshed each time the Loader reloads
        from Core.loader import Loader
        from Core.exceptions_ import Quit, Reboot, Reload, Call999
        from Core.connection import Connection
        from Core.chanusertracker import CUT
        from Core.robocop import RoboCop
        from Core.router import Router
	from Core.actions import Action
        
        # Collect any garbage remnants that might have been left behind
        #  from an old loader or backup that wasn't properly dereferenced
        gc.collect()
        
        try:

            # Attach the IRC connection and configure
            self.irc = Connection.attach(*self.irc)
            # Attach the RoboCop/clients sockets and configure
            self.robocop = RoboCop.attach(*self.robocop)
            # Attach the CUT state
            self.cut = CUT.attach(*self.cut)
            
            # Operation loop
            Router.run()
        
        except Call999 as exc:
            # RoboCop server failed, restart it
            self.robocop = RoboCop.disconnect(str(exc))
            return
        
        except Reboot as exc:
            # Reset the connection first
            self.irc = Connection.disconnect(str(exc) or "Rebooting")
            print "%s Reloading..." % (time.asctime(),)
            # Reimport all the modules
            Loader.reload()
            return
        
        except Reload:
            # Detach the current CUT state
            self.cut = CUT.detach()
            print "%s Reloading..." % (time.asctime(),)
            # Reimport all the modules
            Loader.reload()
            return
        
        except (Quit, KeyboardInterrupt, SystemExit) as exc:
            self.irc = Connection.disconnect(str(exc) or "Bye!")
            self.robocop = RoboCop.disconnect(str(exc) or "Bye!")
            sys.exit("Bye!")
Exemplo n.º 19
0
    def run(self):
        # Import elements of Core we need
        # These will be refreshed each time the Loader reloads
        from Core.loader import Loader
        from Core.exceptions_ import Quit, Reboot, Reload, Call999
        from Core.connection import Connection
        from Core.chanusertracker import CUT
        from Core.robocop import RoboCop
        from Core.router import Router

        # Collect any garbage remnants that might have been left behind
        #  from an old loader or backup that wasn't properly dereferenced
        gc.collect()

        try:
            # Attach the IRC connection and configure
            self.irc = Connection.attach(*self.irc)
            # Attach the RoboCop/clients sockets and configure
            self.robocop = RoboCop.attach(*self.robocop)
            # Attach the CUT state
            self.cut = CUT.attach(*self.cut)

            # Operation loop
            Router.run()

        except Call999 as exc:
            # RoboCop server failed, restart it
            self.robocop = RoboCop.disconnect(str(exc))
            return

        except Reboot as exc:
            # Reset the connection first
            self.irc = Connection.disconnect(str(exc) or "Rebooting")
            print "%s Reloading..." % (time.asctime(), )
            # Reimport all the modules
            Loader.reload()
            return

        except Reload:
            # Detach the current CUT state
            self.cut = CUT.detach()
            print "%s Reloading..." % (time.asctime(), )
            # Reimport all the modules
            Loader.reload()
            return

        except (Quit, KeyboardInterrupt, SystemExit) as exc:
            self.irc = Connection.disconnect(str(exc) or "Bye!")
            self.robocop = RoboCop.disconnect(str(exc) or "Bye!")
            sys.exit("Bye!")
Exemplo n.º 20
0
    def blocks(self, message, user, params):
        id = params.group(1)
        dists = int(params.group(2)) + 1
        request = Request.load(id)
        if request is None:
            message.reply("No open request number %s exists (idiot)." % (id, ))
            return
        if request.user is not user and not user.is_member(
        ) and not self.is_chan(message, self.scanchan()):
            message.reply(
                "Scan request %s isn't yours and you're not a scanner!" %
                (id, ))
            return

        request.dists = max(request.dists, dists)
        session.commit()

        reply = "Updated request %s dists to %s" % (
            id,
            request.dists,
        )
        message.reply(reply)
        if message.get_chan() != self.scanchan():
            message.privmsg(reply, self.scanchan())

        nicks = CUT.get_user_nicks(request.user.name)
        if message.get_nick() not in nicks:
            for nick in nicks:
                message.privmsg(reply, nick)
Exemplo n.º 21
0
    def blocks(self, message, user, params):
        id = params.group(1)
        dists = int(params.group(2)) + 1
        request = Request.load(id)
        if request is None:
            message.reply("No open request number %s exists (idiot)." % (id,))
            return
        if request.user is not user and not user.is_member() and not self.is_chan(message, self.scanchan()):
            message.reply("Scan request %s isn't yours and you're not a scanner!" % (id,))
            return

        # Update Intel
        planet = request.target
        if planet.intel is None:
            planet.intel = Intel()
        planet.intel.dists = max(planet.intel.dists, dists)

        request.dists = max(request.dists, dists)
        session.commit()

        reply = "Updated request %s dists to %s" % (id, request.dists)
        message.reply(reply)
        if message.get_chan() != self.scanchan():
            message.privmsg(reply, self.scanchan())

        nicks = CUT.get_user_nicks(request.user.name)
        if message.get_nick() not in nicks:
            for nick in nicks:
                message.privmsg(reply, nick)
Exemplo n.º 22
0
    def robocop(self, message, scantype, pa_id, x, y, z, names):
        nicks = []
        reply = "%s on %s:%s:%s " % (
            PA.get(scantype, "name"),
            x,
            y,
            z,
        )
        reply += Config.get("URL", "viewscan") % (pa_id, )

        for name in names.split(","):
            user = User.load(name)
            for nick in CUT.get_user_nicks(name):
                nicks.append(nick)
                message.privmsg(self.url(reply, user), nick)

        reply = "%s on %s:%s:%s " % (
            PA.get(scantype, "name"),
            x,
            y,
            z,
        )
        reply += "delivered to: "
        reply += ", ".join(nicks) if not Config.getboolean(
            "Misc", "anonscans") else "Anon"
        from Hooks.scans.request import request
        message.privmsg(reply, request().scanchan())
Exemplo n.º 23
0
    def router(self, message, command):
        for name, regex, access in self.routes:
            params = regex.match(command)
            if params is None:
                continue
            else:
                break
        else:
            raise ParseError

        route = getattr(self, name)

        user = self.check_access(message, access)
        if user is None:
            raise UserError

        if getattr(route, "_USER", False) is True:
            if self.is_user(user) is False:
                message.get_pnick()
                raise UserError

        if getattr(route, "_PLANET", False) is True:
            if self.user_has_planet(user) is False:
                raise PrefError

        if getattr(route, "_CHANNEL", None) is not None:
            if self.is_chan(message, route._CHANNEL) is False:
                raise ChanParseError(route._CHANNEL)

        if getattr(route, "_USER_IN", None) is not None:
            if CUT.nick_in_chan(message.get_nick(),
                                route._USER_IN) is not True:
                raise ChanParseError(route._USER_IN)

        return route, name, user, params
Exemplo n.º 24
0
 def router(self, message, command):
     for name, regex, access in self.routes:
         params = regex.match(command)
         if params is None:
             continue
         else:
             break
     else:
         raise ParseError
     
     route = getattr(self, name)
     
     user = self.check_access(message, access)
     if user is None:
         raise UserError
     
     if getattr(route, "_USER", False) is True:
         if self.is_user(user) is False:
             message.get_pnick()
             raise UserError
     
     if getattr(route, "_PLANET", False) is True:
         if self.user_has_planet(user) is False:
             raise PrefError
     
     if getattr(route, "_CHANNEL", None) is not None:
         if self.is_chan(message, route._CHANNEL) is False:
             raise ChanParseError(route._CHANNEL)
     
     if getattr(route, "_USER_IN", None) is not None:
         if CUT.nick_in_chan(message.get_nick(), route._USER_IN) is not True:
             raise ChanParseError(route._USER_IN)
     
     return route, name, user, params
Exemplo n.º 25
0
    def cancel(self, message, user, params):
        id = params.group(1)
        request = Request.load(id)
        if request is None:
            message.reply("No open request number %s exists (idiot)." % (id, ))
            return
        if request.user is not user and not user.is_member(
        ) and not self.is_chan(message, self.scanchan()):
            message.reply(
                "Scan request %s isn't yours and you're not a scanner!" %
                (id, ))
            return

        request.active = False
        session.commit()

        reply = "Cancelled scan request %s" % (id, )
        message.reply(reply)
        if message.get_chan() != self.scanchan():
            message.privmsg(reply, self.scanchan())

        nicks = CUT.get_user_nicks(request.user.name)
        if message.get_nick() not in nicks:
            for nick in nicks:
                message.privmsg(reply, nick)
Exemplo n.º 26
0
def admin_msg(message, priority=2):
    # Import these here or Core/connection.py will get upset.
    from Core.chanusertracker import CUT
    from Core.config import Config
    from Core.connection import Connection

    for a in Config.options("Admins"):
        for nick in CUT.get_user_nicks(a.lower()):
            Connection.write("PRIVMSG %s :%s" % (nick, message), priority)
Exemplo n.º 27
0
def op(message):
    # Used for tracking whether or not we're opped in channels
    if not CUT.Channels.has_key(message.get_chan()):
        # Probably a user mode change, not a channel
        return
    modes = message.line.split(None,4)[3:]
    if "o" in modes[0] and Merlin.nick in modes[1].split():
        # The change in mode involves ops, and the ops might involve us
        modes, args = modes[0], modes[1].split()
        if modes[0] not in "+-":
            # add a '+' before the modes if it isn't specified (e.g. MODE s)
            modes = "+" + modes
        # modes that require args, [0] for -, [1] for +
        require_args = {
            'q': (True, True),
            'a': (True, True),
            'o': (True, True),
            'h': (True, True),
            'v': (True, True),
            'b': (True, True),
            'l': (False, True),
            'k': (False, True),
        }
        for mode in modes:
            # cycle through modes changed
            if mode == "+":
                set = True
            elif mode == "-":
                set = False
            else:
                if mode == "o":
                    # ops changing, pop out the target being changed
                    target = args.pop(0)
                    if target == Merlin.nick:
                        # update our op status
                        CUT.opped(message.get_chan(), set)
                elif require_args.get(mode, (False, False))[set] is True:
                    # some other mode that requires an argument
                    target = args.pop(0)
Exemplo n.º 28
0
def letmein(message):
    """Invites the user to the private channel, if they provide their username and password"""
    # P redundancy
    msg = message.get_msg().split()
    if len(msg) != 3:
        message.alert("!letmein user pass")
        return
    try:
        user = CUT.auth_user(message.get_nick(), message.get_pnick, username=msg[1], password=msg[2])
        if (user is not None) and user.is_member():
            message.invite(message.get_nick(), Config.get("Channels","home"))
    except UserError:
        message.alert("You don't have access to this command")
Exemplo n.º 29
0
def auth(message):
    """Authenticates the user, if they provide their username and password"""
    # P redundancy
    msg = message.get_msg().split()
    if len(msg) != 3:
        message.alert("!auth user pass")
        return
    try:
        user = CUT.auth_user(message.get_nick(), message.get_pnick, username=msg[1], password=msg[2])
        if user is not None:
            message.reply("You have been authenticated as %s" % (user.name,))
    except UserError:
        message.alert("You don't have access to this command")
Exemplo n.º 30
0
def join(message):
    # Someone is joining a channel
    if message.get_nick() == Merlin.nick:
        # Bot is joining the channel, so add a new object to the dict
        CUT.new_chan(message.get_chan())
    else:
        # Someone is joining a channel we're in
        CUT.join(message.get_chan(), message.get_nick())
        if CUT.mode_is("rapid", "join"):
            # Set the user's pnick
            CUT.get_user(message.get_nick(), message.get_chan(), pnickf=message.get_pnick)
Exemplo n.º 31
0
def names(message):
    # List of users in a channel
    for nick in message.get_msg().split():
        if nick == "@"+Merlin.nick:
            CUT.opped(message.get_chan(), True)
        elif nick == "+"+Merlin.nick or nick == Merlin.nick:
            CUT.opped(message.get_chan(), False)
        if nick[0] in ("@","+"): nick = nick[1:]
        CUT.join(message.get_chan(), nick)
        if CUT.mode_is("rapid"):
            # Use whois to get the user's pnick
            message.write("WHOIS %s" % (nick,))
Exemplo n.º 32
0
def names(message):
    # List of users in a channel
    for nick in message.get_msg().split():
        modes, nick = modesre.match(nick).groups()
        if nick == Merlin.nick and "@" in modes:
            CUT.opped(message.get_chan(), True)
        elif nick == Merlin.nick:
            CUT.opped(message.get_chan(), False)
        if CUT.mode_is("rapid") and CUT.Nicks.get(nick) is None:
            # Use whois to get the user's pnick
            message.write("WHOIS %s" % (nick,))
        CUT.join(message.get_chan(), nick)
Exemplo n.º 33
0
def letmein(message):
    """Invites the user to the private channel, if they provide their username and password"""
    # P redundancy
    msg = message.get_msg().split()
    if len(msg) != 3:
        message.alert("!letmein user pass")
        return
    try:
        chan = message.get_chan() if message.in_chan() else None
        user = CUT.auth_user(message.get_nick(), chan, message.get_pnick, username=msg[1], password=msg[2])
        if (user is not None) and user.is_member():
            message.invite(message.get_nick(), Config.get("Channels","home"))
    except UserError:
        message.alert("You don't have access to this command")
Exemplo n.º 34
0
def auth(message):
    """Authenticates the user, if they provide their username and password"""
    # P redundancy
    msg = message.get_msg().split()
    if len(msg) != 3:
        message.alert("!auth user pass")
        return
    try:
        chan = message.get_chan() if message.in_chan() else None
        user = CUT.auth_user(message.get_nick(), chan, message.get_pnick, username=msg[1], password=msg[2])
        if user is not None:
            message.reply("You have been authenticated as %s" % (user.name,))
    except UserError:
        message.alert("You don't have access to this command")
Exemplo n.º 35
0
Arquivo: scans.py Projeto: JDD/DLR
 def robocop(self, message, scantype, pa_id, x, y, z, names):
     nicks = []
     [nicks.extend(nick) for nick in [CUT.list_user_nicks(name) for name in names.split(",")]]
     
     reply = "%s on %s:%s:%s " % (PA.get(scantype,"name"),x,y,z,)
     reply+= Config.get("URL","viewscan") % (pa_id,)
     for nick in nicks:
         message.privmsg(reply, nick)
     
     reply = "%s on %s:%s:%s " % (PA.get(scantype,"name"),x,y,z,)
     reply+= "delivered to: "
     reply+= ", ".join(nicks)
     from Hooks.scans.request import request
     message.privmsg(reply, request().scanchan())
Exemplo n.º 36
0
    def robocop(self,
                message,
                scantype,
                pa_id,
                x,
                y,
                z,
                names,
                scanner,
                reqs,
                old=False):
        nicks = []
        reply = "Old " if old else ""
        reply += "%s on %s:%s:%s " % (
            PA.get(scantype, "name"),
            x,
            y,
            z,
        )
        if ("showscanner" in Config.options("Misc")
                and Config.getboolean("Misc", "showscanner")
                and scanner != 'None'):
            reply += "from %s " % (User.load(id=scanner).name) if User.load(
                id=scanner) not in (None, 'None') else ""
        reply += Config.get("URL", "viewscan") % (pa_id, )
        if old:
            reply += " !request cancel %s if this is suitable." % (reqs)

        for name in names.split(","):
            user = User.load(name)
            for nick in CUT.get_user_nicks(name):
                nicks.append(nick)
                message.privmsg(self.url(reply, user), nick)

        if not old:
            reply = "[-%s] %s on %s:%s:%s " % (
                reqs,
                PA.get(scantype, "name"),
                x,
                y,
                z,
            )
            reply += "delivered to: "
            reply += ", ".join(nicks) if not Config.getboolean(
                "Misc", "anonscans") else "Anon"
            if Config.getboolean("Misc", "showurls"):
                reply += " (%s)" % (Config.get("URL", "viewscan") % (pa_id, ))
            from Hooks.scans.request import request
            message.privmsg(reply, request().scanchan())
Exemplo n.º 37
0
 def privmsg(self, text, target=None, priority=0):
     # Privmsg someone. Target defaults to the person who triggered this line
     # Should we send colours?
     if (Config.has_option("Connection", "color")
             and not Config.has_option("NoColor", target)
             and not (target[0] in ['#', '&']
                      and Config.has_option("NoColorChan", target[1:]))):
         text = "\x03" + Config.get("Connection", "color") + text + "\x0F"
         color = True
     else:
         color = False
     # If we're opped in a channel in common with the user, we can reply with
     #  CPRIVMSG instead of PRIVMSG which doesn't count towards the flood limit.
     if (not target or target[0] not in "#&") and hasattr(
             self, "_channel") and CUT.opped(
                 self.get_chan()) and CUT.nick_in_chan(
                     target or self.get_nick(), self.get_chan()):
         self.write(
             "CPRIVMSG %s %s :%s" %
             (target or self.get_nick(), self.get_chan(), text), color,
             priority)
     else:
         self.write("PRIVMSG %s :%s" % (target or self.get_nick(), text),
                    color, priority)
Exemplo n.º 38
0
 def robocop(self, message, scantype, pa_id, x, y, z, names):
     nicks = []
     reply = "%s on %s:%s:%s " % (PA.get(scantype,"name"),x,y,z,)
     reply+= Config.get("URL","viewscan") % (pa_id,)
     
     for name in names.split(","):
         user = User.load(name)
         for nick in CUT.get_user_nicks(name):
             nicks.append(nick)
             message.privmsg(self.url(reply, user), nick)
     
     reply = "%s on %s:%s:%s " % (PA.get(scantype,"name"),x,y,z,)
     reply+= "delivered to: "
     reply+= ", ".join(nicks) if not Config.getboolean("Misc", "anonscans") else "Anon"
     from Hooks.scans.request import request
     message.privmsg(reply, request().scanchan())
Exemplo n.º 39
0
def join(message):
    # Someone is joining a channel
    if message.get_nick() == Merlin.nick:
        # Bot is joining the channel, so add a new object to the dict
        CUT.new_chan(message.get_chan())
    else:
        # Someone is joining a channel we're in
        CUT.join(message.get_chan(), message.get_nick())
        if Config.get("Misc","usercache") == "join":
            # Set the user's pnick
            CUT.get_user(message.get_nick(), pnickf=message.get_pnick)
Exemplo n.º 40
0
    def cancel(self, message, user, params):
        cancel_ids = []
        reply_ids = []
        noexist = []
        noaccess = []

        for id in params.group(1).split():
            if ':' in id:
                [start,end] = id.split(':')
                cancel_ids += range(int(start), int(end)+1)
            elif '-' in id:
                [start,end] = id.split('-')
                cancel_ids += range(int(start), int(end)+1)
            else:
                cancel_ids.append(int(id))

        for id in cancel_ids:
            id = str(id)
            request = Request.load(id)
            if request is None:
                noexist.append(id)
                continue
            if request.user is not user and not user.is_member() and not self.is_chan(message, self.scanchan()):
                noaccess.append(id)
                continue
            
            request.active = False
            session.commit()

            reply = "Cancelled scan request %s" % (id)
            nicks = CUT.get_user_nicks(request.user.name)
            if message.get_nick() not in nicks:
                for nick in nicks:
                    message.privmsg(reply, nick)
            
            reply_ids.append(id)

        if len(noexist) > 0:
            message.reply("No open request number %s exists (idiot)."%(", ".join(noexist),))
        if len(noaccess) > 0:
            message.reply("Scan requests: %s aren't yours and you're not a scanner!"%(", ".join(noaccess),))
        if len(reply_ids) > 0:
            reply = "Cancelled scan request %s" % (", ".join(reply_ids))
            message.reply(reply)
            if message.get_chan() != self.scanchan():
                message.privmsg(reply, self.scanchan())
Exemplo n.º 41
0
    def cancel(self, message, user, params):
        cancel_ids = []
        reply_ids = []
        noexist = []
        noaccess = []

        for id in params.group(1).split():
            if ":" in id:
                [start, end] = id.split(":")
                cancel_ids += range(int(start), int(end) + 1)
            elif "-" in id:
                [start, end] = id.split("-")
                cancel_ids += range(int(start), int(end) + 1)
            else:
                cancel_ids.append(int(id))

        for id in cancel_ids:
            id = str(id)
            request = Request.load(id)
            if request is None:
                noexist.append(id)
                continue
            if request.user is not user and not user.is_member() and not self.is_chan(message, self.scanchan()):
                noaccess.append(id)
                continue

            request.active = False
            session.commit()

            reply = "Cancelled scan request %s" % (id)
            nicks = CUT.get_user_nicks(request.user.name)
            if message.get_nick() not in nicks:
                for nick in nicks:
                    message.privmsg(reply, nick)

            reply_ids.append(id)

        if len(noexist) > 0:
            message.reply("No open request number %s exists (idiot)." % (", ".join(noexist),))
        if len(noaccess) > 0:
            message.reply("Scan requests: %s aren't yours and you're not a scanner!" % (", ".join(noaccess),))
        if len(reply_ids) > 0:
            reply = "Cancelled scan request %s" % (", ".join(reply_ids))
            message.reply(reply)
            if message.get_chan() != self.scanchan():
                message.privmsg(reply, self.scanchan())
Exemplo n.º 42
0
def join(message):
    # Someone is joining a channel
    try:
        chan = message.get_msg()
    except MsgParseError:
        chan = message.get_chan()
    
    if message.get_nick() == Merlin.nick:
        # Bot is joining the channel, so add a new object to the dict
        CUT.new_chan(chan)
    else:
        # Someone is joining a channel we're in
        CUT.join(chan, message.get_nick())
        if CUT.mode_is("rapid", "join"):
            # Set the user's pnick
            CUT.get_user(message.get_nick(), chan, pnickf=message.get_pnick)
Exemplo n.º 43
0
 def check_access(self, message, user=None, channel=None):
     if message.in_chan():
         channel = channel or Channel.load(message.get_chan()) or Channel(maxlevel=0, userlevel=0)
         if channel.maxlevel < self.access and message.reply_type() == PUBLIC_REPLY:
             raise UserError
     else:
         channel = Channel(userlevel=0)
     user = user or CUT.get_user(message.get_nick(), pnickf=message.get_pnick)
     if self.is_user(user):
         if max(user.access, channel.userlevel) >= self.access:
             return user
         else:
             raise UserError
     else:
         if channel.userlevel >= self.access:
             return True
         elif message.get_pnick():
             raise UserError
Exemplo n.º 44
0
 def execute(self, message, user, params):
     if params.group(1):
         if not user.is_admin():
             message.alert("Insufficient access to send the help to %s." % params.group(1))
             return
         from Hooks.scans.request import request
         tnick = params.group(1).strip()
         if not CUT.nick_in_chan(tnick,request().scanchan()):
             message.alert("%s does not appear to be in the scanner channel. Aborting." % tnick)
             return
         if message.reply_type() == NOTICE_REPLY:
             message.notice(self.helptext, tnick, 2)
         else:
             message.privmsg(self.helptext, tnick, 2)
     elif message.reply_type() == PUBLIC_REPLY and not user.is_admin():
         message.alert("Insufficient access to spam the channel. Try another prefix." % params.group(1))
     else:
         message.reply(self.helptext, 2)
Exemplo n.º 45
0
Arquivo: request.py Projeto: JDD/DLR
 def blocks(self, message, user, params):
     id = params.group(1)
     dists = int(params.group(2))
     request = Request.load(id)
     if request is None:
         message.reply("No open request number %s exists (idiot)."%(id,))
         return
     
     request.dists = max(request.dists, dists)
     session.commit()
     
     reply = "Updated request %s dists to %s" % (id, request.dists,)
     message.reply(reply)
     if message.get_chan() != self.scanchan():
         message.privmsg(reply, self.scanchan())
     
     nicks = CUT.list_user_nicks(request.user.name)
     if message.get_nick() not in nicks:
         for nick in nicks:
             message.privmsg(reply, nick)
Exemplo n.º 46
0
 def execute(self, message, user, params):
     if params.group(1):
         if not user.is_admin():
             message.alert("Insufficient access to send the help to %s." %
                           params.group(1))
             return
         from Hooks.scans.request import request
         tnick = params.group(1).strip()
         if not CUT.nick_in_chan(tnick, request().scanchan()):
             message.alert(
                 "%s does not appear to be in the scanner channel. Aborting."
                 % tnick)
             return
         if message.reply_type() == NOTICE_REPLY:
             message.notice(self.helptext, tnick, 2)
         else:
             message.privmsg(self.helptext, tnick, 2)
     elif message.reply_type() == PUBLIC_REPLY and not user.is_admin():
         message.alert(
             "Insufficient access to spam the channel. Try another prefix."
             % params.group(1))
     else:
         message.reply(self.helptext, 2)
Exemplo n.º 47
0
 def check_access(self, message, access=None, user=None, channel=None):
     access = access or self.access
     if message.in_chan():
         channel = channel or Channel.load(message.get_chan()) or Channel(
             maxlevel=0, userlevel=0)
         if channel.maxlevel < access and message.reply_type(
         ) == PUBLIC_REPLY:
             raise UserError
     else:
         channel = Channel(userlevel=0)
     chan = message.get_chan() if message.in_chan() else None
     user = user or CUT.get_user(
         message.get_nick(), chan, pnickf=message.get_pnick)
     if self.is_user(user):
         if max(user.access, channel.userlevel) >= access:
             return user
         else:
             raise UserError
     else:
         if channel.userlevel >= access:
             return User()
         elif message.get_pnick():
             raise UserError
Exemplo n.º 48
0
    def execute(self, message, user, params):

        username = params.group(1)
        access = params.group(2).lower()
        if access.isdigit():
            access = int(access)
        elif access in self.true:
            access = True
        elif access in self.false:
            access = False
        else:
            try:
                access = Config.getint("Access", access)
            except Exception:
                message.reply("Invalid access level '%s'" % (access, ))
                return

        member = User.load(name=username, active=False)
        if member is None:
            message.alert("No such user '%s'" % (username, ))
            return

        if type(access) is int and not member.active:
            message.reply("You should first re-activate user %s" %
                          (member.name, ))
            return

        if access > user.access or member.access > user.access:
            message.reply("You may not change access higher than your own")
            return

        mbraxx = Config.getint("Access", "member")
        home = Config.get("Channels", "home")

        if type(access) == int:
            if member.active == True and member.access < mbraxx and access >= mbraxx:
                message.privmsg("adduser %s %s 399" % (
                    home,
                    member.name,
                ), Config.get("Services", "nick"))
                message.reply("%s has been added to %s" % (
                    member.name,
                    home,
                ))
            if member.active == True and member.access >= mbraxx and access < mbraxx:
                message.privmsg("remuser %s %s" % (
                    home,
                    member.name,
                ), Config.get("Services", "nick"))
                message.privmsg(
                    "ban %s *!*@%s.%s GTFO, EAAD" % (
                        home,
                        member.name,
                        Config.get("Services", "usermask"),
                    ), Config.get("Services", "nick"))
            member.access = access
        else:
            if member.active != access and access == True and member.access >= mbraxx:
                message.privmsg("adduser %s %s 399" % (
                    home,
                    member.name,
                ), Config.get("Services", "nick"))
                message.reply("%s has been added to %s" % (
                    member.name,
                    home,
                ))
            if member.active != access and access == False and member.access >= mbraxx:
                message.privmsg("remuser %s %s" % (
                    home,
                    member.name,
                ), Config.get("Services", "nick"))
                message.privmsg(
                    "ban %s *!*@%s.%s GTFO, EAAD" % (
                        home,
                        member.name,
                        Config.get("Services", "usermask"),
                    ), Config.get("Services", "nick"))
            member.active = access
        session.commit()
        message.reply("Editted user %s access: %s" % (
            member.name,
            access,
        ))
        if not member.active:
            CUT.untrack_user(member.name)
Exemplo n.º 49
0
def topic_change(message):
    # Topic of a channel is set
    CUT.topic(message.get_chan(), message.get_msg())
Exemplo n.º 50
0
    def execute(self, message, user, params):
        
        usernames = params.group(1)
        access = params.group(2).lower()
        if access.isdigit():
            access = int(access)
        elif access in self.true:
            access = True
        elif access in self.false:
            access = False
        else:
            try:
                access = Config.getint("Access",access)
            except Exception:
                message.reply("Invalid access level '%s'" % (access,))
                return

        addnicks = []
        remnicks = []
        changed = []
        mbraxx = Config.getint("Access","member")
        home = Config.get("Channels","home")
            
        for username in usernames.split():
            member = User.load(name=username, active=False)
            if member is None:
                message.alert("No such user '%s'" % (username,))
                return
            
            if type(access) is int and not member.active:
                message.reply("You should first re-activate user %s" %(member.name,))
                return
            
            if access > user.access or member.access > user.access:
                message.reply("You may not change access higher than your own")
                return

            changed.append(username)

            if type(access) == int:
                if member.active == True and member.access < mbraxx and access >= mbraxx:
                    addnicks.append(member.name)
                if member.active == True and member.access >= mbraxx and access < mbraxx:
                    message.privmsg("remuser %s %s"%(home, member.name,), Config.get("Services", "nick"))
                    remnicks.append(member.name)
    #                message.privmsg("ban %s *!*@%s.%s GTFO, EAAD"%(home, member.name, Config.get("Services", "usermask"),), Config.get("Services", "nick"))
                member.access = access
            else:
                if member.active != access and access == True and member.access >= mbraxx:
                    addnicks.append(member.name)
                if member.active != access and access == False and member.access >= mbraxx:
                    message.privmsg("remuser %s %s"%(home, member.name,), Config.get("Services", "nick"))
                    remnicks.append(member.name)
     #               message.privmsg("ban %s *!*@%s.%s GTFO, EAAD"%(home, member.name, Config.get("Services", "usermask"),), Config.get("Services", "nick"))
                member.active = access
            if not member.active:
                CUT.untrack_user(member.name)
        session.commit()
        if addnicks:
            message.privmsg("adduser %s %s 24" %(home, ",".join(addnicks),), Config.get("Services", "nick"))
            message.reply("%s ha%s been added to %s"%(", ".join(addnicks), "ve" if len(addnicks) > 1 else "s", home,))
        if remnicks:
            message.reply("%s ha%s been removed from %s"%(", ".join(remnicks), "ve" if len(remnicks) > 1 else "s", home,))
        if changed:
            message.reply("Editted user%s %s access to %s" % ("s" if len(changed) > 1 else "", ", ".join(changed), access,))
Exemplo n.º 51
0
def nick(message):
    # Someone is changing their nick
    if message.get_nick() != Merlin.nick:
        CUT.nick_change(message.get_nick(), message.get_msg())
Exemplo n.º 52
0
def quit(message):
    # Someone is quitting
    if message.get_nick() != Merlin.nick:
        # It's not the bot that's quitting
        CUT.del_nick(message.get_nick())