Skip to content

Commit

Permalink
Merge pull request wangshub#82 from wangshub/wangshub/autoReply
Browse files Browse the repository at this point in the history
自动评论功能
  • Loading branch information
神奇的战士 authored Feb 20, 2019
2 parents 6ac6777 + cae1fc5 commit 05fcbf2
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,7 @@ venv.bak/

# mypy
.mypy_cache/

face/
autojump.png
optimized.png
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

最近沉迷于抖音无法自拔,常常花好几个小时在抖音**漂亮小姐姐**身上。

为了**高效、直接**地找到漂亮小姐姐,我用 Python + ADB 做了一个 Python 抖音机器人 Douyin-Bot。

![](screenshot/demo.gif)
本着**高效、直接**地找到漂亮小姐姐的核心思想,我用 Python + ADB 做了一个 Python 抖音机器人 Douyin-Bot。

<img src="./screenshot/demo.gif" title="Logo" width="300"> <img src="./screenshot/auto_reply.gif" title="Logo" width="300">

## 特性

- [x] **自动翻页**
Expand All @@ -16,9 +16,9 @@
- [x] **自动点赞**
- [x] **自动关注**
- [x] 随机防 Ban
- [ ] 自动回复
- [x] **自动评论**

## 原理
## 原理

- 打开《抖音短视频》APP,进入主界面
- 获取手机截图,并对截图进行压缩 (Size < 1MB);
Expand All @@ -28,13 +28,15 @@
- 下一页,返回第一步;

## 使用教程

- Python版本:3.0及以上
- 相关软件工具安装和使用步骤请参考 [wechat_jump_game](https://github.com/wangshub/wechat_jump_game)[Android 操作步骤](https://github.com/wangshub/wechat_jump_game/wiki/Android-%E5%92%8C-iOS-%E6%93%8D%E4%BD%9C%E6%AD%A5%E9%AA%A4)
-[ai.qq.com](https://ai.qq.com) 免费申请 `AppKey``AppID`
1. 获取源码:`git clone https://github.com/wangshub/Douyin-Bot.git`
2. 进入源码目录: `cd Douyin-Bot`
3. 安装依赖: `pip install -r requirements.txt`
4. 运行程序:`python douyin-bot.py`
5. 自动回复(可选):`python3 douyin-bot.py --reply`

## 注意

Expand All @@ -57,4 +59,6 @@ MIT

如果你有什么问题请提 Issue,或者关注我的微信公众号留言,我都会一一解答

![](screenshot/qrcode.jpg)
<p align="center">
<img src="screenshot/qrcode.jpg" title="Logo" width="150">
</>
Binary file modified autojump.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions config/1920x1080/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@
"y": 1083,
"rx": 10,
"ry": 10
},
"comment_bottom":{
"x": 1000,
"y": 1240,
"rx": 10,
"ry": 10
},
"comment_text":{
"x": 300,
"y": 1855,
"rx": 10,
"ry": 10
},
"comment_send":{
"x": 1010,
"y": 1690,
"rx": 10,
"ry": 10
}

}
18 changes: 18 additions & 0 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@
"y": 1083,
"rx": 10,
"ry": 10
},
"comment_bottom":{
"x": 1000,
"y": 1240,
"rx": 10,
"ry": 10
},
"comment_text":{
"x": 300,
"y": 1855,
"rx": 10,
"ry": 10
},
"comment_send":{
"x": 1010,
"y": 1690,
"rx": 10,
"ry": 10
}

}
55 changes: 49 additions & 6 deletions douyin-bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import random
import time
from PIL import Image

import argparse

if sys.version_info.major != 3:
print('Please run under Python3')
Expand Down Expand Up @@ -37,7 +37,7 @@
BEAUTY_THRESHOLD = 80

# 最小年龄
GIRL_MIN_AGE = 18
GIRL_MIN_AGE = 14


def yes_or_no():
Expand All @@ -50,7 +50,7 @@ def yes_or_no():
if yes_or_no == 'y':
break
elif yes_or_no == 'n':
print('谢谢使用', end='')
print('谢谢使用')
exit(0)
else:
print('请重新输入')
Expand All @@ -62,7 +62,6 @@ def _random_bias(num):
:param num:
:return:
"""
print('num = ', num)
return random.randint(-num, num)


Expand Down Expand Up @@ -108,6 +107,39 @@ def thumbs_up():
time.sleep(0.5)


def tap(x, y):
cmd = 'shell input tap {x} {y}'.format(
x=x + _random_bias(10),
y=y + _random_bias(10)
)
adb.run(cmd)


def auto_reply():

msg = "垆边人似月,皓腕凝霜雪。就在刚刚,我的心动了一下,小姐姐你好可爱呀_Powered_By_Python"

tap(config['comment_bottom']['x'], config['comment_bottom']['y'])
time.sleep(1)
tap(config['comment_text']['x'], config['comment_text']['y'])
time.sleep(1)
cmd = 'shell am broadcast -a ADB_INPUT_TEXT --es msg {text}'.format(text=msg)
adb.run(cmd)
time.sleep(1)
tap(config['comment_send']['x'], config['comment_send']['y'])
time.sleep(0.5)
cmd = 'shell input keyevent 4'
adb.run(cmd)


def parser():
ap = argparse.ArgumentParser()
ap.add_argument("-r", "--reply", action='store_true',
help="auto reply")
args = vars(ap.parse_args())
return args


def main():
"""
main
Expand All @@ -118,6 +150,8 @@ def main():
debug.dump_device_info()
screenshot.check_screenshot()

cmd_args = parser()

while True:
next_page()

Expand All @@ -138,9 +172,15 @@ def main():
if rsp['ret'] == 0:
beauty = 0
for face in rsp['data']['face_list']:
print(face)

msg_log = '[INFO] gender: {gender} age: {age} expression: {expression} beauty: {beauty}'.format(
gender=face['gender'],
age=face['age'],
expression=face['expression'],
beauty=face['beauty'],
)
print(msg_log)
face_area = (face['x'], face['y'], face['x']+face['width'], face['y']+face['height'])
print(face_area)
img = Image.open("optimized.png")
cropped_img = img.crop(face_area).convert('RGB')
cropped_img.save(FACE_PATH + face['face_id'] + '.png')
Expand All @@ -159,6 +199,9 @@ def main():
thumbs_up()
follow_user()

if cmd_args['reply']:
auto_reply()

else:
print(rsp)
continue
Expand Down
Binary file modified optimized.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot/auto_reply.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 05fcbf2

Please sign in to comment.