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")
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")
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.")
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)
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.")
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)
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)
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)
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))
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()
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()
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))
def srregendb(self,irc,msg,args): commands.getoutput(BOTPATH + "/plugins/SunriseAdmin/passwordexport.py")
def srregendb(self, irc, msg, args): commands.getoutput(BOTPATH + "/plugins/SunriseAdmin/passwordexport.py")
def runShCmd(self, irc, cmd): import commands for line in commands.getoutput(cmd).splitlines(): irc.reply("Result: " + line, prefixNick=False)