diff --git a/config.py b/config.py
index 5ca7780..ca97ce3 100644
--- a/config.py
+++ b/config.py
@@ -23,10 +23,11 @@ class RSSConfig:
self.show_Content_title = True
self.show_content = True
self.send_media = True
+ self.display_entry_link = False
if d is not None:
for k in d.keys():
if hasattr(self, k):
setattr(self, k, d[k])
def toJson(self):
- return dumps({'disable_web_page_preview': self.disable_web_page_preview, 'show_RSS_title': self.show_RSS_title, 'show_Content_title': self.show_Content_title, 'show_content': self.show_content, 'send_media': self.send_media}, ensure_ascii=False)
+ return dumps({'disable_web_page_preview': self.disable_web_page_preview, 'show_RSS_title': self.show_RSS_title, 'show_Content_title': self.show_Content_title, 'show_content': self.show_content, 'send_media': self.send_media, 'display_entry_link': self.display_entry_link}, ensure_ascii=False)
diff --git a/rssbot.py b/rssbot.py
index fafc533..ebdf7c4 100644
--- a/rssbot.py
+++ b/rssbot.py
@@ -69,6 +69,7 @@ def getMediaInfo(m: dict, config: RSSConfig = RSSConfig()) -> str:
s = f"{s}\n显示内容标题:{config.show_Content_title}"
s = f"{s}\n显示内容:{config.show_content}"
s = f"{s}\n发送媒体:{config.send_media}"
+ s = f"{s}\n单独一行显示链接:{config.display_entry_link}"
return s
@@ -85,6 +86,7 @@ class InlineKeyBoardCallBack(Enum):
ShowContentTitle = 8
ShowContent = 9
SendMedia = 10
+ DisplayEntryLink = 11
def getInlineKeyBoardWhenRSS(hashd: str, m: dict) -> dict:
@@ -138,6 +140,10 @@ def getInlineKeyBoardWhenRSS2(hashd: str, config: RSSConfig) -> str:
temp = '禁用发送媒体' if config.send_media else '启用发送媒体'
d[i].append(
{'text': temp, 'callback_data': f'0,{hashd},{InlineKeyBoardCallBack.SendMedia.value}'})
+ temp = '禁用单独一行显示链接' if config.display_entry_link else '启用单独一行显示链接'
+ d[i].append({'text': temp, 'callback_data': f'0,{hashd},{InlineKeyBoardCallBack.DisplayEntryLink.value}'})
+ d.append([])
+ i += 1
d[i].append(
{'text': '返回', 'callback_data': f'0,{hashd},{InlineKeyBoardCallBack.BackToNormalPage.value}'})
return {'inline_keyboard': d}
@@ -180,8 +186,11 @@ class main:
text.addtotext(f"{meta['title']}")
if config.show_Content_title and 'title' in content and content['title'] is not None and content['title'] != '':
if 'link' in content and content['link'] is not None and content['link'] != '':
- text.addtotext(
- f"""{content['title']}""")
+ if not config.display_entry_link:
+ text += f"""{content['title']}"""
+ else:
+ text += f"{content['title']}"
+ text += f"""{escape(content['link'])}"""
else:
text.addtotext(f"{content['title']}")
elif 'link' in content and content['link'] is not None and content['link'] != '':
@@ -1265,6 +1274,19 @@ class callbackQueryHandle(Thread):
self._main._request("editMessageText", "post", json=di)
self.answer()
return
+ elif self._inlineKeyBoardCommand == InlineKeyBoardCallBack.DisplayEntryLink:
+ self._rssMeta.config.display_entry_link = not self._rssMeta.config.display_entry_link
+ di = {'chat_id': self._rssMeta.chatId,
+ 'message_id': self._rssMeta.messageId}
+ di['text'] = getMediaInfo(
+ self._rssMeta.meta, self._rssMeta.config)
+ di['parse_mode'] = 'HTML'
+ di['disable_web_page_preview'] = True
+ di['reply_markup'] = getInlineKeyBoardWhenRSS2(
+ self._hashd, self._rssMeta.config)
+ self._main._request("editMessageText", "post", json=di)
+ self.answer()
+ return
elif self._loc == 1:
chatId = int(self._inputList[1])
self._inlineKeyBoardForRSSListCommand = InlineKeyBoardForRSSList(
@@ -1412,7 +1434,7 @@ class callbackQueryHandle(Thread):
self._main._request("editMessageText", "post", json=di)
self.answer()
return
- elif self._inlineKeyBoardForRSSListCommand in [InlineKeyBoardForRSSList.DisableWebPagePreview, InlineKeyBoardForRSSList.ShowRSSTitle, InlineKeyBoardForRSSList.ShowContentTitle, InlineKeyBoardForRSSList.ShowContent, InlineKeyBoardForRSSList.SendMedia]:
+ elif self._inlineKeyBoardForRSSListCommand in [InlineKeyBoardForRSSList.DisableWebPagePreview, InlineKeyBoardForRSSList.ShowRSSTitle, InlineKeyBoardForRSSList.ShowContentTitle, InlineKeyBoardForRSSList.ShowContent, InlineKeyBoardForRSSList.SendMedia, InlineKeyBoardForRSSList.DisplayEntryLink]:
di = {'chat_id': self._data['message']['chat']['id'],
'message_id': self._data['message']['message_id']}
rssList = self._main._db.getRSSListByChatId(chatId)
@@ -1435,6 +1457,8 @@ class callbackQueryHandle(Thread):
config.show_content = not config.show_content
elif self._inlineKeyBoardForRSSListCommand == InlineKeyBoardForRSSList.SendMedia:
config.send_media = not config.send_media
+ elif self._inlineKeyBoardForRSSListCommand == InlineKeyBoardForRSSList.DisplayEntryLink:
+ config.display_entry_link = not config.display_entry_link
updated = self._main._db.updateChatConfig(chatEntry)
if updated:
self.answer('修改设置成功')
diff --git a/rsslist.py b/rsslist.py
index 4e76062..cb4b8ac 100644
--- a/rsslist.py
+++ b/rsslist.py
@@ -41,6 +41,7 @@ class InlineKeyBoardForRSSList(Enum):
ShowContent = 15
SendMedia = 16
ForceUpdate = 17
+ DisplayEntryLink = 18
def getTextContentForRSSInList(rssEntry: RSSEntry, s: settings) -> str:
@@ -70,6 +71,7 @@ def getTextContentForRSSInList(rssEntry: RSSEntry, s: settings) -> str:
text.addtotext(f"显示内容标题:{config.show_Content_title}")
text.addtotext(f"显示内容:{config.show_content}")
text.addtotext(f"发送媒体:{config.send_media}")
+ text += f"单独一行显示链接:{config.display_entry_link}"
return text.tostr()
@@ -186,6 +188,8 @@ def getInlineKeyBoardForRSSSettingsInList(chatId: int, rssEntry: RSSEntry, index
temp = '禁用发送媒体' if config.send_media else '启用发送媒体'
d[i].append(
{'text': temp, 'callback_data': f'1,{chatId},{InlineKeyBoardForRSSList.SendMedia.value},{index},{rssEntry.id}'})
+ temp = '禁用单独一行显示链接' if config.display_entry_link else '启用单独一行显示链接'
+ d[i].append({'text': 'temp', 'callback_data': f'1,{chatId},{InlineKeyBoardForRSSList.DisplayEntryLink.value},{index},{rssEntry.id}'})
d.append([])
i = i + 1
d[i].append(