cleanup some vars

master
lub 5 years ago
parent 0bcddaa5dc
commit 90458f255e

@ -21,7 +21,6 @@ async def on_event(room, event):
# automatically join invites # automatically join invites
print('joining '+room.room_id) print('joining '+room.room_id)
join = await matrix[event.source['state_key']].join(room.room_id) join = await matrix[event.source['state_key']].join(room.room_id)
print(join)
def get_blog(): def get_blog():
url = 'https://news.blizzard.com/en-us/' url = 'https://news.blizzard.com/en-us/'
html = requests.get(url).text html = requests.get(url).text
@ -86,17 +85,17 @@ async def main():
event_type_prefix = 'de.lubiland.snowstorm-matrix.' event_type_prefix = 'de.lubiland.snowstorm-matrix.'
next_batch = {} next_batch = {}
for game in device: for game in accesstoken:
# initialize new client # initialize new client
mxid = '@'+mxid_prefix+game+':'+homeserver_name mxid = '@'+mxid_prefix+game+':'+homeserver_name
config = ClientConfig(store_sync_tokens=True) config = ClientConfig(store_sync_tokens=True)
matrix[mxid] = AsyncClient(homeserver_url, matrix[mxid] = AsyncClient(homeserver_url,
config=config) config=config)
# login # login
login_response = LoginResponse(mxid, login_response = LoginResponse(mxid,
device[game]['id'], 'xxx',
device[game]['accesstoken']) accesstoken[game])
await matrix[mxid].receive_response(login_response) await matrix[mxid].receive_response(login_response)
matrix[mxid].add_event_callback(on_event, InviteEvent) matrix[mxid].add_event_callback(on_event, InviteEvent)
@ -189,13 +188,10 @@ homeserver_url = environ['HOMESERVER_URL']
mxid_prefix = environ['MXID_PREFIX'] mxid_prefix = environ['MXID_PREFIX']
admin_room = environ['ADMIN_ROOM'] admin_room = environ['ADMIN_ROOM']
device = {} accesstoken = {}
for var in environ:
if (game := re.match('^DEVICEID_([A-Z]*)$', var)) is not None:
device[game[1].lower()] = {'id': environ[var]}
for var in environ: for var in environ:
if (game := re.match('^ACCESSTOKEN_([A-Z]*)_FILE$', var)) is not None: if (game := re.match('^ACCESSTOKEN_([A-Z]*)_FILE$', var)) is not None:
device[game[1].lower()]['accesstoken'] = get_accesstoken_from_file(environ[var]) accesstoken[game[1].lower()] = get_accesstoken_from_file(environ[var])

Loading…
Cancel
Save