示例#1
0
文件: plugin.py 项目: AzP/sunrise
 def srunlock(self,irc,msg,args,sunriseuser):
     sundb = self.sundb
     if not sundb.userExists(sunriseuser):
         irc.reply("That user doesn't exist, Typo maybe??")
     else:
         if not sundb.isLocked(sunriseuser):
             irc.reply("This account is not locked")
         else:
             self.sundb.unlockAccount(sunriseuser)
             commands.getoutput(BOTPATH + "/plugins/SunriseAdmin/passwordexport.py")
             irc.reply("Commitaccount is unlocked now")
示例#2
0
 def srunlock(self, irc, msg, args, sunriseuser):
     sundb = self.sundb
     if not sundb.userExists(sunriseuser):
         irc.reply("That user doesn't exist, Typo maybe??")
     else:
         if not sundb.isLocked(sunriseuser):
             irc.reply("This account is not locked")
         else:
             self.sundb.unlockAccount(sunriseuser)
             commands.getoutput(BOTPATH +
                                "/plugins/SunriseAdmin/passwordexport.py")
             irc.reply("Commitaccount is unlocked now")
示例#3
0
文件: plugin.py 项目: AzP/sunrise
 def srsetpassword(self,irc,msg,args,newpass):
     if len(newpass) < 4:
         irc.reply("Pick a longer password")
     elif len(newpass) > 20:
         irc.reply("You want to remember that many letters? ;)")
     elif not re.compile("^[a-zA-Z0-9]*$").match(newpass):
         irc.reply("Only a-z, A-Z and 0-9 chars allowed")
     else:
         try:
             self.sundb.changePassword(irc.msg.nick,newpass)
             commands.getoutput(BOTPATH + "/plugins/SunriseAdmin/passwordexport.py")
             irc.reply("Successfully set your new password.")
         except PasswordChangeForbidden:
             irc.reply("You're not allowed to change your password currently."
                       " Ask an op in #gentoo-sunrise to grant it to you.")
示例#4
0
 def brainstats (self,irc,msg,args):
     if not irc.isChannel(msg.args[0]):
         irc.reply("No brains in private! (each channel have a different brain)")
         return
     out = commands.getoutput('%s %s' % (self.cmd(msg.args[0]),'-s'))
     out = out.replace ('\n',', ')
     irc.reply(out)
示例#5
0
 def srsetpassword(self, irc, msg, args, newpass):
     if len(newpass) < 4:
         irc.reply("Pick a longer password")
     elif len(newpass) > 20:
         irc.reply("You want to remember that many letters? ;)")
     elif not re.compile("^[a-zA-Z0-9]*$").match(newpass):
         irc.reply("Only a-z, A-Z and 0-9 chars allowed")
     else:
         try:
             self.sundb.changePassword(irc.msg.nick, newpass)
             commands.getoutput(BOTPATH +
                                "/plugins/SunriseAdmin/passwordexport.py")
             irc.reply("Successfully set your new password.")
         except PasswordChangeForbidden:
             irc.reply(
                 "You're not allowed to change your password currently."
                 " Ask an op in #gentoo-sunrise to grant it to you.")
示例#6
0
 def fortune(self, irc, msg, args):
     """ Display a fortune cookie """
     f = commands.getoutput("/usr/games/fortune -s")
     f.replace("\t", "    ")
     f = f.split("\n")
     for l in f:
         if l:
             irc.reply(l)
示例#7
0
 def ofortune(self, irc, msg, args):
     """ Display a possibly offensive fortune cookie """
     if not self.registryValue("offensive", msg.args[0]):
         return
     f = commands.getoutput("/usr/games/fortune -so")
     f.replace("\t", "    ")
     f = f.split("\n")
     for l in f:
         if l:
             irc.reply(l)
示例#8
0
    def brainstats (self,irc,msg,args):
        """Information about the current brain.

        """
        if not irc.isChannel(msg.args[0]):
            irc.reply("No brains in private! (each channel have a different brain)")
            return
        out = commands.getoutput('%s %s' % (self.cmd(msg.args[0]),'-s'))
        out = out.replace ('\n',', ')
        irc.reply(out)
示例#9
0
 def reply(self, irc, msg, text):
     nick = msg.nick
     channel = msg.args[0]
     text = self.sanitize(text)
     text = self.strip_nick(irc, msg, text)
     out = commands.getoutput('%s %s' % (self.cmd(msg.args[0]),'-r "%s"' % text))
     if out and out != text and out != nick and not out.startswith('DBD::SQLite::db'):
         out = out.replace('\n','').replace('\t','')
         out = out.replace(irc.nick, self.magicnick)
         out = self.add_nick(irc, msg, out)
         out = out.strip()
         if out.startswith(irc.nick):
             self.log.info("Hailo tried to output " + str(out))
             return
         if out != nick:
             irc.reply(out)
         return
     self.log.warning('Hailo tried to output: "%s"' % str(out))
