测试入库
This commit is contained in:
@@ -58,14 +58,15 @@ class MessageStorage:
|
|||||||
yesterday = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d')
|
yesterday = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d')
|
||||||
|
|
||||||
# 遍历Redis中所有与昨天日期相关的key,并写入数据库
|
# 遍历Redis中所有与昨天日期相关的key,并写入数据库
|
||||||
for key_bytes in redis_conn.keys(f"*:*:{yesterday}:count"):
|
for key_item in redis_conn.keys(f"*:*:{yesterday}:count"):
|
||||||
key = key_bytes.decode('utf-8')
|
# 检查key是否为字节类型,如果是则解码
|
||||||
|
key = key_item.decode('utf-8') if isinstance(key_item, bytes) else key_item
|
||||||
parts = key.split(':')
|
parts = key.split(':')
|
||||||
group_id, wx_id, _date = parts[0], parts[1], parts[2] # _date应该是yesterday
|
group_id, wx_id, _date = parts[0], parts[1], parts[2] # _date应该是yesterday
|
||||||
|
|
||||||
# 获取计数值
|
# 获取计数值
|
||||||
count_bytes = redis_conn.hget(key, 'count')
|
count_bytes = redis_conn.hget(key, 'count')
|
||||||
count = int(count_bytes) if isinstance(count_bytes, bytes) else 0
|
count = int(count_bytes) if isinstance(count_bytes, bytes) else int(count_bytes) if count_bytes else 0
|
||||||
|
|
||||||
# 使用MessageStorageDB插入数据
|
# 使用MessageStorageDB插入数据
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -258,9 +258,9 @@ class DouyinParserPlugin(MessagePluginInterface):
|
|||||||
def _parse_douyin(self, url: str) -> Dict[str, Any]:
|
def _parse_douyin(self, url: str) -> Dict[str, Any]:
|
||||||
"""解析抖音链接"""
|
"""解析抖音链接"""
|
||||||
try:
|
try:
|
||||||
api_url = "http://zj.v.api.aa1.cn/api/douyinjx/"
|
api_url = "http://192.168.2.240:9081/api/hybrid/video_data"
|
||||||
clean_url = self._clean_url(url)
|
clean_url = self._clean_url(url)
|
||||||
params = {'text': clean_url, 'type': 'json'}
|
params = {'url': clean_url, 'type': 'json'}
|
||||||
|
|
||||||
self.LOG.info(f"[抖音] 请求API: {api_url}, 参数: {repr(params)}")
|
self.LOG.info(f"[抖音] 请求API: {api_url}, 参数: {repr(params)}")
|
||||||
proxy = {"http": self.http_proxy, "https": self.http_proxy} if self.http_proxy else None
|
proxy = {"http": self.http_proxy, "https": self.http_proxy} if self.http_proxy else None
|
||||||
|
|||||||
5
robot.py
5
robot.py
@@ -44,7 +44,6 @@ from db.connection import DBConnectionManager
|
|||||||
from message_util import MessageUtil
|
from message_util import MessageUtil
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Robot(Job):
|
class Robot(Job):
|
||||||
"""个性化自己的机器人
|
"""个性化自己的机器人
|
||||||
"""
|
"""
|
||||||
@@ -296,6 +295,10 @@ class Robot(Job):
|
|||||||
self.LOG.info("已更新")
|
self.LOG.info("已更新")
|
||||||
if msg.content == "今日百度新闻":
|
if msg.content == "今日百度新闻":
|
||||||
self.news_baidu_report()
|
self.news_baidu_report()
|
||||||
|
if msg.content == "TO_DB":
|
||||||
|
self.message_count_to_db()
|
||||||
|
if msg.content == "RANK":
|
||||||
|
self.generate_and_send_ranking()
|
||||||
if msg.content.startswith("清除群-"):
|
if msg.content.startswith("清除群-"):
|
||||||
self.gbm.handle_command(msg.roomid, msg.content)
|
self.gbm.handle_command(msg.roomid, msg.content)
|
||||||
self.send_text_msg(f"指令:{msg.content} 已执行", msg.sender)
|
self.send_text_msg(f"指令:{msg.content} 已执行", msg.sender)
|
||||||
|
|||||||
Reference in New Issue
Block a user