contrib/email_login.py code cleanup, update markup

Line breaks at more visual locations
This commit is contained in:
BlauFeuer 2017-02-16 21:28:36 -05:00 committed by GitHub
parent eef348b4ba
commit 78ff1f39a0

View file

@ -54,7 +54,8 @@ except Exception:
# malformed connection screen or no screen given # malformed connection screen or no screen given
pass pass
if not CONNECTION_SCREEN: if not CONNECTION_SCREEN:
CONNECTION_SCREEN = "\nEvennia: Error in CONNECTION_SCREEN MODULE (randomly picked connection screen variable is not a string). \nEnter 'help' for aid." CONNECTION_SCREEN = "\nEvennia: Error in CONNECTION_SCREEN MODULE" \
" (randomly picked connection screen variable is not a string). \nEnter 'help' for aid."
class CmdUnconnectedConnect(MuxCommand): class CmdUnconnectedConnect(MuxCommand):
@ -108,8 +109,8 @@ class CmdUnconnectedConnect(MuxCommand):
or or
any(tup[2].match(session.address[0]) for tup in bans if tup[2])): any(tup[2].match(session.address[0]) for tup in bans if tup[2])):
# this is a banned IP or name! # this is a banned IP or name!
string = "{rYou have been banned and cannot continue from here." string = "|rYou have been banned and cannot continue from here."
string += "\nIf you feel this ban is in error, please email an admin.{x" string += "\nIf you feel this ban is in error, please email an admin.|x"
session.msg(string) session.msg(string)
session.execute_cmd("quit") session.execute_cmd("quit")
return return
@ -117,6 +118,7 @@ class CmdUnconnectedConnect(MuxCommand):
# actually do the login. This will call all hooks. # actually do the login. This will call all hooks.
session.sessionhandler.login(session, player) session.sessionhandler.login(session, player)
class CmdUnconnectedCreate(MuxCommand): class CmdUnconnectedCreate(MuxCommand):
""" """
Create a new account. Create a new account.
@ -156,7 +158,7 @@ class CmdUnconnectedCreate(MuxCommand):
self.playerinfo = (playername, email, password) self.playerinfo = (playername, email, password)
def func(self): def func(self):
"Do checks and create account" """Do checks and create account"""
session = self.caller session = self.caller
@ -167,8 +169,8 @@ class CmdUnconnectedCreate(MuxCommand):
session.msg(string) session.msg(string)
return return
if not re.findall('^[\w. @+-]+$', playername) or not (0 < len(playername) <= 30): if not re.findall('^[\w. @+-]+$', playername) or not (0 < len(playername) <= 30):
session.msg("\n\r Playername can be max 30 characters, or less. Letters, spaces, dig\ session.msg("\n\r Playername can be max 30 characters, or less. Letters, spaces,"
its and @/./+/-/_ only.") # this echoes the restrictions made by django's auth module. " digits and @/./+/-/_ only.") # this echoes the restrictions made by django's auth module.
return return
if not email or not password: if not email or not password:
session.msg("\n\r You have to supply an e-mail address followed by a password.") session.msg("\n\r You have to supply an e-mail address followed by a password.")
@ -205,11 +207,11 @@ its and @/./+/-/_ only.") # this echoes the restrictions made by django's auth m
permissions = settings.PERMISSION_PLAYER_DEFAULT permissions = settings.PERMISSION_PLAYER_DEFAULT
try: try:
new_player = create.create_player(playername, email, password, new_player = create.create_player(playername, email, password, permissions=permissions)
permissions=permissions)
except Exception as e: except Exception as e:
session.msg("There was an error creating the default Player/Character:\n%s\n If this problem persists, contact an admin." % e) session.msg("There was an error creating the default Player/Character:\n%s\n"
" If this problem persists, contact an admin." % e)
logger.log_trace() logger.log_trace()
return return
@ -260,6 +262,7 @@ its and @/./+/-/_ only.") # this echoes the restrictions made by django's auth m
session.msg("An error occurred. Please e-mail an admin if the problem persists.") session.msg("An error occurred. Please e-mail an admin if the problem persists.")
logger.log_trace() logger.log_trace()
class CmdUnconnectedQuit(MuxCommand): class CmdUnconnectedQuit(MuxCommand):
""" """
We maintain a different version of the `quit` command We maintain a different version of the `quit` command
@ -271,7 +274,7 @@ class CmdUnconnectedQuit(MuxCommand):
locks = "cmd:all()" locks = "cmd:all()"
def func(self): def func(self):
"Simply close the connection." """Simply close the connection."""
session = self.caller session = self.caller
session.msg("Good bye! Disconnecting ...") session.msg("Good bye! Disconnecting ...")
session.session_disconnect() session.session_disconnect()
@ -289,7 +292,7 @@ class CmdUnconnectedLook(MuxCommand):
locks = "cmd:all()" locks = "cmd:all()"
def func(self): def func(self):
"Show the connect screen." """Show the connect screen."""
self.caller.msg(CONNECTION_SCREEN) self.caller.msg(CONNECTION_SCREEN)
@ -303,34 +306,34 @@ class CmdUnconnectedHelp(MuxCommand):
locks = "cmd:all()" locks = "cmd:all()"
def func(self): def func(self):
"Shows help" """Shows help"""
string = \ string = \
""" """
You are not yet logged into the game. Commands available at this point: You are not yet logged into the game. Commands available at this point:
{wcreate, connect, look, help, quit{n |wcreate, connect, look, help, quit|n
To login to the system, you need to do one of the following: To login to the system, you need to do one of the following:
{w1){n If you have no previous account, you need to use the 'create' |w1)|n If you have no previous account, you need to use the 'create'
command like this: command like this:
{wcreate "Anna the Barbarian" anna@myemail.com c67jHL8p{n |wcreate "Anna the Barbarian" anna@myemail.com c67jHL8p|n
It's always a good idea (not only here, but everywhere on the net) It's always a good idea (not only here, but everywhere on the net)
to not use a regular word for your password. Make it longer than to not use a regular word for your password. Make it longer than
3 characters (ideally 6 or more) and mix numbers and capitalization 3 characters (ideally 6 or more) and mix numbers and capitalization
into it. into it.
{w2){n If you have an account already, either because you just created |w2)|n If you have an account already, either because you just created
one in {w1){n above or you are returning, use the 'connect' command: one in |w1)|n above or you are returning, use the 'connect' command:
{wconnect anna@myemail.com c67jHL8p{n |wconnect anna@myemail.com c67jHL8p|n
This should log you in. Run {whelp{n again once you're logged in This should log you in. Run |whelp|n again once you're logged in
to get more aid. Hope you enjoy your stay! to get more aid. Hope you enjoy your stay!
You can use the {wlook{n command if you want to see the connect screen again. You can use the |wlook|n command if you want to see the connect screen again.
""" """
self.caller.msg(string) self.caller.msg(string)
@ -345,7 +348,7 @@ class UnloggedinCmdSet(CmdSet):
priority = 0 priority = 0
def at_cmdset_creation(self): def at_cmdset_creation(self):
"Populate the cmdset" """Populate the cmdset"""
self.add(CmdUnconnectedConnect()) self.add(CmdUnconnectedConnect())
self.add(CmdUnconnectedCreate()) self.add(CmdUnconnectedCreate())
self.add(CmdUnconnectedQuit()) self.add(CmdUnconnectedQuit())