Commit d9ddf914 authored by 吴升宇's avatar 吴升宇

Merge branch 'wsy' into 'test'

add auto follow after post and regist

See merge request !516
parents 773e52e4 93377de8
...@@ -10,7 +10,7 @@ from trans2es.type_info import get_type_info_map, TypeInfo ...@@ -10,7 +10,7 @@ from trans2es.type_info import get_type_info_map, TypeInfo
from vest.reply import true_comment_one, true_comment_two, true_comment_three, one_seven_topic_comment from vest.reply import true_comment_one, true_comment_two, true_comment_three, one_seven_topic_comment
from vest.click import true_click_five, true_click_two, true_click_four, true_click_one, true_click_three, \ from vest.click import true_click_five, true_click_two, true_click_four, true_click_one, true_click_three, \
one_seven_star_topic one_seven_star_topic
from vest.follow import auto_follow, auto_follow_new, auto_follow_per_5m_by_followed from vest.follow import auto_follow, auto_follow_new, auto_follow_per_5m_by_followed, auto_follow_per_1d_by_regist, auto_follow_per_1d_by_post
from vest.urge import auto_star_urge, auto_lunch_app, auto_lunch_app2, auto_urge1, auto_urge2 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.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, \
...@@ -116,7 +116,10 @@ class Command(BaseCommand): ...@@ -116,7 +116,10 @@ class Command(BaseCommand):
auto_follow_new.auto_follow_new() auto_follow_new.auto_follow_new()
if options['mvest'] == "auto_follow_per_5m_by_followed": if options['mvest'] == "auto_follow_per_5m_by_followed":
auto_follow_per_5m_by_followed.auto_follow_per_5m_by_followed() auto_follow_per_5m_by_followed.auto_follow_per_5m_by_followed()
if options['mvest'] == "auto_follow_per_1d_by_regist":
auto_follow_per_1d_by_regist.auto_follow_per_1d_by_regist()
if options['mvest'] == "auto_follow_per_1d_by_post":
auto_follow_per_1d_by_post.auto_follow_per_1d_by_post()
# 补足 # 补足
if options["mvest"] == "fix_no_comment_click": if options["mvest"] == "fix_no_comment_click":
......
import pymysql
import random
import traceback
import logging
from vest.request.auto_request import login, time_convs, follow
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
def get_commnet_id(numtime, numtime2):
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
# 发贴后
cursor.execute(
"select user_id from topic WHERE create_time > '%s' and create_time < '%s' " % (numtime, numtime2))
data_new_user = cursor.fetchall()
all_data = list(data_new_user)
user_id_list = []
for i in all_data and all_data:
cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0 ")
data = cursor.fetchall()
user_id = list(data)
if (user_id and user_id[0][1] == 0) or len(user_id) == 0:
user_id_list.append(i)
logging.info("Database version : %s " % user_id_list)
pc.close()
return user_id_list
def auto_follow_per_1d_by_post():
# 发帖触发自动加粉丝
try:
# 0-3星
# 1天前发的帖子:[2-6]个粉丝
numtime1, numtime2 = time_convs(1, 1)
user_id = get_commnet_id(numtime2, numtime1, )
try:
for j in user_id and user_id:
id = int(j[0])
follow_num = random.randint(2, 6)
for i in range(follow_num):
cookies = login()
if cookies is not None:
follow(cookies, id)
except:
pass
# 2-15天前发的帖子:[0-1]个粉丝
numtime1, numtime2 = time_convs(2, 15)
user_id = get_commnet_id(numtime2, numtime1)
try:
for j in user_id and user_id:
id = int(j[0])
follow_num = random.randint(0, 1)
for i in range(follow_num):
cookies = login()
if cookies is not None:
follow(cookies, id)
except:
pass
# 15天前或更早发的帖子:每隔11天[0-2]个粉丝
numtime1, numtime2 = time_convs(2, 15)
user_id = get_commnet_id('0', numtime2)
try:
for j in user_id and user_id:
id = int(j[0])
follow_num = random.randint(1, 6)
if follow_num == 6:
cookies = login()
if cookies is not None:
follow(cookies, id)
except:
pass
# 4-6星
# 1天前发的帖子:[5-10]个粉丝
numtime1, numtime2 = time_convs(1, 1)
user_id = get_commnet_id(numtime2, numtime1)
try:
for j in user_id and user_id:
id = int(j[0])
follow_num = random.randint(5, 10)
for i in range(follow_num):
cookies = login()
if cookies is not None:
follow(cookies, id)
except:
pass
# 2-15天前发的帖子:[0-5]个粉丝
numtime1, numtime2 = time_convs(2, 15)
user_id = get_commnet_id(numtime2, numtime1)
try:
for j in user_id and user_id:
id = int(j[0])
follow_num = random.randint(0, 5)
for i in range(follow_num):
cookies = login()
if cookies is not None:
follow(cookies, id)
except:
pass
# 15天前或更早发的帖子:每隔11天[0-2]个粉丝
numtime1, numtime2 = time_convs(2, 15)
user_id = get_commnet_id('0', numtime2)
try:
for j in user_id and user_id:
id = int(j[0])
follow_num = random.randint(1, 6)
if follow_num == 6:
cookies = login()
if cookies is not None:
follow(cookies, id)
except:
pass
except:
logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -2,76 +2,58 @@ import pymysql ...@@ -2,76 +2,58 @@ import pymysql
import random import random
import traceback import traceback
import logging import logging
from vest.request.auto_request import login, time_convs_hours, follow from vest.request.auto_request import login, time_convs, follow
from vest.request.auto_request import host, user, db, passwd from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception from libs.error import logging_exception
def get_commnet_id(numtime): def get_commnet_id(numtime, numtime2):
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306) pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor() cursor = pc.cursor()
# 注册后
cursor.execute( cursor.execute(
"SELECT user_id FROM reply WHERE create_time > '%s' " % numtime)
data_comment = cursor.fetchall() "select user_id from account_user WHERE create_time > '%s' and create_time < '%s' " % (numtime, numtime2))
cursor.execute(
"SELECT t.user_id from topic t left join reply r on r.topic_id = t.id WHERE r.create_time > '%s'" % numtime)
data_reply_topic = cursor.fetchall()
cursor.execute(
"SELECT r.user_id from reply r left join reply p on r.replied_id = p.replied_id WHERE p.create_time > '%s'" % numtime)
data_reply_reply = cursor.fetchall()
cursor.execute(
"SELECT user_id FROM group_user_role WHERE create_time > '%s' " % numtime)
data_group_follow = cursor.fetchall()
cursor.execute(
"select user_id from account_user WHERE create_time > '%s'" % numtime)
data_new_user = cursor.fetchall() data_new_user = cursor.fetchall()
data_id = list(data_comment) all_data = list(data_new_user)
data1_id = list(data_reply_topic)
data2_id = list(data_group_follow)
data3_id = list(data_new_user)
data_reply = list(data_reply_reply)
all_data = []
all_data.extend(data_id)
all_data.extend(data2_id)
all_data.extend(data3_id)
all_data.extend(data_reply)
all_data.extend(data1_id)
topic_id_list = [] user_id_list = []
for i in all_data and all_data: for i in all_data and all_data:
cursor.execute( cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0 ") "select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0 ")
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
if (user_id and user_id[0][1] == 0) or len(user_id) == 0: if (user_id and user_id[0][1] == 0) or len(user_id) == 0:
topic_id_list.append(i) user_id_list.append(i)
logging.info("Database version : %s " % topic_id_list) logging.info("Database version : %s " % user_id_list)
pc.close() pc.close()
return topic_id_list return user_id_list
def auto_follow_per_2h():
# 注册,发帖 2个事件触发自动加粉丝(在2个小时内加1-3个粉)
def auto_follow_per_1d_by_regist():
# 注册事件触发自动加粉丝
try: try:
numtime1, numtime2 = time_convs_hours(1, 2) # 1天前注册:[1-3]个粉丝
user_id = get_commnet_id(numtime1) numtime1, numtime2 = time_convs(1, 1)
user_id = get_commnet_id(numtime2, numtime1)
try:
for j in user_id and user_id:
id = int(j[0])
follow_num = random.randint(1, 3)
for i in range(follow_num):
cookies = login()
if cookies is not None:
follow(cookies, id)
except:
pass
# 2-10天前注册:[0-1]个粉丝
numtime1, numtime2 = time_convs(2, 12)
user_id = get_commnet_id(numtime2, numtime1)
try: try:
for j in user_id and user_id: for j in user_id and user_id:
id = int(j[0]) id = int(j[0])
...@@ -83,6 +65,20 @@ def auto_follow_per_2h(): ...@@ -83,6 +65,20 @@ def auto_follow_per_2h():
except: except:
pass pass
# 10天前注册:每隔12天[0-1]个赞
numtime1, numtime2 = time_convs(1, 12)
user_id = get_commnet_id('0', numtime2)
try:
for j in user_id and user_id:
id = int(j[0])
follow_num = random.randint(1, 24)
if follow_num == 12:
cookies = login()
if cookies is not None:
follow(cookies, id)
except:
pass
except: except:
logging_exception() logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -26,7 +26,7 @@ def auto_follow_per_5m_by_followed(): ...@@ -26,7 +26,7 @@ def auto_follow_per_5m_by_followed():
try: try:
for user in users and users: for user in users and users:
user_id = user[0] user_id = user[0]
cookies = login(majia_user_ids_dict.get(user[1])) cookies = login(str(majia_user_ids_dict.get(user[1])))
if cookies is not None: if cookies is not None:
follow(cookies, user_id) follow(cookies, user_id)
except: except:
......
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