diff --git a/database.py b/database.py
index 60bd86f..17eb146 100644
--- a/database.py
+++ b/database.py
@@ -320,6 +320,27 @@ class database:
li.append(BlackInfo(i[0], i[1], i[2], i[3], i[4]))
return li
+ def getChatCount(self) -> int:
+ with self._value_lock:
+ cur = self._db.execute('SELECT COUNT(DISTINCT chatId) FROM chatList;')
+ for i in cur:
+ return i[0]
+ return None
+
+ def getChatRSSCount(self) -> int:
+ with self._value_lock:
+ cur = self._db.execute('SELECT COUNT(*) FROM chatList;')
+ for i in cur:
+ return i[0]
+ return None
+
+ def getHashCount(self) -> int:
+ with self._value_lock:
+ cur = self._db.execute('SELECT COUNT(*) FROM hashList;')
+ for i in cur:
+ return i[0]
+ return None
+
def getRSSByIdAndChatId(self, id: int, chatId: int) -> RSSEntry:
while self._value_lock:
cur = self._db.execute('SELECT RSSList.title, RSSList.url, RSSList.interval, RSSList.lastupdatetime, RSSList.id, RSSList.lasterrortime, RSSList.forceupdate, RSSList.errorcount, RSSList.settings, chatList.config FROM chatList INNER JOIN RSSList ON RSSList.id = chatList.id WHERE chatList.chatId = ? AND chatlist.id = ?;', (chatId, id))
@@ -329,6 +350,13 @@ class database:
return rss
return None
+ def getRSSCount(self) -> int:
+ with self._value_lock:
+ cur = self._db.execute('SELECT COUNT(*) FROM RSSList;')
+ for i in cur:
+ return i[0]
+ return None
+
def getRSSListByChatId(self, chatId: int) -> List[RSSEntry]:
with self._value_lock:
cur = self._db.execute(
@@ -349,6 +377,13 @@ class database:
except Exception:
return None
+ def getUserBlackListCount(self) -> int:
+ with self._value_lock:
+ cur = self._db.execute('SELECT COUNT(*) FROM userBlackList;')
+ for i in cur:
+ return i[0]
+ return None
+
def getUserStatus(self, userId: int) -> Tuple[userStatus, str]:
with self._value_lock:
try:
diff --git a/rssbot.py b/rssbot.py
index 89b775d..3951817 100644
--- a/rssbot.py
+++ b/rssbot.py
@@ -1164,7 +1164,7 @@ class messageHandle(Thread):
return
if self._botCommand is None and self._data['chat']['type'] in ['group', 'supergroup']:
return
- if self._botCommand is None or self._botCommand not in ['/help', '/rss', '/rsslist', '/ban', '/banlist', '/unban']:
+ if self._botCommand is None or self._botCommand not in ['/help', '/rss', '/rsslist', '/ban', '/banlist', '/unban', '/status']:
self._botCommand = '/help'
di = {'chat_id': self._chatId}
if self.__getChatType() in ['supergroup', 'group'] and self._fromUserId is not None:
@@ -1175,7 +1175,8 @@ class messageHandle(Thread):
/rsslist [chatId] 获取RSS订阅列表
/ban 封禁某用户
/banlist 查询被封禁列表
-/unban 取消封禁某用户'''
+/unban 取消封禁某用户
+/status 返回Bot状态'''
elif self._botCommand == '/rss':
self._botCommandPara = self._getCommandlinePara()
self._uri = None
@@ -1296,6 +1297,19 @@ class messageHandle(Thread):
else:
di['text'] = f'封禁{title}失败!'
di['parse_mode'] = 'HTML'
+ elif self._botCommand == '/status':
+ if self._fromUserId is None or not self._main._setting.botOwnerList.isOwner(self._fromUserId):
+ di['text'] = '❌你没有权限操作,请与Bot主人进行PY交易以获得权限。'
+ else:
+ di['text'] = f'''Bot状态:
+RSSBotLib版本: {('' + '.'.join(str(i) for i in self._main._rssbotLib._version) + '') if self._main._rssbotLib is not None else '未发现RSSBotLib'}
+数据库版本: {'.'.join(str(i) for i in self._main._db._version)}
+RSS地址总数: {self._main._db.getRSSCount()}
+RSS订阅总数: {self._main._db.getChatRSSCount()}
+用户(含频道、群组)数: {self._main._db.getChatCount()}
+内容散列个数: {self._main._db.getHashCount()}
+黑名单(不含配置文件)总数: {self._main._db.getUserBlackListCount()}'''
+ di['parse_mode'] = 'HTML'
re = self._main._request('sendMessage', 'post', json=di)
if self._botCommand == '/rss' and self._uri is not None and re is not None and 'ok' in re and re['ok']:
re = re['result']