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