From 2f7be8f233cb65d8fe0824151f70dcb534269063 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Wed, 5 May 2021 11:21:29 +0800 Subject: [PATCH] set max items in mediaGroup to 10 --- rssbot.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rssbot.py b/rssbot.py index 33aec0c..a73702a 100644 --- a/rssbot.py +++ b/rssbot.py @@ -39,6 +39,9 @@ from rssbotlib import loadRSSBotLib, AddVideoInfoResult from time import sleep +MAX_ITEM_IN_MEDIA_GROUP = 10 + + def getMediaInfo(m: dict, config: RSSConfig = RSSConfig()) -> str: s = '' if 'link' in m: @@ -355,7 +358,7 @@ class main: di3 = {} di['media'] = [] for i in content['imgList']: - if ind % 9 == 0 and ind != 0: + if ind % MAX_ITEM_IN_MEDIA_GROUP == 0 and ind != 0: for _ in range(self._setting._maxRetryCount + 1): if not self._setting._downloadMediaFile or self._setting._sendFileURLScheme: re = self._request('sendMediaGroup', 'post', json=di) @@ -386,13 +389,13 @@ class main: di2['media'] = f'attach://file{ind2}' di3[f'file{ind2}'] = (fileEntry._fullfn, fileEntry._f) ind2 = ind2 + 1 - if ind % 9 == 0: + if ind % MAX_ITEM_IN_MEDIA_GROUP == 0: di2['caption'] = text.tostr(1024) di2['parse_mode'] = 'HTML' di['media'].append(di2) ind = ind + 1 for i in content['videoList']: - if ind % 9 == 0 and ind != 0: + if ind % MAX_ITEM_IN_MEDIA_GROUP == 0 and ind != 0: for _ in range(self._setting._maxRetryCount + 1): if not self._setting._downloadMediaFile or self._setting._sendFileURLScheme: re = self._request('sendMediaGroup', 'post', json=di) @@ -438,7 +441,7 @@ class main: di3[f'file{ind2}'] = ( fileEntry._fullfn, fileEntry._f) ind2 = ind2 + 1 - if ind % 9 == 0: + if ind % MAX_ITEM_IN_MEDIA_GROUP == 0: di2['caption'] = text.tostr(1024) di2['parse_mode'] = 'HTML' if self._rssbotLib is not None: