Commit 6947ae00 authored by 段英荣's avatar 段英荣

Merge branch 'reply_vest' into 'master'

Reply vest

See merge request !480
parents 0c5b02fa 1564a967
......@@ -13,10 +13,14 @@ from vest.click import true_click_five, true_click_two, true_click_four, true_cl
from vest.follow import auto_follow, auto_follow_new
from vest.urge import auto_star_urge, auto_lunch_app, auto_lunch_app2, auto_urge1, auto_urge2
from vest.fix import fix_no_comment_click
from vest.reply_answer import reply_comment2, reply_comment3, answer_reply2, answer_reply3, answer_reply1
from vest.reply_answer import reply_comment2, reply_comment3, answer_reply2, answer_reply3, answer_reply1, \
answer_reply5, answer_reply7,reply_comment1,reply_comment5,reply_comment7
from vest.request import get_session, auto_user_id
from vest.vest_majiauser import vest_click_reply
from vest.pictorial import principal_offline_comment1, principal_online_comment1,no_reply_principal
from vest.pictorial import principal_offline_comment1, principal_online_comment1, no_reply_principal
from vest.change_reply import yesterday_topic_reply, before_yesterday_topic_reply, seven_days_ago_reply, \
three_days_ago_topic_reply, five_days_ago_topic_reply
class Command(BaseCommand):
......@@ -115,18 +119,6 @@ class Command(BaseCommand):
if options["mvest"] == "fix_no_comment_click":
fix_no_comment_click.fix_no_comment_click()
# 二级评论
if options["mvest"] == "answer_reply1":
answer_reply1.answer_reply1()
if options["mvest"] == "answer_reply2":
answer_reply2.answer_reply2()
if options["mvest"] == "answer_reply3":
answer_reply3.answer_reply3()
if options["mvest"] == "reply_comment2":
reply_comment2.reply_comment2()
if options["mvest"] == "reply_comment3":
reply_comment3.reply_comment3()
# 获得session和use_id
if options["mvest"] == "get_login_session":
get_session.get_session()
......@@ -146,6 +138,46 @@ class Command(BaseCommand):
if options["mvest"] == "no_reply_principal":
no_reply_principal.no_reply_principal()
### 修改评论
if options["mvest"] == "yesterday_topic_reply":
yesterday_topic_reply.yesterday_comment_one()
if options["mvest"] == "before_yesterday_topic_reply":
before_yesterday_topic_reply.before_yesterday_comment_one()
if options["mvest"] == "three_days_ago_topic_reply":
three_days_ago_topic_reply.three_days_ago_comment_one()
if options["mvest"] == "five_days_ago_topic_reply":
five_days_ago_topic_reply.five_days_ago_comment_one()
if options["mvest"] == "seven_days_ago_reply":
seven_days_ago_reply.serven_days_ago_comment_one()
# 修改的二级评论
# 二级评论
if options["mvest"] == "answer_reply1":
answer_reply1.answer_reply1()
if options["mvest"] == "answer_reply2":
answer_reply2.answer_reply2()
if options["mvest"] == "answer_reply3":
answer_reply3.answer_reply3()
if options["mvest"] == "answer_reply5":
answer_reply5.answer_reply5()
if options["mvest"] == "answer_reply7":
answer_reply7.answer_reply7()
if options["mvest"] == "reply_comment1":
reply_comment1.reply_comment1()
if options["mvest"] == "reply_comment2":
reply_comment2.reply_comment2()
if options["mvest"] == "reply_comment3":
reply_comment3.reply_comment3()
if options["mvest"] == "reply_comment5":
reply_comment5.reply_comment5()
if options["mvest"] == "reply_comment7":
reply_comment7.reply_comment7()
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
import pymysql
import traceback
import logging
from vest.request.auto_request import logins, time_convs, get_comment, reply, get_product_comment, get_face_comment, \
get_category_tag_id, get_category_reply_commtent, judge_topic_info_get_comment, get_majia_reply
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
from vest.data.topic_models import get_edit_tag_id_list, get_pictorial_tag_by_id, get_topic_product_info, \
topic_has_image
import random
def get_data(numtime, numtime2):
try:
print("....")
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE (create_time >= '%s' and create_time <= '%s' ) and is_online=1 " % (
numtime2, numtime))
data = cursor.fetchall()
topic_id_list = list(data)
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
def before_yesterday_comment_one():
try:
logging.info("comment one")
numtime, numtime2 = time_convs(2, 2)
topic_id_list = get_data(numtime, numtime2)
if topic_id_list:
for i in topic_id_list:
random_num = random.randint(0, 2)
logging.info("get random_num:%s" % random_num)
for num in range(random_num):
majia_user_id = get_majia_reply(i[0])
cook = logins(majia_user_id)
comment = judge_topic_info_get_comment(i[1])
if cook is not None:
reply(cook, i[1], comment)
else:
logging.error("catch exception,main:%s" % traceback.format_exc())
except:
logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc())
import pymysql
import traceback
import logging
from vest.request.auto_request import logins, time_convs, get_comment, reply, get_product_comment, get_face_comment, \
get_category_tag_id, get_category_reply_commtent, judge_topic_info_get_comment, get_majia_reply
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
from vest.data.topic_models import get_edit_tag_id_list, get_pictorial_tag_by_id, get_topic_product_info, \
topic_has_image
import random
def get_data(numtime, numtime2):
try:
print("....")
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE (create_time >= '%s' and create_time <= '%s' ) and is_online=1 " % (
numtime2, numtime))
data = cursor.fetchall()
topic_id_list = list(data)
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
def five_days_ago_comment_one():
try:
logging.info("comment one")
numtime, numtime2 = time_convs(5, 5)
topic_id_list = get_data(numtime, numtime2)
if topic_id_list:
for i in topic_id_list:
random_num = random.randint(0, 2)
logging.info("get random_num:%s" % random_num)
for num in range(random_num):
majia_user_id = get_majia_reply(i[0])
cook = logins(majia_user_id)
comment = judge_topic_info_get_comment(i[1])
if cook is not None:
reply(cook, i[1], comment)
else:
logging.error("catch exception,main:%s" % traceback.format_exc())
except:
logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc())
import pymysql
import traceback
import logging
from vest.request.auto_request import logins, time_convs, get_comment, reply, get_product_comment, get_face_comment, \
get_category_tag_id, get_category_reply_commtent, judge_topic_info_get_comment, get_majia_reply
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
from vest.data.topic_models import get_edit_tag_id_list, get_pictorial_tag_by_id, get_topic_product_info, \
topic_has_image
import random
def get_data(numtime, numtime2):
try:
print("....")
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE (create_time >= '%s' and create_time <= '%s' ) and is_online=1 " % (
numtime2, numtime))
data = cursor.fetchall()
topic_id_list = list(data)
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
def serven_days_ago_comment_one():
try:
logging.info("comment one")
numtime, numtime2 = time_convs(7, 7)
topic_id_list = get_data(numtime, numtime2)
if topic_id_list:
for i in topic_id_list:
random_num = random.randint(0, 2)
logging.info("get random_num:%s" % random_num)
for num in range(random_num):
majia_user_id = get_majia_reply(i[0])
cook = logins(majia_user_id)
comment = judge_topic_info_get_comment(i[1])
if cook is not None:
reply(cook, i[1], comment)
else:
logging.error("catch exception,main:%s" % traceback.format_exc())
except:
logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc())
import pymysql
import traceback
import logging
from vest.request.auto_request import logins, time_convs, get_comment, reply, get_product_comment, get_face_comment, \
get_category_tag_id, get_category_reply_commtent, judge_topic_info_get_comment, get_majia_reply
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
from vest.data.topic_models import get_edit_tag_id_list, get_pictorial_tag_by_id, get_topic_product_info, \
topic_has_image
import random
def get_data(numtime, numtime2):
try:
print("....")
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE (create_time >= '%s' and create_time <= '%s' ) and is_online=1 " % (
numtime2, numtime))
data = cursor.fetchall()
topic_id_list = list(data)
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
def three_days_ago_comment_one():
try:
logging.info("comment one")
numtime, numtime2 = time_convs(3, 3)
topic_id_list = get_data(numtime, numtime2)
if topic_id_list:
for i in topic_id_list:
random_num = random.randint(0, 2)
logging.info("get random_num:%s" % random_num)
for num in range(random_num):
majia_user_id = get_majia_reply(i[0])
cook = logins(majia_user_id)
comment = judge_topic_info_get_comment(i[1])
if cook is not None:
reply(cook, i[1], comment)
else:
logging.error("catch exception,main:%s" % traceback.format_exc())
except:
logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc())
import pymysql
import traceback
import logging
from vest.request.auto_request import logins, time_convs, get_comment, reply, get_product_comment, get_face_comment, \
get_category_tag_id, get_category_reply_commtent, judge_topic_info_get_comment, get_majia_reply
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
from vest.data.topic_models import get_edit_tag_id_list, get_pictorial_tag_by_id, get_topic_product_info, \
topic_has_image
import random
def get_data(numtime, numtime2):
try:
print("....")
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE (create_time >= '%s' and create_time <= '%s' ) and is_online=1 " % (
numtime2, numtime))
data = cursor.fetchall()
topic_id_list = list(data)
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
def yesterday_comment_one():
try:
logging.info("comment one")
numtime, numtime2 = time_convs(1, 1)
topic_id_list = get_data(numtime, numtime2)
if topic_id_list:
for i in topic_id_list:
random_num = random.randint(0, 2)
logging.info("get random_num:%s" % random_num)
for num in range(random_num):
majia_user_id = get_majia_reply(i[0])
cook = logins(majia_user_id)
comment = judge_topic_info_get_comment(i[1])
if cook is not None:
reply(cook, i[1], comment)
else:
logging.error("catch exception,main:%s" % traceback.format_exc())
except:
logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc())
This diff is collapsed.
......@@ -12,8 +12,8 @@ from django.db import models
def get_edit_tag_id_list(topic_id):
try:
tag_id_list = list(TopicTag.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=topic_id,
is_collection=1).values_list("tag_id",
flat=True))
is_collection=1).values_list("tag_id",
flat=True))
logging.info("get ---tag_id_list:%s" % tag_id_list)
logging.info("get ---topic_id:%s" % topic_id)
......@@ -23,6 +23,19 @@ def get_edit_tag_id_list(topic_id):
return []
def get_tag_id_list(topic_id):
try:
tag_id_list = list(
TopicTag.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=topic_id, tag_id=10332212).values_list(
"tag_id",
flat=True))
return tag_id_list
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
def topic_has_image(topic_id):
try:
has_image = Topic.objects.using(settings.SLAVE_DB_NAME).filter(id=topic_id, is_deleted=False,
......
......@@ -61,7 +61,7 @@ def get_data(numtime1, numtime2):
def principal_online_comment1():
try:
logging.info("comment offline pictorial")
numtime1, numtime2, minute = time_conv_minute(30, 0)
numtime1, numtime2, minute = time_conv_minute(240, 0)
user_id, data_vote = get_data(numtime1, numtime2)
random_num = 0
......
......@@ -2,9 +2,9 @@ import pymysql
import traceback
import logging
import json
import random
from vest.request.auto_request import time_conv_minute, get_answer_data, reply_answer, set_reply_to_redis, \
reply2, logins, \
get_majia, get_majia_reply
reply2, logins, time_convs, get_majia, get_majia_reply
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
......@@ -15,71 +15,85 @@ def get_data(numtime, numtime2):
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time > '%s' and create_time < '%s' )" % (
numtime, numtime2))
numtime2, numtime))
data = cursor.fetchall()
topic_id = list(data)
topic_id_list = []
try:
for i in topic_id and topic_id:
cursor.execute(
"select user_id,is_shadow from user_extra where user_id =" + str(
i[0]) + " and is_online =1 and is_deleted =0")
data = cursor.fetchall()
user_id = list(data)
if (user_id and user_id[0][1] == 0) or len(user_id) == 0:
topic_id_list.append(i)
logging.info("Database version : %s " % topic_id_list)
pc.close()
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
topic_id_list = list(data)
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
# def answer_reply1():
# try:
# logging.info("answer_reply_one")
# numtime1, numtime2, minute = time_conv_minute(5, 0)
# user_id = get_data(numtime1, numtime2)
# redis_key1 = "cybertron:set_reply_id:one"
# reply_data_comment = []
# if user_id:
# for i in user_id:
# majia_user_id = get_majia()
# logging.info("get majia_user-id:%s" % majia_user_id)
# cook = logins(majia_user_id)
# comment1, comment2 = get_answer_data()
# if cook is not None:
# response = reply_answer(cook, i[1], comment1)
# if len(response) > 1:
# data_dict = json.loads(response)
# reply_id = data_dict["data"]["id"]
# reply_user_id = data_dict["data"]["user"]["id"]
# topic_id = i[1]
# reply_data_comment.append(
# {"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": topic_id,
# "majia_user_id": majia_user_id})
#
# redis_client = set_reply_to_redis()
# redis_client.hset(redis_key1, str(minute), json.dumps(reply_data_comment))
# logging.info("get eeeeeeee:%s" % str(minute - 5))
# have_reply1 = redis_client.hget(redis_key1, str(minute - 5))
# logging.info("get have_reply1:%s" % have_reply1)
# if have_reply1:
# result = json.loads(str(have_reply1, encoding="utf-8"))
# redis_client.hdel(redis_key1, str(minute - 5))
# if result:
# for item in result:
# majia_user_id = get_majia_reply(item["majia_user_id"])
# cook = logins(majia_user_id)
# reply2(cook, item["topic_id"], item["answer"], item["id"])
#
# except:
# logging_exception()
# logging.error("catch exception,main:%s" % traceback.format_exc())
def answer_reply1():
try:
logging.info("answer_reply_one")
numtime1, numtime2, minute = time_conv_minute(5, 0)
numtime1, numtime2 = time_convs(1, 1)
user_id = get_data(numtime1, numtime2)
redis_key1 = "cybertron:set_reply_id:one"
reply_data_comment = []
if user_id:
for i in user_id:
majia_user_id = get_majia()
logging.info("get majia_user-id:%s" % majia_user_id)
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
logging.info("get comment1:%s" % comment1)
logging.info("get comment2:%s" % comment2)
if cook is not None:
response = reply_answer(cook, i[1], comment1)
if len(response) > 1:
data_dict = json.loads(response)
reply_id = data_dict["data"]["id"]
reply_user_id = data_dict["data"]["user"]["id"]
topic_id = i[1]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": topic_id,
"majia_user_id": majia_user_id})
random_num = random.randint(0, 2)
logging.info("get random_num:%s" % random_num)
for num in range(random_num):
majia_user_id = get_majia_reply(i[0])
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
if cook is not None:
response = reply_answer(cook, i[1], comment1)
if len(response) > 1:
data_dict = json.loads(response)
reply_id = data_dict["data"]["id"]
reply_user_id = data_dict["data"]["user"]["id"]
topic_id = i[1]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2,
"topic_id": topic_id,
"majia_user_id": majia_user_id})
redis_client = set_reply_to_redis()
redis_client.hset(redis_key1, str(minute), json.dumps(reply_data_comment))
logging.info("get eeeeeeee:%s" % str(minute - 5))
have_reply1 = redis_client.hget(redis_key1, str(minute - 5))
logging.info("get have_reply1:%s" % have_reply1)
if have_reply1:
result = json.loads(str(have_reply1, encoding="utf-8"))
redis_client.hdel(redis_key1, str(minute - 5))
if result:
for item in result:
majia_user_id = get_majia_reply(item["majia_user_id"])
cook = logins(majia_user_id)
reply2(cook, item["topic_id"], item["answer"], item["id"])
redis_client.set(redis_key1, json.dumps(reply_data_comment))
except:
logging_exception()
......
......@@ -2,10 +2,11 @@ import pymysql
import traceback
import logging
import json
from vest.request.auto_request import logins, time_conv, get_answer_data, reply_answer, get_majia, \
from vest.request.auto_request import logins, time_convs, get_answer_data, reply_answer, get_majia, \
set_reply_to_redis
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
import random
def get_data(numtime, numtime2):
......@@ -13,27 +14,10 @@ def get_data(numtime, numtime2):
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time > '%s' and create_time < '%s' )" % (
numtime, numtime2))
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time >= '%s' and create_time <= '%s' )" % (
numtime2, numtime))
data = cursor.fetchall()
topic_id = list(data)
topic_id_list = []
try:
for i in topic_id and topic_id:
cursor.execute(
"select user_id,is_shadow from user_extra where user_id =" + str(
i[0]) + " and is_online =1 and is_deleted =0")
data = cursor.fetchall()
user_id = list(data)
print(user_id)
if (user_id and user_id[0][1] == 0) or len(user_id) == 0:
topic_id_list.append(i)
logging.info("Database version : %s " % topic_id_list)
pc.close()
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
topic_id_list = list(data)
return topic_id_list
except:
......@@ -43,25 +27,28 @@ def get_data(numtime, numtime2):
def answer_reply2():
try:
logging.info("comment answer one")
numtime1, numtime2 = time_conv(27, 17)
logging.info("comment answer two")
numtime1, numtime2 = time_convs(2, 2)
user_id = get_data(numtime1, numtime2)
redis_key = "cybertron:set_reply_id:two"
reply_data_comment = []
if user_id:
for i in user_id:
majia_user_id = get_majia()
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
if cook is not None:
response = reply_answer(cook, i[1], comment1)
if len(response) > 1:
data_dict = json.loads(response)
reply_id = data_dict["data"]["id"]
reply_user_id = data_dict["data"]["user"]["id"]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": i[1],
"majia_user_id": majia_user_id})
random_num = random.randint(0, 2)
logging.info("get random_num:%s" % random_num)
for num in range(random_num):
majia_user_id = get_majia()
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
if cook is not None:
response = reply_answer(cook, i[1], comment1)
if len(response) > 1:
data_dict = json.loads(response)
reply_id = data_dict["data"]["id"]
reply_user_id = data_dict["data"]["user"]["id"]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": i[1],
"majia_user_id": majia_user_id})
redis_client = set_reply_to_redis()
redis_client.set(redis_key, json.dumps(reply_data_comment))
......
......@@ -2,9 +2,11 @@ import pymysql
import traceback
import logging
import json
from vest.request.auto_request import logins, time_conv, get_answer_data, reply_answer, set_reply_to_redis, get_majia
from vest.request.auto_request import logins, time_convs, get_answer_data, reply_answer, get_majia, \
set_reply_to_redis
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
import random
def get_data(numtime, numtime2):
......@@ -12,27 +14,10 @@ def get_data(numtime, numtime2):
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time > '%s' and create_time < '%s' )" % (
numtime, numtime2))
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time >= '%s' and create_time <= '%s' )" % (
numtime2, numtime))
data = cursor.fetchall()
topic_id = list(data)
topic_id_list = []
try:
for i in topic_id and topic_id:
cursor.execute(
"select user_id,is_shadow from user_extra where user_id =" + str(
i[0]) + " and is_online =1 and is_deleted =0")
data = cursor.fetchall()
user_id = list(data)
print(user_id)
if (user_id and user_id[0][1] == 0) or len(user_id) == 0:
topic_id_list.append(i)
logging.info("Database version : %s " % topic_id_list)
pc.close()
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
topic_id_list = list(data)
return topic_id_list
except:
......@@ -42,28 +27,31 @@ def get_data(numtime, numtime2):
def answer_reply3():
try:
logging.info("comment answer one")
numtime1, numtime2 = time_conv(45, 35)
logging.info("comment answer three")
numtime1, numtime2 = time_convs(3, 3)
user_id = get_data(numtime1, numtime2)
redis_key1 = "cybertron:set_reply_id:three"
redis_key = "cybertron:set_reply_id:three"
reply_data_comment = []
if user_id:
for i in user_id:
majia_user_id = get_majia()
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
if cook is not None:
response = reply_answer(cook, i[1], comment1)
if len(response) > 1:
data_dict = json.loads(response)
reply_id = data_dict["data"]["id"]
reply_user_id = data_dict["data"]["user"]["id"]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": i[1],
"majia_user_id": majia_user_id})
random_num = random.randint(0, 2)
logging.info("get random_num:%s" % random_num)
for num in range(random_num):
majia_user_id = get_majia()
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
if cook is not None:
response = reply_answer(cook, i[1], comment1)
if len(response) > 1:
data_dict = json.loads(response)
reply_id = data_dict["data"]["id"]
reply_user_id = data_dict["data"]["user"]["id"]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": i[1],
"majia_user_id": majia_user_id})
redis_client = set_reply_to_redis()
redis_client.set(redis_key1, json.dumps(reply_data_comment))
redis_client.set(redis_key, json.dumps(reply_data_comment))
except:
logging_exception()
......
import pymysql
import traceback
import logging
import json
from vest.request.auto_request import logins, time_convs, get_answer_data, reply_answer, get_majia, \
set_reply_to_redis
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
import random
def get_data(numtime, numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time >= '%s' and create_time <= '%s' )" % (
numtime2, numtime))
data = cursor.fetchall()
topic_id_list = list(data)
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
def answer_reply5():
try:
logging.info("comment answer five")
numtime1, numtime2 = time_convs(5, 5)
user_id = get_data(numtime1, numtime2)
redis_key = "cybertron:set_reply_id:five"
reply_data_comment = []
if user_id:
for i in user_id:
random_num = random.randint(0, 2)
logging.info("get random_num:%s" % random_num)
for num in range(random_num):
majia_user_id = get_majia()
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
if cook is not None:
response = reply_answer(cook, i[1], comment1)
if len(response) > 1:
data_dict = json.loads(response)
reply_id = data_dict["data"]["id"]
reply_user_id = data_dict["data"]["user"]["id"]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": i[1],
"majia_user_id": majia_user_id})
redis_client = set_reply_to_redis()
redis_client.set(redis_key, json.dumps(reply_data_comment))
except:
logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc())
import pymysql
import traceback
import logging
import json
from vest.request.auto_request import logins, time_convs, get_answer_data, reply_answer, get_majia, \
set_reply_to_redis
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
import random
def get_data(numtime, numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time >= '%s' and create_time <= '%s' )" % (
numtime2, numtime))
data = cursor.fetchall()
topic_id_list = list(data)
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
def answer_reply7():
try:
logging.info("comment answer seven")
numtime1, numtime2 = time_convs(7, 7)
user_id = get_data(numtime1, numtime2)
redis_key = "cybertron:set_reply_id:seven"
reply_data_comment = []
if user_id:
for i in user_id:
random_num = random.randint(0, 2)
logging.info("get random_num:%s" % random_num)
for num in range(random_num):
majia_user_id = get_majia()
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
if cook is not None:
response = reply_answer(cook, i[1], comment1)
if len(response) > 1:
data_dict = json.loads(response)
reply_id = data_dict["data"]["id"]
reply_user_id = data_dict["data"]["user"]["id"]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": i[1],
"majia_user_id": majia_user_id})
redis_client = set_reply_to_redis()
redis_client.set(redis_key, json.dumps(reply_data_comment))
except:
logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc())
import traceback
import logging
import json
from vest.request.auto_request import set_reply_to_redis, reply2, logins, get_majia_reply
from libs.error import logging_exception
def reply_comment1():
try:
redis_key1 = "cybertron:set_reply_id:one"
redis_client = set_reply_to_redis()
have_reply1 = redis_client.get(redis_key1)
result = json.loads(str(have_reply1, encoding="utf-8"))
if result:
for item in result:
majia_user_id = get_majia_reply(item["majia_user_id"])
cook = logins(majia_user_id)
reply2(cook, item["topic_id"], item["answer"], item["id"])
redis_client.delete(redis_key1)
except:
logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc())
import traceback
import logging
import json
from vest.request.auto_request import set_reply_to_redis, reply2, logins, get_majia_reply
from libs.error import logging_exception
def reply_comment5():
try:
redis_key1 = "cybertron:set_reply_id:five"
redis_client = set_reply_to_redis()
have_reply1 = redis_client.get(redis_key1)
result = json.loads(str(have_reply1, encoding="utf-8"))
if result:
for item in result:
majia_user_id = get_majia_reply(item["majia_user_id"])
cook = logins(majia_user_id)
reply2(cook, item["topic_id"], item["answer"], item["id"])
redis_client.delete(redis_key1)
except:
logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc())
import traceback
import logging
import json
from vest.request.auto_request import set_reply_to_redis, reply2, logins, get_majia_reply
from libs.error import logging_exception
def reply_comment7():
try:
redis_key1 = "cybertron:set_reply_id:seven"
redis_client = set_reply_to_redis()
have_reply1 = redis_client.get(redis_key1)
result = json.loads(str(have_reply1, encoding="utf-8"))
if result:
for item in result:
majia_user_id = get_majia_reply(item["majia_user_id"])
cook = logins(majia_user_id)
reply2(cook, item["topic_id"], item["answer"], item["id"])
redis_client.delete(redis_key1)
except:
logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -13,21 +13,17 @@ from email.utils import formataddr
from physical.settings_local import DATABASES
from physical.settings_local import REDIS_URL
from vest.data.topic_models import get_pictorial_tag_by_id, get_topic_product_info, get_edit_tag_id_list, \
get_category_tag_id, topic_has_image
get_category_tag_id, topic_has_image, get_tag_id_list
from django.conf import settings
my_sender = 'lixiaofang@igengmei.com'
my_pass = 'tg5AVKBB8jLQGBET'
my_user6 = "lixiaofang@igengmei.com"
# auto_click_url = "http://earth.gmapp.env/api/v1/like"
# auto_reply_url = "http://earth.gmapp.env/api/v1/reply/create"
# auto_follow_url = "http://earth.gmapp.env/api/v1/follow"
# auto_urge_url = "http://earth.gmapp.env/api/v1/user/urge"
auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create"
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
auto_click_url = settings.AUTO_CLICK_URL
auto_reply_url = settings.AUTO_REPLY_URL
auto_follow_url = settings.AUTO_FOLLOW_URL
auto_urge_url = settings.AUTO_URGE_URL
host = DATABASES['default']['HOST']
......@@ -192,6 +188,9 @@ def time_convs(numtime, numtime2):
yes_time_str2 = yes_time2.strftime('%Y-%m-%d')
yes_time_str2 = yes_time_str2 + ' 00:00:00.000000'
logging.info("get yes_time_str:%s" % yes_time_str)
logging.info("get yes_time_str2:%s" % yes_time_str2)
return yes_time_str, yes_time_str2
except:
return None
......@@ -315,7 +314,7 @@ def send_email(stat_data):
msg = MIMEText(stat_data, 'plain', 'utf-8')
msg['From'] = formataddr(["李小芳", my_sender])
msg["To"] = formataddr(["李小芳", my_user6])
msg['Subject'] = str(datetime.date.today()) + "like的线上环境的自动点赞出问题了"
msg['Subject'] = str(datetime.date.today()) + "like的" + str(settings.SERVICE_NAME) + "环境的自动点赞出问题了"
server = smtplib.SMTP_SSL("smtp.exmail.qq.com", 465)
server.login(my_sender, my_pass)
server.sendmail(my_sender, [my_user6], msg.as_string())
......@@ -494,6 +493,24 @@ def get_face_comment():
return None
def get_hellolike_comment():
try:
data = open("/srv/apps/physical/vest/data/hellolike.txt", "r")
list_guanshui = []
for i in data:
list_guanshui.append(i)
num = random.randint(0, len(list_guanshui))
comment = list_guanshui[num - 1]
return comment
except:
return None
def get_category_reply_commtent(category_id):
try:
# 发型42、穿搭46、美妆3、护肤4、美甲21972、香水17576、瘦身32605、配饰5305608
......@@ -532,7 +549,11 @@ def judge_topic_info_get_comment(topic_id):
# 先判断是不是编辑标签
edit_tag_list = get_edit_tag_id_list(topic_id)
logging.info("get topic_tag:%s" % edit_tag_list)
if len(edit_tag_list) > 0:
tag_list = get_tag_id_list(topic_id)
if len(tag_list) > 0:
comment = get_hellolike_comment()
elif len(edit_tag_list) > 0:
# 如果有编辑标签
# 去拿他的所属分类 根据分类去拿对应的标签(随机拿一个)
category_tag_id = get_category_tag_id(edit_tag_list)
......@@ -555,6 +576,7 @@ def judge_topic_info_get_comment(topic_id):
else:
comment = get_comment()
else:
# 判断有没有商品信息
product_judge = get_topic_product_info(topic_id)
......
......@@ -4,14 +4,12 @@ import logging
import json
from libs.cache import redis_client
from libs.error import logging_exception
login_url = "http://earth.iyanzhi.com/api/account/login_pwd"
# login_url = "http://earth.gmapp.env/api/account/login_pwd"
from django.conf import settings
def index_first():
try:
r1 = requests.get(login_url)
r1 = requests.get(settings.LOGIN_URL)
return r1.cookies.get_dict()
except:
logging.error("index_first:%s" % traceback.format_exc())
......@@ -33,7 +31,7 @@ def get_cook():
'email': i
}
response = requests.post(
url=login_url,
url=settings.LOGIN_URL,
data=post_dict,
cookies=cookies
)
......
......@@ -9,8 +9,8 @@ from libs.cache import redis_client
from vest.request.auto_request import get_offline_comment
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
from django.conf import settings
auto_reply_url = "http://saturn.iyanzhi.com/api/v1/reply/create_for_inner"
def reply(id, content, user_id):
......@@ -21,7 +21,7 @@ def reply(id, content, user_id):
'content': content,
"type": 4
}
response = requests.post(url=auto_reply_url,
response = requests.post(url=settings.auto_inner_reply_url,
data=post_dict)
logging.info("response.text:%s" % response.text)
......
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