Skip to content

Commit 07aeff9

Browse files
committed
fix: update markdown formatting in social-networks.yml and enhance debug logging in truthsocial.py
1 parent 1f0b084 commit 07aeff9

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

config/social-networks.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ social_networks:
66
77
这是你需要分析的内容:$content
88
9-
如果需要分析的内容与财经、美股、中美关系、美债市场、科技股或半导体股有关,就按下面的markdown格式输出内容
9+
如果需要分析的内容与财经、美股、中美关系、美债市场、科技股或半导体股有关,就按下面的格式输出内容
1010
1111
## Brief Analysis
1212
@@ -25,15 +25,7 @@ social_networks:
2525
{
2626
"msgtype": "markdown",
2727
"markdown": {
28-
"content": "# [$poster_name]($poster_url) $post_time
29-
30-
> $content
31-
32-
$translation:zh-cn
33-
34-
$ai_result
35-
36-
Origin: [$post_url]($post_url)"
28+
"content": "# [$poster_name]($poster_url) $post_time\n> $content\n\n$translation:zh-cn\n\n$ai_result\n\nOrigin: [$post_url]($post_url)"
3729
}
3830
}
3931
- url: $PRIVATE_BARK_URL

modules/socialmedia/truthsocial.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from datetime import datetime
23
from bs4 import BeautifulSoup
34
from truthbrush.api import Api
@@ -16,6 +17,11 @@ def fetch(user_id: str) -> list[Post]:
1617
else:
1718
last_post_id = str(last_post_id, encoding='utf-8')
1819

20+
if os.getenv('DEBUG') == 'true':
21+
print(
22+
f"Fetching TruthSocial posts for user: {user_id} under debug mode, last_post_id will be set to 114344562778183288")
23+
last_post_id = '114344562778183288'
24+
1925
posts = list(api.pull_statuses(username=user_id, since_id=last_post_id))
2026

2127
noneEmptyPosts = []
@@ -32,7 +38,11 @@ def fetch(user_id: str) -> list[Post]:
3238
if post['id'] > last_post_id:
3339
last_post_id = post['id']
3440

35-
redis_client.set(f"truthsocial:{user_id}:last_post_id", last_post_id)
41+
if os.getenv('DEBUG') == 'true':
42+
print(
43+
f"Fetching TruthSocial posts for user: {user_id} under debug mode, last_post_id will be updated")
44+
else:
45+
redis_client.set(f"truthsocial:{user_id}:last_post_id", last_post_id)
3646

3747
return noneEmptyPosts
3848

0 commit comments

Comments
 (0)