-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
67 lines (58 loc) · 1.96 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env
import libfurc
import argparse
import getpass
import asyncio
client = libfurc.Client()
@client.on("Login")
async def login(success):
if success:
print("Logged in!")
else:
print("Connection failed!")
@client.on("Message")
async def message(msg):
print(msg)
@client.on("*")
async def t(name, *args, **kwargs):
print(name, *args)
async def main():
parser = argparse.ArgumentParser(description="Simple client test")
parser.add_argument("-a", "--account", default=None, help="Account name (Typically email address)")
parser.add_argument("-p", "--password", default=None, help="Account password")
parser.add_argument("-c", "--character", default=None, help="Character name (Leave blank for listing)")
args = parser.parse_args()
if not args.account:
args.account = input("Username / email: ")
if not args.password:
args.password = getpass.getpass()
try:
account = libfurc.Account.login(args.account, args.password)
except libfurc.exceptions.LoginError as e:
print(e)
character = None
if not args.character or not character:
while True:
print("Characters on {} (#{}):".format(account.email, account.id))
for i, character in enumerate(account.characters):
print(" {}. {}".format(i+1, character.name))
cn = input("Character name or ID: ")
try:
character = account.characters[int(cn)-1]
except ValueError:
character = account.findCharacter(cn)
if character:
break
else:
print("Can't find that character")
if not character:
print("Can't find that character!")
exit()
motd = await client.connect()
if not motd:
print("Failed to connect. Is the address correct?")
return
print(motd)
await client.login(character)
await client.run()
asyncio.run(main())