# -*- coding = utf-8 -*-
# @Time : 2021/1/26 15:19
# @Author : 陳良興
# @File : 微信表情包炸群.py
# @Software : PyCharm
# 運(yùn)行程序 > 輸入次數(shù) > 回車 > 打開微信對話框 > 將鼠標(biāo)放置在“發(fā)送”按鈕處即可
from pynput.keyboard import Controller as KB #控制鍵盤輸入
from pynput.mouse import Controller,Button #控制鼠標(biāo)點擊
import time
import random
Wechat_expression = [
"[微笑]","[撇嘴]","[色]","[發(fā)呆]","[得意]","[流淚]","[害羞]","[閉嘴]","[睡]","[大哭]","[尷尬]",
"[發(fā)怒]","[調(diào)皮]","[呲牙]","[驚訝]","[難過]","[囧]","[抓狂]","[吐]","[偷笑]","[愉快]","[白眼]",
"[傲慢]","[困]","[驚恐]","[憨笑]","[悠閑]","[咒罵]","[疑問]","[噓]","[暈]","[衰]","[骷髏]","[豬頭]",
"[敲打]","[再見]","[擦汗]","[摳鼻]","[鼓掌]","[壞笑]","[右哼哼]","[鄙視]","[委屈]","[快哭了]",
"[陰險]","[親親]","[可憐]","[笑臉]","[生病]","[臉紅]","[破涕為笑]","[恐懼]","[失望]","[無語]",
"[嘿哈]","[捂臉]","[奸笑]","[機(jī)智]","[皺眉]","[耶]","[吃瓜]","[加油]","[汗]","[天啊]","[Emm]",
"[社會社會]","[旺柴]","[好的]","[打臉]","[哇]","[翻白眼]","[666]","[讓我看看]","[嘆氣]","[苦澀]",
"[裂開]","[嘴唇]","[愛心]","[心碎]","[擁抱]","[強(qiáng)]","[弱]","[握手]","[勝利]","[抱拳]","[勾引]",
"[拳頭]","[OK]","[合十]","[啤酒]","[咖啡]","[蛋糕]","[玫瑰]","[凋謝]","[菜刀]","[便便]","[月亮]",
"[太陽]","[禮物]","[紅包]","[發(fā)]","[福]","[跳跳]","[發(fā)抖]","[轉(zhuǎn)圈]","[炸彈]","[慶祝]","[煙花]"
]
#鍵盤控制函數(shù)
def keyboardInput(string):
keyboard = KB()
keyboard.type(string)
#鼠標(biāo)控制函數(shù)
def mouseClick():
mouse = Controller()
mouse.press(Button.left)
mouse.release(Button.left)
#響應(yīng)函數(shù)
def response(number):
time.sleep(5) #延遲5s響應(yīng)
for i in range(number):
sentence = random.choice(Wechat_expression)
keyboardInput(sentence)
mouseClick()
time.sleep(0.4) #每條消息間隔0.4秒
if __name__ == "__main__":
while True:
print("\033[1;32m發(fā)動機(jī)已啟動,隨時可以出發(fā)!\033[0m")
Num = input("\033[1;32m請輸入轟炸次數(shù):\033[0m")
if Num.isdigit():
response(int(Num))
print("\033[1;33m報告長官,轟炸完畢,請求下一步作戰(zhàn)計劃?。?!\033[0m")
else:
print("\033[1;31m輸入錯誤,請重新輸入一個整數(shù)?。。033[0m")
#詢問是否繼續(xù)
answer = input("\033[1;34m是否執(zhí)行下一次作戰(zhàn)計劃?(y 或者 n):\033[0m")
if answer == "y":
print("\033[1;33m繼續(xù)轟炸!!!\033[0m")
continue
if answer == "n":
print("\033[1;33m停止轟炸,給他們喘口氣?。。033[0m")
break
else:
print("\033[1;31m輸入錯誤,請輸入“y”或者“n”!!!\033[0m")