async def delete_user(self, ctx): self.log.command(f"{ctx.message.author.id}:deletemail:{getUser(ctx.message.author.id)['mail']}") await ctx.message.delete() print("Delete user request was received.") userid = str(ctx.message.author.id) if getUser(userid) != None: print(deleteUser(userid)) try: await ctx.author.send("Dear {0}, your mail was removed!".format(ctx.message.author.name)) except: await ctx.send("Dear {0}, your mail was removed!".format(ctx.message.author.name)) print("{0}'s mail was removed!".format(ctx.message.author)) return True else: try: await ctx.author.send( "Dear {0}, your have not even registered yet, please consider registering at first by using the command: ```+addmail [email protected]```".format( ctx.message.author.name)) except: await ctx.send( "Dear {0}, your have not even registered yet, please consider registering at first by using the command: ```+addmail [email protected]```".format( ctx.message.author.name)) print("{0} have not registered yet".format(ctx.message.id)) return True
async def update_mail(self, ctx, *mails): await ctx.message.delete() if len(mails) == 1: mail = mails[0] self.log.command( f"{ctx.message.author.id}:updatemail:{getUser(str(ctx.message.author.id))['mail']}:to:{mail}") # +updatemail [email protected] 1 userid = str(ctx.message.author.id) if getUser(userid) != None: try: await ctx.author.send("Your email has been updated to {0}".format(mail)) except: await ctx.send("Your email has been updated successfully!") print(updateMail(userid, mail)) return True else: try: await ctx.author.send( "This user has not registered any mails yet, please use ```+addmail [email protected]``` to create your account!") except: await ctx.send( "This user has not registered any mails yet, please use ```+addmail [email protected]``` to create your account!") return True else: try: await ctx.author.send("Dear {0}, please enter a valid mail address!".format(ctx.message.author.name)) except: await ctx.send("Dear {0}, please enter a valid mail address!".format(ctx.message.author.name))
async def add_mail(self, ctx, mail): await ctx.message.delete() ############################################# newUser = [str(ctx.message.author.id), mail] print("New User: "******"Such user already registered with the mail of {0}".format( newUserResMail)) await ctx.author.send( "Such user already registered with the mail of {0}".format( newUserResMail)) return True # User is registering for the first time else: print(addUser(newUser[0], newUser[1])) print("Mail has been added successfully!") await ctx.author.send("Your mail has been successfully added!") print("\n") return True
async def current_mail(self, ctx): self.log.command(f"{ctx.message.author.id}:mymail:{getUser(ctx.message.author.id)['mail']}") await ctx.message.delete() userid = str(ctx.message.author.id) if getUser(userid) != None: try: await ctx.author.send( "Your current saved mail to your Discord account is ```{0}``` You can update it anytime you want by using ```+updatemail [email protected]```".format( getUserMail(userid))) except: await ctx.send("You have to allow direct messages to use this feature!") print( "Your current saved mail to your Discord account is ```{0}``` You can update it anytime you want by using ```+updatemail [email protected]```".format( getUserMail(userid))) return True else: try: await ctx.author.send( "This user has not registered any mails yet, please use ```+addmail [email protected]``` to create your account") except: await ctx.send( "This user has not registered any mails yet, please use ```+addmail [email protected]``` to create your account") return True
async def chegg_answer(self, ctx, link): userid = str(ctx.message.author.id) newUserRes = getUser(userid) if newUserRes != None: if "chegg.com" in link: newUserResMail = newUserRes["mail"] await ctx.author.send( "I am searching for the answer, please give me a few seconds!" ) print("User: {0}; Link:{1}".format(ctx.message.author, link)) print(getLink(newUserResMail, str(link))) await ctx.author.send( "Dear {1}, I am sending the answer to {0}, you will get it in a few minutes!" .format(newUserResMail, ctx.message.author)) return True else: await ctx.author.send( "Dear {0}, Please use only official Chegg links, this link is not recognized!" .format(ctx.message.author)) print("Wrong link was used: {0}".format(link)) return True else: await ctx.author.send( "You have not added your email to our database, make sure to add your own email by using```+addmail [email protected]```" ) print("This user has not registered a mail to our database yet.") return True
async def chegg_answer(self, ctx, *links): await ctx.message.delete() if len(links) == 1: link = links[0] self.log.command(f"{ctx.message.author.id}:chegg:{link}") userid = str(ctx.message.author.id) newUserRes = getUser(userid) if newUserRes != None: if "chegg.com" in link: newUserResMail = newUserRes["mail"] try: await ctx.author.send("I am searching for the answer, please give me a few seconds!") except: await ctx.send("I am searching for the answer, please give me a few seconds!") print("User: {0}; Link:{1}".format(ctx.message.author, link)) print(getLink(newUserResMail, str(link))) try: await ctx.author.send( "Dear {1}, I am sending the answer to {0}, you will get it in a few minutes!".format( newUserResMail, ctx.message.author.name)) except: await ctx.send( "Dear {0}, I am sending the answer to your registered mail!".format(ctx.message.author.name)) return True else: try: await ctx.author.send( "Dear {0}, Please use only official Chegg links, this link is not recognized!".format( ctx.message.author.name)) except: await ctx.send( "Dear {0}, Please use only official Chegg links, this link is not recognized!".format( ctx.message.author.name)) print("Wrong link was used: {0}".format(link)) return True else: try: await ctx.author.send( "You have not added your email to our database, make sure to add your own email by using```+addmail [email protected]```") except: await ctx.send( "You have not added your email to our database, make sure to add your own email by using```+addmail [email protected]```") pass print(f"{ctx.message.author.id} has not registered a mail to our database yet.") return True else: try: await ctx.author.send( "Dear {0}, Please use only official Chegg links, this link is not recognized!".format( ctx.message.author.name)) except: await ctx.send( "Dear {0}, Please use only official Chegg links, this link is not recognized!".format( ctx.message.author.name))
async def update_mail(self, ctx, mail): await ctx.message.delete() userid = str(ctx.message.author.id) if getUser(userid) != None: print(updateMail(userid, mail)) await ctx.author.send( "Your email has been updated to {0}".format(mail)) return True else: await ctx.author.send( "This user has not registered any mails yet, please use ```+addmail [email protected]``` to create your account!" ) return True
async def current_mail(self, ctx): userid = str(ctx.message.author.id) if getUser(userid) != None: await ctx.author.send( "Your current saved mail to your Discord account is ```{0}``` You can update it anytime you want by using ```+updatemail [email protected]```" .format(getUserMail(userid))) print( "Your current saved mail to your Discord account is ```{0}``` You can update it anytime you want by using ```+updatemail [email protected]```" .format(getUserMail(userid))) return True else: await ctx.author.send( "This user has not registered any mails yet, please use ```+addmail [email protected]``` to create your account" ) print( "This user has not registered any mails yet, please use ```+addmail [email protected]``` to create your account" ) return True
async def chegg_answer(self, ctx, link): await ctx.message.delete() userid = str(ctx.message.author.id) newUserRes = getUser(userid) if newUserRes != None: if "chegg.com" in link: newUserResMail = newUserRes["mail"] await ctx.author.send( "I am searching for the answer, please give me a few seconds!" ) await ctx.author.send( "Dear {1}, I am sending the answer to {0}, you will get it in a few minutes!" .format(newUserResMail, ctx.message.author.name)) print("User: {0}; Link:{1}".format(ctx.message.author, link)) print(getLink(newUserResMail, str(link))) return True
async def add_mail(self, ctx, *mails): if len(mails) == 1: mail = mails[0] self.log.command(f"{ctx.message.author.id}:addmail:{mail}:") await ctx.message.delete() ############################################# newUser = [str(ctx.message.author.id), mail] print("New User: "******"Such user already registered with the mail of {0}".format(newUserResMail)) try: await ctx.author.send("Such user already registered with the mail of {0}".format(newUserResMail)) except: await ctx.send("Such user already registered with this mail address") return True # User is registering for the first time else: print(addUser(newUser[0], newUser[1])) print("Mail has been added successfully!") try: await ctx.author.send("Your mail has been successfully added!") except: await ctx.send("Your mail has been successfully added!") print("\n") return True ############################################# else: print("BBBBB") try: await ctx.author.send("Dear {0}, please enter a valid mail address!".format(ctx.message.author.name)) except: await ctx.send("Dear {0}, please enter a valid mail address!".format(ctx.message.author.name))
async def delete_user(self, ctx): print("Delete user request was received.") userid = str(ctx.message.author.id) if getUser(userid) != None: print(deleteUser(userid)) await ctx.author.send("Dear {0}, your mail was removed!".format( ctx.message.author)) print("Dear {0}, your mail was removed!".format( ctx.message.author)) return True else: await ctx.author.send( "Dear {0}, your have not even registered yet, please consider registering at first by using the command: ```+addmail [email protected]```" .format(ctx.message.author)) print( "Dear {0}, your have not even registered yet, please consider registering at first by using the command: ```+addmail [email protected]```" .format(ctx.message.author)) return True