41 lines
972 B
Python
41 lines
972 B
Python
from groupy import Client
|
|
|
|
import constants
|
|
|
|
GROUPME_CLIENT: Client = None
|
|
|
|
|
|
def init_client():
|
|
global GROUPME_CLIENT
|
|
GROUPME_CLIENT = Client.from_token(constants.GROUPME)
|
|
|
|
|
|
def get_client():
|
|
if GROUPME_CLIENT is None:
|
|
init_client()
|
|
return GROUPME_CLIENT
|
|
|
|
|
|
def get_group(group_name):
|
|
found_group = Exception("Input group not found")
|
|
if GROUPME_CLIENT is None:
|
|
init_client()
|
|
group_list = GROUPME_CLIENT.groups.list(per_page=50)
|
|
for ret_group in group_list:
|
|
if group_name.casefold() == ret_group.name.casefold():
|
|
found_group = ret_group
|
|
break
|
|
return found_group
|
|
|
|
|
|
def get_bot(bot_name):
|
|
found_bot = Exception("Input bot not found")
|
|
if GROUPME_CLIENT is None:
|
|
init_client()
|
|
bot_list = GROUPME_CLIENT.bots.list()
|
|
for ret_bot in bot_list:
|
|
if bot_name.casefold() == ret_bot.name.casefold():
|
|
found_bot = ret_bot
|
|
break
|
|
return found_bot
|