Skip to content

Commit

Permalink
新增指定intents的qq开放平台对接
Browse files Browse the repository at this point in the history
  • Loading branch information
lunzhiPenxil committed Dec 21, 2023
1 parent 3b9cc87 commit 400236a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
17 changes: 11 additions & 6 deletions OlivOS/adapter/qqGuild/qqGuildv2SDK.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,23 @@ class intents_T(IntEnum):


class bot_info_T(object):
def __init__(self, id=-1, access_token=None, model='private'):
def __init__(self, id=-1, access_token=None, model='private', intents=0):
self.id = id
self.access_token = access_token
self.model = model
self.intents = intents
self.debug_mode = False
self.debug_logger = None


def get_SDK_bot_info_from_Plugin_bot_info(plugin_bot_info):
res = bot_info_T(
plugin_bot_info.id,
plugin_bot_info.post_info.access_token
id = plugin_bot_info.id,
access_token = plugin_bot_info.post_info.access_token,
model = plugin_bot_info.platform.get('model', 'private'),
intents = plugin_bot_info.post_info.port
)
res.debug_mode = plugin_bot_info.debug_mode
if plugin_bot_info.platform['model'] == 'public':
res.model = 'public'
return res


Expand Down Expand Up @@ -175,14 +176,18 @@ def __init__(self, data):
payload_template.__init__(self, data, True)

class sendIdentify(payload_template):
def __init__(self, bot_info, intents=(int(intents_T.GUILDS) | int(intents_T.DIRECT_MESSAGE))):
def __init__(self, bot_info:bot_info_T, intents=(int(intents_T.GUILDS) | int(intents_T.DIRECT_MESSAGE))):
tmp_intents = intents
if bot_info.model == 'private':
tmp_intents |= int(intents_T.GUILD_MESSAGES)
#tmp_intents |= int(intents_T.QQ_MESSAGES)
elif bot_info.model == 'public':
tmp_intents |= int(intents_T.PUBLIC_GUILD_MESSAGES)
tmp_intents |= int(intents_T.PUBLIC_QQ_MESSAGES)
elif bot_info.model == 'public_guild_only':
tmp_intents |= int(intents_T.PUBLIC_GUILD_MESSAGES)
elif bot_info.model in ['private_intents', 'public_intents']:
tmp_intents = bot_info.intents
payload_template.__init__(self)
self.data.op = 2
try:
Expand Down
33 changes: 30 additions & 3 deletions OlivOS/nativeGUI/multiLoginUIAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,10 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non
'渡渡语音/Dodo/V2',
'渡渡语音/Dodo/V1',
'QQ官方/公域/V2',
'QQ官方/公域/V2/纯频道',
'QQ官方/公域/V2/指定intents',
'QQ官方/私域/V2',
'QQ官方/私域/V2/指定intents',
'QQ官方/公域/V1',
'QQ官方/私域/V1',
'米游社/大别野/公域',
Expand Down Expand Up @@ -663,11 +666,28 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non
'AppSecret': 'edit_root_Entry_Server_access_token'
}
],
'QQ官方/公域/V2/纯频道': ['qqGuild', 'qqGuildv2_link', 'public_guild_only', 'True', 'websocket', {
'AppID': 'edit_root_Entry_ID',
'AppSecret': 'edit_root_Entry_Server_access_token'
}
],
'QQ官方/公域/V2/指定intents': ['qqGuild', 'qqGuildv2_link', 'public_intents', 'True', 'websocket', {
'AppID': 'edit_root_Entry_ID',
'AppSecret': 'edit_root_Entry_Server_access_token',
'intents': 'edit_root_Entry_Server_port'
}
],
'QQ官方/私域/V2': ['qqGuild', 'qqGuildv2_link', 'private', 'True', 'websocket', {
'AppID': 'edit_root_Entry_ID',
'AppSecret': 'edit_root_Entry_Server_access_token'
}
],
'QQ官方/私域/V2/指定intents': ['qqGuild', 'qqGuildv2_link', 'private_intents', 'True', 'websocket', {
'AppID': 'edit_root_Entry_ID',
'AppSecret': 'edit_root_Entry_Server_access_token',
'intents': 'edit_root_Entry_Server_port'
}
],
'Telegram': ['telegram', 'telegram_poll', 'default', 'True', 'post', {
'TOKEN': 'edit_root_Entry_Server_access_token'
}
Expand Down Expand Up @@ -835,8 +855,11 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non
'default'
],
'qqGuildv2_link': [
'private',
'public',
'public_guild_only',
'public_intents',
'private',
'private_intents',
'default'
]
},
Expand Down Expand Up @@ -989,8 +1012,12 @@ def tree_edit_commit(self):
tmp_password = 'NONEED'
if tmp_host == '':
tmp_host = 'NONEED'
if tmp_port == '':
tmp_port = '0'
if tmp_platform_model not in [
'public_intents',
'private_intents'
]:
if tmp_port == '':
tmp_port = '0'
if tmp_platform_platform == 'mhyVila' \
and tmp_platform_sdk == 'mhyVila_link':
tmp_id = tmp_id.strip('\n')
Expand Down

0 comments on commit 400236a

Please sign in to comment.