示例#10
0
 def reply(self, irc, msg, text):
     nick = msg.nick
     channel = msg.args[0]
     text = self.sanitize(text)
     text = self.strip_nick(irc, msg, text)
     out = commands.getoutput('%s %s' % (self.cmd(msg.args[0]),'-r "%s"' % text))
     if out and out != text and out != nick and not out.startswith('DBD::SQLite::db'):
         out = out.replace('\n','').replace('\t','')
         out = out.replace(irc.nick, self.magicnick)
         out = self.add_nick(irc, msg, out)
         out = out.strip()
         if out.startswith(irc.nick):
             self.log.info("Hailo tried to output " + str(out))
             return
         if out != nick:
             irc.reply(out)
         return
     self.log.warning('Hailo tried to output: "%s"' % str(out))
示例#11
0
文件: plugin.py 项目: AzP/sunrise
    def changePassword(self,ircuser,password):
        self.db.execute("""DELETE FROM passwordgrant WHERE timeout<%i""" % time.time())
        result = self.cursor.execute("""SELECT sunriseuser FROM passwordgrant
            WHERE ircuser='******' AND timeout>%i""" % (ircuser,time.time()))
        row = result.fetchone()
        if not row:
            raise PasswordChangeForbidden(ircuser)
        sunriseuser = row[0] 
        if not self.userExists(sunriseuser):
            raise NoSuchUser(sunriseuser)
        if self.isLocked(sunriseuser):
            raise AccountLocked(sunriseuser)
        htpasswdout = commands.getoutput('%s -bn %s "%s"' %
                 (self.htpasswd2,sunriseuser,password))

        self.db.execute("""UPDATE sunriseusers SET password='******' WHERE
                username='******'""" % (htpasswdout.strip(),sunriseuser))
        self.db.execute("""DELETE FROM passwordgrant
                               WHERE ircuser='******' OR timeout>%i""" %
                               (ircuser,time.time()))
        self.db.commit()
示例#12
0
    def changePassword(self, ircuser, password):
        self.db.execute("""DELETE FROM passwordgrant WHERE timeout<%i""" %
                        time.time())
        result = self.cursor.execute("""SELECT sunriseuser FROM passwordgrant
            WHERE ircuser='******' AND timeout>%i""" % (ircuser, time.time()))
        row = result.fetchone()
        if not row:
            raise PasswordChangeForbidden(ircuser)
        sunriseuser = row[0]
        if not self.userExists(sunriseuser):
            raise NoSuchUser(sunriseuser)
        if self.isLocked(sunriseuser):
            raise AccountLocked(sunriseuser)
        htpasswdout = commands.getoutput(
            '%s -bn %s "%s"' % (self.htpasswd2, sunriseuser, password))

        self.db.execute("""UPDATE sunriseusers SET password='******' WHERE
                username='******'""" % (htpasswdout.strip(), sunriseuser))
        self.db.execute("""DELETE FROM passwordgrant
                               WHERE ircuser='******' OR timeout>%i""" %
                        (ircuser, time.time()))
        self.db.commit()
示例#13
0
 def learn(self, irc, msg, text):
     text = self.sanitize(text)
     text = self.strip_nick(irc, msg, text)
     commands.getoutput('%s %s' % (self.cmd(msg.args[0]), '-l "%s"' % text))
示例#14
0
 def learn(self, irc, msg, text):
     text = self.sanitize(text)
     text = self.strip_nick(irc, msg, text)
     commands.getoutput('%s %s' % (self.cmd(msg.args[0]), '-l "%s"' % text))
示例#15
0
文件: plugin.py 项目: AzP/sunrise
 def srregendb(self,irc,msg,args):
     commands.getoutput(BOTPATH + "/plugins/SunriseAdmin/passwordexport.py")
示例#16
0
 def srregendb(self, irc, msg, args):
     commands.getoutput(BOTPATH + "/plugins/SunriseAdmin/passwordexport.py")
示例#17
0
 def runShCmd(self, irc, cmd):
     import commands
     for line in commands.getoutput(cmd).splitlines():
         irc.reply("Result: " + line, prefixNick=False)
示例#18
0
 def runShCmd(self, irc, cmd):
     import commands
     for line in commands.getoutput(cmd).splitlines():
         irc.reply("Result: " + line, prefixNick=False)