Commit 9afbd4e0 authored by lixiaofang's avatar lixiaofang

add

parent 8d9faa86
This diff is collapsed.
......@@ -44,8 +44,8 @@ if __name__ == "__main__":
logging.info("comment answer one")
numtime1, numtime2 = time_conv(5, 0)
user_id = get_data(numtime1, numtime2)
redis_key1 = "cybertron:set_reply_id:one1"
redis_key2 = "cybertron:set_reply_id:one2"
redis_key1 = "cybertron:set_reply_id:one"
# redis_key2 = "cybertron:set_reply_id:one2"
reply_data_comment = []
if user_id:
for i in user_id:
......@@ -61,15 +61,6 @@ if __name__ == "__main__":
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": i[1]})
redis_client = set_reply_to_redis()
have_reply = redis_client.get(redis_key1)
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))
redis_client.hset(redis_key1, str(numtime1), reply_data_comment)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -2,29 +2,22 @@ import traceback
import redis
import logging
import json
import datetime
from auto_request import set_reply_to_redis, reply2, login
if __name__ == "__main__":
try:
redis_key1 = "cybertron:set_reply_id:one1"
redis_key2 = "cybertron:set_reply_id:one2"
now = datetime.datetime.now().minute
redis_key1 = "cybertron:set_reply_id:one"
redis_client = set_reply_to_redis()
have_reply1 = redis_client.get(redis_key1)
have_reply1 = redis_client.hget(redis_key1, now - 5)
result = json.loads(str(have_reply1, encoding="utf-8"))
if result:
for item in result:
cook = login()
reply2(cook, item["topic_id"], item["answer"], item["id"])
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:
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