diff --git a/readset.py b/readset.py
index 0efe3ae..1c4e876 100644
--- a/readset.py
+++ b/readset.py
@@ -34,3 +34,4 @@ class settings:
self._maxTTL = int(d['maxTTL']) if 'maxTTL' in d and d['maxTTL'].isnumeric(
) and int(d['maxTTL']) >= self._minTTL else max(1440, self._minTTL)
self._maxRetryCount = int(d['maxRetryCount']) if 'maxRetryCount' in d and d['maxRetryCount'].isnumeric() and int(d['maxRetryCount']) >= 0 else 3
+ self._telegramBotApiServer = d['telegramBotApiServer'] if 'telegramBotApiServer' in d else 'https://api.telegram.org'
diff --git a/rssbot.py b/rssbot.py
index 21826ff..8a36476 100644
--- a/rssbot.py
+++ b/rssbot.py
@@ -135,10 +135,10 @@ class main:
def __init__(self):
pass
- def _request(self, methodName: str, HTTPMethod: str = 'get', data: dict = None, json: dict = None, files: dict = None, returnType: str = 'json'):
+ def _request(self, methodName: str, HTTPMethod: str = 'get', data: dict = None, json: dict = None, files: dict = None, returnType: str = 'json', telegramBotApiServer: str = None):
try:
r = self._r.request(
- HTTPMethod, f'https://api.telegram.org/bot{self._setting._token}/{methodName}', data=data, json=json, files=files)
+ HTTPMethod, f'{self._telegramBotApiServer if telegramBotApiServer is None else telegramBotApiServer}/bot{self._setting._token}/{methodName}', data=data, json=json, files=files)
if r.status_code != 200:
return None
if returnType == 'json':
@@ -240,6 +240,10 @@ class main:
if self._setting._token is None:
print('没有机器人token')
return -1
+ self._telegramBotApiServer = self._setting._telegramBotApiServer
+ if self._telegramBotApiServer != 'https://api.telegram.org':
+ self._request("logOut", "post",
+ telegramBotApiServer="https://api.telegram.org")
self._db = database(self)
if not exists('settings.txt'):
print('找不到settings.txt')
diff --git a/rsslist.py b/rsslist.py
index 5fdc7ae..962fc02 100644
--- a/rsslist.py
+++ b/rsslist.py
@@ -30,11 +30,15 @@ class InlineKeyBoardForRSSList(Enum):
Close = 4
Content = 5
BackToList = 6
+ Unsubscribe = 7
+ ConfirmUnsubscribe = 8
+ CancleUnsubscribe = 9
def getTextContentForRSSInList(rssEntry: RSSEntry) -> str:
text = textc()
- text.addtotext(f"""{rssEntry.title}""")
+ text.addtotext(
+ f"""{escape(rssEntry.title)}""")
temp = '更新间隔:未知' if rssEntry.interval is None else f'更新间隔:{rssEntry.interval}分'
text.addtotext(temp)
temp = '上次更新时间:未知' if rssEntry.lastupdatetime is None or rssEntry.lastupdatetime < 0 else f'上次更新时间:{timeToStr(rssEntry.lastupdatetime)}'
@@ -51,6 +55,10 @@ def getTextContentForRSSInList(rssEntry: RSSEntry) -> str:
return text.tostr()
+def getTextContentForRSSUnsubscribeInList(rssEntry: RSSEntry) -> str:
+ return f"""你是否要取消订阅{escape(rssEntry.title)}?"""
+
+
def getInlineKeyBoardForRSSList(chatId: int, RSSEntries: List[RSSEntry], page: int = 1, lastPage: bool = False, itemIndex: int = None) -> dict:
d = []
i = -1
@@ -100,6 +108,11 @@ def getInlineKeyBoardForRSSInList(chatId: int, rssEntry: RSSEntry, index: int) -
d = []
i = -1
d.append([])
+ i = i + 1
+ d[i].append(
+ {'text': '取消订阅', 'callback_data': f'1,{chatId},{InlineKeyBoardForRSSList.Unsubscribe.value},{index}'})
+ d.append([])
+ i = i + 1
d[i].append(
{'text': '返回', 'callback_data': f'1,{chatId},{InlineKeyBoardForRSSList.BackToList.value},{index}'})
return {'inline_keyboard': d}