45 lines
793 B
Python
45 lines
793 B
Python
#
|
|
# Copyright 2015 (c) Anna Schumaker
|
|
#
|
|
import sys
|
|
import os
|
|
|
|
path = os.path.realpath(sys.argv[0])
|
|
os.chdir(os.path.dirname(path))
|
|
|
|
|
|
from . import api
|
|
from . import auth
|
|
from . import channels
|
|
from . import groups
|
|
from . import users
|
|
|
|
|
|
#
|
|
# Verify connection and setup team information.
|
|
#
|
|
|
|
if api.test() == False:
|
|
print("Connection error, cannot continue.")
|
|
sys.exit(1)
|
|
|
|
__auth = auth.test()
|
|
if __auth == None:
|
|
sys.exit(1)
|
|
__TEAM = __auth["team"]
|
|
__USER = users.info(__auth["user_id"])
|
|
|
|
|
|
def team():
|
|
return __TEAM
|
|
|
|
def user():
|
|
return __USER
|
|
|
|
def find_thread(thread_id):
|
|
[ res ] = [ c for c in channels.list() if c.id() == thread_id ] or [ None ]
|
|
if res:
|
|
return res
|
|
[ res ] = [ g for g in groups.list() if g.id() == thread_id ] or [ None ]
|
|
return res
|