2015-05-26 14:21:19 -04:00
|
|
|
#
|
|
|
|
# Copyright 2015 (c) Anna Schumaker
|
|
|
|
#
|
2015-05-26 21:31:45 -04:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
path = os.path.realpath(sys.argv[0])
|
|
|
|
os.chdir(os.path.dirname(path))
|
|
|
|
|
2015-05-26 14:21:19 -04:00
|
|
|
|
|
|
|
from . import api
|
2015-05-26 14:44:59 -04:00
|
|
|
from . import auth
|
2015-05-26 15:20:12 -04:00
|
|
|
from . import channels
|
2015-06-09 09:56:55 -04:00
|
|
|
from . import groups
|
2016-11-16 15:52:42 -05:00
|
|
|
from . import im
|
2015-05-27 09:11:28 -04:00
|
|
|
from . import users
|
2015-05-26 15:20:12 -04:00
|
|
|
|
2015-05-26 14:44:59 -04:00
|
|
|
|
|
|
|
#
|
|
|
|
# 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"]
|
2016-11-16 09:39:46 -05:00
|
|
|
__URL = __auth["url"].rstrip("/")
|
2015-05-27 09:11:28 -04:00
|
|
|
__USER = users.info(__auth["user_id"])
|
2015-05-26 16:48:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
def team():
|
|
|
|
return __TEAM
|
2015-05-27 09:11:28 -04:00
|
|
|
|
2016-11-16 09:39:46 -05:00
|
|
|
def url():
|
|
|
|
return __URL
|
|
|
|
|
2015-05-27 09:11:28 -04:00
|
|
|
def user():
|
|
|
|
return __USER
|
2015-06-16 11:05:32 -04:00
|
|
|
|
|
|
|
def find_thread(thread_id):
|
2016-11-17 10:28:53 -05:00
|
|
|
for c in channels.list():
|
|
|
|
if c.id() == thread_id: return c
|
|
|
|
for g in groups.list():
|
|
|
|
if g.id() == thread_id: return g
|
|
|
|
for i in im.list():
|
|
|
|
if i.id() == thread_id: return i
|
|
|
|
return None
|