コード例 #1
0
ファイル: loadable.py プロジェクト: munin/merlin
 def run(self, message):
     m = self.match(message, self.commandre)
     if m is None:
         if self.match(message, self.helpre) is not None:
             self.help(message)
         return
     command = m.group(1)
     
     try:
         route, subcommand, user, params = self.router(message, command)
         
         route(message, user, params)
         
         session = Session()
         session.add(Command(command_prefix = message.get_prefix(),
                             command = self.name,
                             subcommand = subcommand,
                             command_parameters = message.get_msg()[len(self.name)+1:].strip(),
                             nick = message.get_nick(),
                             username = "" if user is True else user.name,
                             hostname = message.get_hostmask(),
                             target = message.get_chan() if message.in_chan() else message.get_nick(),))
         session.commit()
         session.close()
         
     except PNickParseError:
         message.alert(self.PParseError)
     except UserError:
         message.alert(self.AccessError)
     except PrefError:
         message.alert(self.PrefError)
     except ChanParseError, e:
         message.alert(self.ChanError%e)
コード例 #2
0
ファイル: loadable.py プロジェクト: Go3Media/merlin
 def run(self, message):
     m = self.match(message, self.commandre)
     if m is None:
         if self.match(message, self.helpre) is not None:
             self.help(message)
         return
     command = m.group(1)
     try:
         access = self.check_access(message)
         if access is None:
             raise UserError
         params = self.check_params(command)
         if params is None:
             raise ParseError
         self.execute(message, access, params)
         session = Session()
         session.add(Command(command_prefix = message.get_prefix(),
                             command = self.name,
                             command_parameters = message.get_msg()[len(self.name)+1:],
                             nick = message.get_nick(),
                             username = "" if access is True else access.name,
                             hostname = message.get_hostmask(),
                             target = message.get_chan() if message.in_chan() else message.get_nick(),))
         session.commit()
     except PNickParseError:
         message.alert(self.PParseError)
     except UserError:
         message.alert(self.AccessError)
     except PrefError:
         message.alert(self.PrefError)
     except ChanParseError, e:
         message.alert(self.ChanError%e)
コード例 #3
0
ファイル: loadable.py プロジェクト: munin/merlin
 def run(self, request, **kwargs):
     user = request.session.user
     
     try:
         if self.check_access(user) is not True:
             raise UserError
         
         response = self.execute(request, user, **kwargs)
         
         session = Session()
         session.add(PageView(page = self.name,
                              full_request = request.get_full_path(),
                              username = user.name,
                              session = request.session.key,
                              hostname = request.get_host(),))
         session.commit()
         
         return response
     
     except UserError:
         return render("login.tpl", request, msg="F**k off.")