Exemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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.º 8
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)