diff --git a/.env.example b/.env.example index 0af291b..f73e147 100644 --- a/.env.example +++ b/.env.example @@ -11,6 +11,7 @@ CAMPUX_REDIS_PASSWORD="" CAMPUX_REDIS_PUBLISH_POST_STREAM="campux_publish_post" CAMPUX_REDIS_NEW_POST_STREAM="campux_new_post" CAMPUX_REDIS_POST_CANCEL_STREAM="campux_post_cancel" +CAMPUX_REDIS_POST_PUBLISH_STATUS_HASH="campux_post_publish_status" CAMPUX_HELP_MESSAGE="填写未匹配指令时的帮助信息。每用户每60秒只会响应一次。" CAMPUX_REVIEW_HELP_MESSAGE="填写未匹配指令时的审核帮助信息" CAMPUX_REVIEW_QQ_GROUP_ID=123456789 diff --git a/campux/mq/redis.py b/campux/mq/redis.py index e29e468..da4bc22 100644 --- a/campux/mq/redis.py +++ b/campux/mq/redis.py @@ -15,6 +15,9 @@ 'campux_redis_post_cancel_stream': 'campux_post_cancel', } +hash_table_name = { + 'campux_redis_post_publish_status_hash': 'campux_post_publish_status' +} class RedisStreamMQ: @@ -44,7 +47,13 @@ async def initialize(self): if hasattr(self.ap.config, stream_key): streams_name[stream_key] = getattr(self.ap.config, stream_key) + # 从config取出hash table的名称 + for hash_table_key in hash_table_name.keys(): + if hasattr(self.ap.config, hash_table_key): + hash_table_name[hash_table_key] = getattr(self.ap.config, hash_table_key) + logger.info(f"Redis Streams: {streams_name}") + logger.info(f"Redis Hash Tables: {hash_table_name}") # 创建xgroup # 检查是否存在同名group @@ -162,7 +171,7 @@ async def check_new_post(self, message: tuple): async def mark_post_published(self, post_id): await self.redis_client.hset( - f"publish_post_status:{post_id}", + f"{hash_table_name['campux_redis_post_publish_status_hash']}{post_id}", self.get_instance_identity(), 1 )