From b591a4913fffc312724e3e5aa07eb56aa9d34256 Mon Sep 17 00:00:00 2001 From: Rongrong <15956627+Rongronggg9@users.noreply.github.com> Date: Wed, 15 Sep 2021 21:51:26 +0800 Subject: [PATCH] minor refactor and docker build config update Signed-off-by: Rongrong <15956627+Rongronggg9@users.noreply.github.com> --- .github/workflows/publish-docker-image-dev.yml | 16 ++-------------- .../workflows/publish-docker-image-master.yml | 16 ++-------------- docker-compose.yml.sample | 5 +++-- feed.py | 7 ++++++- telegramRSSbot.py | 4 ++-- 5 files changed, 15 insertions(+), 33 deletions(-) diff --git a/.github/workflows/publish-docker-image-dev.yml b/.github/workflows/publish-docker-image-dev.yml index 1f1f425360..2ecd1decd1 100644 --- a/.github/workflows/publish-docker-image-dev.yml +++ b/.github/workflows/publish-docker-image-dev.yml @@ -21,21 +21,9 @@ jobs: with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Push to Docker Hub (x64) + - name: Push to Docker Hub uses: docker/build-push-action@v2 with: push: true - platforms: linux/amd64 + platforms: linux/amd64,linux/386,linux/arm64 tags: rongronggg9/rss-to-telegram:dev - - name: Push to Docker Hub (x86) - uses: docker/build-push-action@v2 - with: - push: true - platforms: linux/386 - tags: rongronggg9/rss-to-telegram:dev - - name: Push to Docker Hub (arm64) - uses: docker/build-push-action@v2 - with: - push: true - platforms: linux/arm64 - tags: rongronggg9/rss-to-telegram:dev \ No newline at end of file diff --git a/.github/workflows/publish-docker-image-master.yml b/.github/workflows/publish-docker-image-master.yml index 60aaade033..0034d9688e 100644 --- a/.github/workflows/publish-docker-image-master.yml +++ b/.github/workflows/publish-docker-image-master.yml @@ -21,21 +21,9 @@ jobs: with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Push to Docker Hub (x64) + - name: Push to Docker Hub uses: docker/build-push-action@v2 with: push: true - platforms: linux/amd64 - tags: rongronggg9/rss-to-telegram:latest - - name: Push to Docker Hub (x86) - uses: docker/build-push-action@v2 - with: - push: true - platforms: linux/386 - tags: rongronggg9/rss-to-telegram:latest - - name: Push to Docker Hub (arm64) - uses: docker/build-push-action@v2 - with: - push: true - platforms: linux/arm64 + platforms: linux/amd64,linux/386,linux/arm64 tags: rongronggg9/rss-to-telegram:latest diff --git a/docker-compose.yml.sample b/docker-compose.yml.sample index 88d8f673d3..9997ed55be 100644 --- a/docker-compose.yml.sample +++ b/docker-compose.yml.sample @@ -4,9 +4,10 @@ # 以后如果需要更新/停止/重启等,都在这个目录里操作 # <------ 命令 ------> # 启动: docker-compose up -d -# 结束:docker-compose down +# 结束:docker-compose down -v # 修改配置后更新配置: 先结束再启动 -# 更新到最新版本: 同上 +# 更新到最新版本: 先结束, 再 docker-compose pull +# 查看日志:docker logs rsstt version: '3.6' diff --git a/feed.py b/feed.py index df7f90cafc..7e46278c24 100644 --- a/feed.py +++ b/feed.py @@ -109,7 +109,7 @@ def add_feed(self, name, link, uid: Optional[int] = None, timeout: Optional[int] if rss_d is None: return None last = str(rss_d.entries[0]['link']) - fid = max(self._feeds.keys()) + 1 if self._feeds else 1 + fid = self.current_fid feed = Feed(fid=fid, name=name, link=link, last=last) # acquire w lock @@ -133,6 +133,11 @@ def del_feed(self, name): logging.info(f'Removed feed {name}.') return feed_to_delete + @property + @fasteners.lock.read_locked + def current_fid(self): + return max(self._feeds.keys()) + 1 if self._feeds else 1 + @fasteners.lock.read_locked def get_user_feeds(self) -> Optional[tuple]: if not self._feeds: diff --git a/telegramRSSbot.py b/telegramRSSbot.py index 8e835e342f..3d7b5c076d 100644 --- a/telegramRSSbot.py +++ b/telegramRSSbot.py @@ -36,8 +36,8 @@ def permission_required(func=None, *, only_manager=False, only_in_private_chat=F @functools.wraps(func) def wrapper(update: telegram.Update, context: Optional[telegram.ext.CallbackContext] = None, *args, **kwargs): - message = update.message - command = message.text + message = update.effective_message + command = message.text if message.text else '(no command, file message)' user_id = update.effective_user.id user_fullname = update.effective_user.full_name if only_manager and str(user_id) != env.MANAGER: