fix: import also add tweets

This commit is contained in:
xtaodada 2023-12-01 23:32:41 +08:00
parent 701f4dc59f
commit 20fae6ded6
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 7 additions and 2 deletions

View File

@ -105,7 +105,6 @@ async def send_check(user_data: User):
await send_to_user(user_data, tweet) await send_to_user(user_data, tweet)
except Exception: except Exception:
logs.error(f"推送 {user_data.name} 的推文 {tweet.id} 失败") logs.error(f"推送 {user_data.name} 的推文 {tweet.id} 失败")
traceback.print_exc()
TweetDB.add(user_data.username, tweet.id) TweetDB.add(user_data.username, tweet.id)

View File

@ -4,7 +4,7 @@ from typing import List
from defs.feed import UsernameNotFound from defs.feed import UsernameNotFound
from defs.models import User from defs.models import User
from defs.sqlite import UserDB from defs.sqlite import UserDB, TweetDB
from defs.update import async_get_user from defs.update import async_get_user
from init import logs from init import logs
@ -40,6 +40,12 @@ async def check_need_add(users_data) -> List[str]:
if isinstance(user_data, User): if isinstance(user_data, User):
logs.info(f"获取 {user_data.name} (@{user_data.username}) 的数据成功," logs.info(f"获取 {user_data.name} (@{user_data.username}) 的数据成功,"
f"{len(user_data.tweets)} 条推文") f"{len(user_data.tweets)} 条推文")
need_send_tweets = [
tweet for tweet in user_data.tweets[1:]
if not TweetDB.check_id(user_data.username, tweet.id)
]
for tweet in need_send_tweets:
TweetDB.add(user_data.username, tweet.id)
need_add.append(user_data.username) need_add.append(user_data.username)
elif isinstance(user_data, UsernameNotFound): elif isinstance(user_data, UsernameNotFound):
logs.warning(f"获取 {username} 的数据失败,可能用户名已改变") logs.warning(f"获取 {username} 的数据失败,可能用户名已改变")