This commit is contained in:
Richard Chien 2017-01-11 14:16:51 +08:00
parent 9c794334c1
commit 1040b600d6
3 changed files with 7 additions and 7 deletions

View File

@ -73,16 +73,16 @@ class ApiClient:
pass
return None
def get_group_info(self, via):
url = self._api_url(via)
def get_group_info(self, ctx_msg: dict):
url = self._api_url(ctx_msg.get('via'))
if url:
try:
return requests.get(url + '/get_group_info')
except requests.exceptions.ConnectionError:
return None
def get_user_info(self, via):
url = self._api_url(via)
def get_user_info(self, ctx_msg: dict):
url = self._api_url(ctx_msg.get('via'))
if url:
try:
return requests.get(url + '/get_user_info')

View File

@ -174,7 +174,7 @@ class CommandRegistry:
allowed_roles = allowed_roles.intersection({'owner'})
groups = list(filter(
lambda g: g.get('group_uid') == ctx_msg.get('group_uid'),
api.get_group_info(via='qq').json()
api.get_group_info(ctx_msg).json()
))
if len(groups) <= 0 or 'member' not in groups[0]:
# This is strange, not likely happens

View File

@ -16,10 +16,10 @@ def _split_at_xiaokai(ctx_msg):
return False
at_me = '@' + my_group_nick
if not text.startswith(at_me):
user_info = api.get_user_info().json()
user_info = api.get_user_info(ctx_msg).json()
if not user_info:
return False
my_nick = user_info.get('nick')
my_nick = user_info.get('name')
if not my_nick:
return False
at_me = '@' + my_nick