Skip to content
MakeMeASandwich edited this page Oct 27, 2015 · 2 revisions

Python scripting cheatsheet

Don't try to block the main, use tgl.set_on_loop(on_loop) instead:

def on_loop():
  do_something()
  send_a_message()

tgl.set_on_loop(on_loop)

To check whether a user is online, update the contact list and compare user_status["when"] with the current time. If the status is in the future, the contact is online right now.

then = peer.user_status["when"]
now = datetime.datetime.now()
if then > now:
  # peer is online
  greet_peer()
Clone this wiki locally