Creating a WeChat Auto‑Reply Bot to Retrieve Test Tokens via wxpy and a Spring Boot API
The article explains how to build a WeChat auto‑reply robot using wxpy that receives a user’s request, calls a custom Spring Boot testing API to obtain a token and personal information, and returns the data to the requester, streamlining mobile app testing.
During testing, colleagues often need to obtain a user token and personal information. Although a Spring Boot endpoint was created for this purpose, copying the token into the app is inconvenient for mobile testers, so a WeChat auto‑reply robot was developed to automate the process.
The idea is to use wxpy to capture incoming messages, perform a simple check, then use requests to call the custom testing API, retrieve the token and user data, and send the result back to the message sender.
#!/usr/bin/python
# coding=utf-8
from wxpy import *
import os
import time
import requests
import json
bot = Bot(cache_path=True)
@bot.register(Friend, TEXT)
def print_group_msg(msg):
m = msg.text
friend = msg.sender
if "@" not in m:
m = "你发错账号了!"
print m
friend.send(m.decode("utf-8"))
return
r = requests.post("http://10.10.32.155:8081/uname/"+m)
b = json.loads(r.text)["data"][u"用户token:"]
friend.send(b)
embed()Technical Articles Selected
Java one‑line code to print a heart shape
Linux performance monitoring tool netdata Chinese version
Interface testing code coverage (JaCoCo) solution sharing
Performance testing framework
How to enjoy performance testing on Linux CLI
HTTP mind map illustration
How to test probabilistic business interfaces
httpclient handling multiple simultaneous users
Automatically converting Swagger docs into test code
Five‑line code to build a static blog
httpclient handling 302 redirects
Exploring a Java linear interface testing framework
Tcloud Cloud Test Platform – A Comprehensive Solution
Non‑Technical Articles Selected
Why Choose Software Testing as a Career?
10 Steps to Becoming an Outstanding Java Developer
Programming Mindset for Everyone
Obstacles in Automated Testing
Problems in Automated Testing
Code Immortality Mind Map
7 Steps to Becoming an Excellent Automated Test Engineer
Click to view the public account map
FunTester
10k followers, 1k articles | completely useless
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.