MCPcopy
hub / github.com/tinode/chat / on_login

Function on_login

chatbot/python/chatbot.py:307–332  ·  view source on GitHub ↗
(cookie_file_name, params)

Source from the content-addressed store, hash-verified

305 return schema, secret
306
307def on_login(cookie_file_name, params):
308 global botUID
309 client_post(subscribe('me'))
310
311 """Save authentication token to file"""
312 if params == None or cookie_file_name == None:
313 return
314
315 if 'user' in params:
316 botUID = params['user'].decode("ascii")[1:-1]
317
318 # Protobuf map 'params' is not a python object or dictionary. Convert it.
319 nice = {'schema': 'token'}
320 for key_in in params:
321 if key_in == 'token':
322 key_out = 'secret'
323 else:
324 key_out = key_in
325 nice[key_out] = json.loads(params[key_in].decode('utf-8'))
326
327 try:
328 cookie = open(cookie_file_name, 'w')
329 json.dump(nice, cookie)
330 cookie.close()
331 except Exception as err:
332 log("Failed to save authentication cookie", err)
333
334def load_quotes(file_name):
335 with open(file_name) as f:

Callers 1

loginFunction · 0.85

Calls 4

client_postFunction · 0.85
subscribeFunction · 0.85
logFunction · 0.85
dumpMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…