Esempio n. 1
0
def main(args): 
	
	"""it's time for a new swag"""
	
	if args: #if you don't know what this does, get out.
		with open(sharedVars.faq2Path, "r") as faqFile: #open the file, the path is read from sharedVars
			faqList = json.load(faqFile) #load the file as a json
		if args[0] == "remove": 
			if isAuth(sharedVars.username) >= 1: #check for auth using the new auth library
				if len(args) == 2: 
					args[1] = args[1].lower() #entry names are made lowercase to prevent confusion
					if args[1] in faqList: #check if the entry exists
						del faqList[args[1]] #delte it
						with open(sharedVars.faq2Path, "w") as faqFile: #open again
							json.dump(faqList,faqFile,indent=1) #dump json data to file
						print "Succesfully removed entry for {}.".format(args[1]) #tell the user how well we've done
					else: print "Entry not found." 
				else: printHelp() #i put the help test in a function so i could edit it faster
			else: "You're not authorized to use this command." #>2015 >not being auth
		elif args[0] == "add": 
			if len(args) >= 3:
				args[1] = args[1].lower()
				if args[1] not in faqList: #check if the entry *doesn't* exist
					entry = args[1] #then save it to another variable, because...
					del args[0] #delete the first entry in args twice,
					del args[0] #i'm sure there's a better way to do this, but i'm lazy
					content = " ".join(args) #join args into a string
					faqList[entry.lower()] = content #create the entry
					with open(sharedVars.faq2Path, "w") as faqFile:
						json.dump(faqList,faqFile,indent=1) #write to disk
					print "Succesfully added entry for {}.".format(entry)
				else: print "Entry already exists."
			else: printHelp()
		elif args[0] == "list":
			#willPrint = "List of faq entries: "
			#i = 0 ##spaghetti code
			#for entry in faqList: #iterate through every entry in faqList
			#		i += 1 #count how many we've gone through
			#		if i != len(faqList): #check if we're at the end of the list
			#			willPrint = willPrint + entry + ", " #if we aren't, append the entry plus a comma
			#		else:
			#			willPrint = willPrint + entry + "." #if we are, append the entry plus a period instead
			#print willPrint #print the list
			print 'Check out the faq list at http://amaura.tk/faq !!'
		else:
			if len(args) == 1: 
				args[0] = args[0].lower()
				if args[0] in faqList: #if args[0] is in the list of faqs
					print faqList[args[0]] #print it
				else: print "Entry not found." #else, tell the user they're dumb as shit
			else: printHelp()
		
	else:
		printHelp()
Esempio n. 2
0
def main(args):
	if args:
		if args[0] == "help":
			authHelp.helpText()
		elif args[0] == "add":
			if len(args) == 3:
				if authorized.isAuth(sharedVars.username):
					if authorized.isAuth(sharedVars.username) - int(args[2]) > 0:
						if authorized.isAuth(args[1]):
							if not authorized.isAuth(sharedVars.username) == 3 or authorized.isAuth(args[1]) == 3: 
								print "You cannot promote or demote people."
								return				
						with open(sharedVars.authorizedPath) as file:
							auths = json.load(file)
						with open(sharedVars.authorizedPath, "w") as file:
							auths[args[1]] = int(args[2])
							json.dump(auths,file,indent=1)
						print "Succesfully added {} as level {} auth.".format(args[1],args[2])
					else: print "You can't add auths on your own level or higher."
				else: print "You're not authorized to use this command."
			else: authHelp.helpText()
		elif args[0] == "remove":
			if len(args) == 2:
				if authorized.isAuth(sharedVars.username):
					if authorized.isAuth(sharedVars.username) == 3 and authorized.isAuth(args[1]) != 3:
						with open(sharedVars.authorizedPath) as file:
							auths = json.load(file)
						with open(sharedVars.authorizedPath, "w") as file:
							auths[args[1]] = 0
							json.dump(auths,file,indent=1)
						print "{} is no longer an auth.".format(args[1])
					else: print "Insufficient security cleareance. Access denied."
				else: print "You're not authorized to use this command."
		elif args[0] == "check":
			if len(args) == 2:
				if authorized.isAuth(args[1]):
					print "{} is a level {} auth.".format(args[1],authorized.isAuth(args[1]))
				else: print "{} is not an auth.".format(args[1])
		else: authHelp.helpText()
Esempio n. 3
0
def main(args):
	if args:
		if len(args) == 2:
			if isAuth(sharedVars.username) == 3:
				modname = args[0]
				link = args[1]
				os.system('wget -nv -O ~/sevabot/modules/' + modname + '.py \'' + link + '\'')
				os.system('chmod +x ~/sevabot/modules/' + modname + '.py')
				return
			else:
				print 'You\'re not authorized to use this command.'
				return
		else:
			print 'Syntax error.'
			print 'Usage: !umodule (module) (direct link)'
			return
	else:
		print 'Syntax error.'
		print 'Usage: !umodule (module) (direct link)'
		return