Пример #1
0
 def __call__(self, user, prot, args, session):
     hash = models.Authen.gen_authen_code(user.jid, session)
     link = "%s/%s" % (config.AUTH_URL, hash)
     message = "Please use the link below to authorise the bot for fetching your douban data:\n%s" % link
     try:
         prot.send_plain(user.jid, message)
         user.auth = False
         user.key = None
         user.secret = None
         session.add(user)
         session.commit()
         scheduling.disable_user(user.jid)
     except:
         log.msg(":(, reauth user: user.jid failed")
Пример #2
0
 def __call__(self, user, prot, args, session):
     hash = models.Authen.gen_authen_code(user.jid, session)
     link = "%s/%s" %(config.AUTH_URL, hash)
     message = "Please use the link below to authorise the bot for fetching your douban data:\n%s" %link
     try:
         prot.send_plain(user.jid, message)
         user.auth = False
         user.key = None
         user.secret = None 
         session.add(user)
         session.commit()
         scheduling.disable_user(user.jid)
     except:
         log.msg(":(, reauth user: user.jid failed")
Пример #3
0
 def _invalid(self, e, admin, jid, uid, prot, session, u):
     err = e.getErrorMessage()
     if err.find('401') == -1:
         prot.send_plain(admin, "Access token validation of %s on behalf of %s failed, %s" % (jid, uid, err))
     else:
         msg = "Access token of %s on behalf of %s is invalid." % (jid, uid)
         prot.send_plain(admin, msg + "\nSending auth request to " + jid)
         msg = msg + " %s" % models.Authen.auth_message(jid)
         prot.send_plain(jid, msg)
         scheduling.disable_user(jid)
         try:
             u.auth = False
             session.add(u)
             session.commit()
         except:
             log.err()
Пример #4
0
    def __call__(self, user, prot, args, session):
        if not args:
            prot.send_plain(user.jid, "How long would you like me to be quiet?")
            return
        m = {'m': 1, 'h': 60, 'd': 1440}
        parts=args.split(' ', 1)
        time=parts[0]
        match = re.compile(r'(\d+)([hmd])').match(time)
        if match:
            t = int(match.groups()[0]) * m[match.groups()[1]]
            u=datetime.datetime.now() + datetime.timedelta(minutes=t)

            user.quiet_until=u
            scheduling.disable_user(user.jid)
            prot.send_plain(user.jid,
                "You won't hear from me again until %s" % str(u))
        else:
            prot.send_plain(user.jid, "I don't understand how long you want "
                "me to be quiet.  Try: quiet 5m")
Пример #5
0
 def _invalid(self, e, admin, jid, uid, prot, session, u):
     err = e.getErrorMessage()
     if err.find('401') == -1:
         prot.send_plain(
             admin,
             "Access token validation of %s on behalf of %s failed, %s" %
             (jid, uid, err))
     else:
         msg = "Access token of %s on behalf of %s is invalid." % (jid, uid)
         prot.send_plain(admin, msg + "\nSending auth request to " + jid)
         msg = msg + " %s" % models.Authen.auth_message(jid)
         prot.send_plain(jid, msg)
         scheduling.disable_user(jid)
         try:
             u.auth = False
             session.add(u)
             session.commit()
         except:
             log.err()
Пример #6
0
    def __call__(self, user, prot, args, session):
        if not args:
            prot.send_plain(user.jid,
                            "How long would you like me to be quiet?")
            return
        m = {'m': 1, 'h': 60, 'd': 1440}
        parts = args.split(' ', 1)
        time = parts[0]
        match = re.compile(r'(\d+)([hmd])').match(time)
        if match:
            t = int(match.groups()[0]) * m[match.groups()[1]]
            u = datetime.datetime.now() + datetime.timedelta(minutes=t)

            user.quiet_until = u
            scheduling.disable_user(user.jid)
            prot.send_plain(user.jid,
                            "You won't hear from me again until %s" % str(u))
        else:
            prot.send_plain(
                user.jid, "I don't understand how long you want "
                "me to be quiet.  Try: quiet 5m")
Пример #7
0
 def __call__(self, user, prot, args, session):
     user.active=False
     scheduling.disable_user(user.jid)
     prot.send_plain(user.jid, "Notify disabled.")
Пример #8
0
 def worked(stuff):
     scheduling.disable_user(user.jid)
     prot.send_plain(user.jid, "Disabled tracks.")
Пример #9
0
 def __call__(self, user, prot, args, session):
     user.active = False
     scheduling.disable_user(user.jid)
     prot.send_plain(user.jid, "Notify disabled.")