aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorPhilip Paquette <pcpaquette@gmail.com>2019-09-11 17:34:18 -0400
committerPhilip Paquette <pcpaquette@gmail.com>2019-09-14 18:18:53 -0400
commit96c5441ac652bb2e7e396381d3fb2e0964ad68da (patch)
tree29a582fd80553b47ea25d25908f2b624ae5c54c8 /README.md
parent57c9c33ae756cc17af223f6bc671191684ee9c9b (diff)
channel.authenticate() - Deprecated argument 'create_user'
- User is now created by default if it doesn't exist on the server - Unless the server prevents new registrations
Diffstat (limited to 'README.md')
-rw-r--r--README.md12
1 files changed, 2 insertions, 10 deletions
diff --git a/README.md b/README.md
index 61a11fd..247893e 100644
--- a/README.md
+++ b/README.md
@@ -118,24 +118,16 @@ from diplomacy.utils import exceptions
POWERS = ['AUSTRIA', 'ENGLAND', 'FRANCE', 'GERMANY', 'ITALY', 'RUSSIA', 'TURKEY']
-async def login(connection, username, password):
- """ Logins to the server """
- try:
- channel = await connection.authenticate(username, password, create_user=True)
- except exceptions.DiplomacyException:
- channel = await connection.authenticate(username, password, create_user=False)
- return channel
-
async def create_game(game_id, hostname='localhost', port=8432):
""" Creates a game on the server """
connection = await connect(hostname, port)
- channel = await login(connection, 'random_user', 'password')
+ channel = await connection.authenticate('random_user', 'password')
await channel.create_game(game_id=game_id, rules={'REAL_TIME', 'NO_DEADLINE', 'POWER_CHOICE'})
async def play(game_id, power_name, hostname='localhost', port=8432):
""" Play as the specified power """
connection = await connect(hostname, port)
- channel = await login(connection, 'user_' + power_name, 'password')
+ channel = await connection.authenticate('user_' + power_name, 'password')
# Waiting for the game, then joining it
while not (await channel.list_games(game_id=game_id)):