pythonはWeChatの自動返信と大量追加の友達機能を実現します。


まず、python WeChatの自動返信機能を紹介します。
1.親友のメッセージを受けたら、自動的に返信します。

import random
import itchat
import requests
import time
def get_tuling_response(_info):
  print(_info)
  #         
  api_url = "http://www.tuling123.com/openapi/api"
  data = {
    'key': '5ea0f11b5b6146239c52a47849387484',
    'info': _info,
    'userid':'wechat-robot'
  }
  #          ,         (      )
  res = requests.post(api_url, data).json()
  # print(res, type(res))
  #         
  print(res['text'])
  return res['text']
#              ,         ,
# isGroupChat=True            ,            ;
# isMapChat=True            ,            ;
@itchat.msg_register(itchat.content.TEXT, isFriendChat=True)
def text_reply(msg):
  #   :          ,        .
  #            
ps:python一括生成のWeChat追加の友達のスクリーンショットを紹介します。

# -*- coding: utf-8 -*-
import time,random,os
import PIL.Image as Image
import PIL.ImageColor as ImageColor
import PIL.ImageDraw as ImageDraw
import PIL.ImageFont as ImageFont
# from PIL import Image, ImageDraw
"""
  author@:xiaohe
  QQ496631085
  python3.7
"""
def circle_corner(img, radii):
  """
      
  :param img:    。
  :param radii:   , :30。
  :return:             。
  """
  #   (    4  )
  circle = Image.new('L', (radii * 2, radii * 2), 0) #            
  draw = ImageDraw.Draw(circle)
  draw.ellipse((0, 0, radii * 2, radii * 2), fill=255) #      
  #   
  img = img.convert("RGBA")
  w, h = img.size
  #  4  (      4   )
  alpha = Image.new('L', img.size, 255)
  alpha.paste(circle.crop((0, 0, radii, radii)), (0, 0)) #    
  alpha.paste(circle.crop((radii, 0, radii * 2, radii)), (w - radii, 0)) #    
  alpha.paste(circle.crop((radii, radii, radii * 2, radii * 2)), (w - radii, h - radii)) #    
  alpha.paste(circle.crop((0, radii, radii, radii * 2)), (0, h - radii)) #    
  # alpha.show()
  img.putalpha(alpha) #         ,       
  return img
#  ,                        
def imgAddFont(im1,gps,font,fontSize,fontColor,data):
  #          1
  draw = ImageDraw.Draw(im1)
  #    
  time_font = ImageFont.truetype(font, fontSize)
  # (0,0):   "  ":      (0,0,255):     font:    
  draw.text(gps,data,fontColor,font=time_font)
  draw = ImageDraw.Draw(im1)
def copy(h,m,z,n,v):
  #           
  systime = str(h) + ":"+str(m)
  #        
  add_h=random.randint(2,5)
  #        
  add_m=random.randint(2,7)
  #       
  addtime = str(h-add_h) + ":"+str(m-add_m)
  #    
  # qun_name = "   " + n
  qun_name = n
  #    
  diannum = str(v)
  #     
  im1=Image.open("new.png")
  #     (   )
  imgAddFont(im1,(17,20),'C:\Windows\Fonts\msyh.ttc',38,(50,50,50),systime)
  #    
  imgAddFont(im1,(1012,21),'C:\Windows\Fonts\simhei.ttf',29,(50,50,50),diannum)
  #   
  imgAddFont(im1,(120,108),'C:\Windows\Fonts\msyh.ttc',49,(50,50,50),qun_name)
  #    
  imgAddFont(im1,(490,260),'C:\Windows\Fonts\msyh.ttc',38,(170,170,170),addtime)
  # #     
  # imgAddFont(im1,(490,260),'C:\Windows\Fonts\msyh.ttc',38,(170,170,170),addtime)
  #      22 370
  # img=im1
  #            ,                   
  #                     
  jpg_path = '.\\img\\' + (str(z))
  if os.path.exists(jpg_path+".jpg"):
    img = Image.open(jpg_path+".jpg")
  else:
    img = Image.open(jpg_path+".png")
  img = circle_corner(img, radii=20)
  #        
  w, h = img.size
  img.thumbnail((118, 118)) #       
  #     
  layer = Image.new('RGBA', im1.size, (0,0,0,0))
  layer.paste(img, (20, 370))
  out=Image.composite(layer,im1,layer)
  # out.save("target.png")
  save_time=time.strftime('%Y_%m_%d_%M_%H',time.localtime(time.time()))
  out.save(save_time +str(z)+".png")
  # out.save("target.png")
h=int(input("       "))
m=int(input("       "))
v=int(input("       "))
z=int(input("            "))
for x in range(1,z+1):
  n=input("            ")
  copy(h,m,x,n,v)
締め括りをつける
以上は小编が皆さんに绍介したpythonです。WeChatの自动的な返信と大量の友达追加の机能を実现します。皆さんに助けてほしいです。ここでも私たちのサイトを応援してくれてありがとうございます。
本文があなたのためになると思ったら、転載を歓迎します。出所を明記してください。ありがとうございます。