Commit 9afbd4e0 authored by lixiaofang's avatar lixiaofang

add

parent 8d9faa86
This diff is collapsed.
...@@ -44,8 +44,8 @@ if __name__ == "__main__": ...@@ -44,8 +44,8 @@ if __name__ == "__main__":
logging.info("comment answer one") logging.info("comment answer one")
numtime1, numtime2 = time_conv(5, 0) numtime1, numtime2 = time_conv(5, 0)
user_id = get_data(numtime1, numtime2) user_id = get_data(numtime1, numtime2)
redis_key1 = "cybertron:set_reply_id:one1" redis_key1 = "cybertron:set_reply_id:one"
redis_key2 = "cybertron:set_reply_id:one2" # redis_key2 = "cybertron:set_reply_id:one2"
reply_data_comment = [] reply_data_comment = []
if user_id: if user_id:
for i in user_id: for i in user_id:
...@@ -61,15 +61,6 @@ if __name__ == "__main__": ...@@ -61,15 +61,6 @@ if __name__ == "__main__":
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": i[1]}) {"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": i[1]})
redis_client = set_reply_to_redis() redis_client = set_reply_to_redis()
have_reply = redis_client.get(redis_key1) redis_client.hset(redis_key1, str(numtime1), reply_data_comment)
if have_reply:
result = json.loads(str(have_reply, encoding="utf-8"))
if result:
redis_client.set(redis_key2, json.dumps(reply_data_comment))
else:
redis_client.set(redis_key1, json.dumps(reply_data_comment))
else:
redis_client.set(redis_key1, json.dumps(reply_data_comment))
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -2,29 +2,22 @@ import traceback ...@@ -2,29 +2,22 @@ import traceback
import redis import redis
import logging import logging
import json import json
import datetime
from auto_request import set_reply_to_redis, reply2, login from auto_request import set_reply_to_redis, reply2, login
if __name__ == "__main__": if __name__ == "__main__":
try: try:
redis_key1 = "cybertron:set_reply_id:one1" now = datetime.datetime.now().minute
redis_key2 = "cybertron:set_reply_id:one2" redis_key1 = "cybertron:set_reply_id:one"
redis_client = set_reply_to_redis() redis_client = set_reply_to_redis()
have_reply1 = redis_client.hget(redis_key1, now - 5)
have_reply1 = redis_client.get(redis_key1)
result = json.loads(str(have_reply1, encoding="utf-8")) result = json.loads(str(have_reply1, encoding="utf-8"))
if result: if result:
for item in result: for item in result:
cook = login() cook = login()
reply2(cook, item["topic_id"], item["answer"], item["id"]) reply2(cook, item["topic_id"], item["answer"], item["id"])
redis_client.delete(redis_key1) redis_client.delete(redis_key1)
else:
have_reply2 = redis_client.get(redis_key2)
result = json.loads(str(have_reply2, encoding="utf-8"))
for item in result:
cook = login()
reply2(cook, item["topic_id"], item["answer"], item["id"])
redis_client.delete(redis_key2)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment