Closed w311ang closed 2 years ago
ding-dong程序重启,gateway服务也要重启
ding-dong程序重启,gateway服务也要重启
重启的意思不是关了再开吗,已经这样尝试过了
问题解决,发现服务端和客户端的配置并不是通用的,服务端的token变量名是WECHATY_TOKEN
,而客户端是WECHATY_PUPPET_SERVICE_TOKEN
,相当于我少了客户端的token配置,却报的这个错就离谱就不应该给个明显的无token错误吗
给各位我的demo,应该可以少走点弯路
config.ps1
$env:WECHATY_PUPPET="wechaty-puppet-xp"
$env:WECHATY_PUPPET_SERVER_PORT="8788"
$env:WECHATY_PUPPET_SERVICE_TOKEN="__token__" #改成你的token
$env:WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER="true"
$env:WECHATY_PUPPET_SERVICE_ENDPOINT="127.0.0.1:8788"
$env:WECHATY_LOG="verbose" #别注释不然跑不起来~~此处靠bug运行~~
server.ps1
.\config.ps1
wechaty gateway --puppet $env:WECHATY_PUPPET --token $env:WECHATY_PUPPET_SERVICE_TOKEN --port $env:WECHATY_PUPPET_SERVER_PORT
client.ps1
.\config.ps1
python .\client.py
client.py
from https://wechaty.readthedocs.io/zh_CN/latest/introduction/use-web-protocol/
import asyncio
from typing import List, Optional, Union
from wechaty_puppet import FileBox # type: ignore
from wechaty import Wechaty, Contact
from wechaty.user import Message, Room
class MyBot(Wechaty):
async def on_message(self, msg: Message):
"""
listen for message event
"""
from_contact: Optional[Contact] = msg.talker()
text = msg.text()
room: Optional[Room] = msg.room()
if text == 'ding':
conversation: Union[
Room, Contact] = from_contact if room is None else room
await conversation.ready()
await conversation.say('dong')
file_box = FileBox.from_url(
'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/'
'u=1116676390,2305043183&fm=26&gp=0.jpg',
name='ding-dong.jpg')
await conversation.say(file_box)
asyncio.run(MyBot().start())
@w311ang Thank you very much for sharing your experiences to help others, it's very valuable!
@w311ang Thank you very much for sharing your experiences to help others, it's very valuable!
Can I just join your team to join wechat group and get a token? Or should I make it into a repository?
@w311ang To become a Wechaty Contributor, you can follow our Wechaty Contributor Program.
Learn it from our official website: https://wechaty.js.org/docs/contributor-program/
问题解决,发现服务端和客户端的配置并不是通用的,服务端的token变量名是
WECHATY_TOKEN
,而客户端是WECHATY_PUPPET_SERVICE_TOKEN
,相当于我少了客户端的token配置,却报的这个错就离谱就不应该给个明显的无token错误吗
大佬,现在是只能发送文字,不能其他类型的消息么???
requirements
PS E:\wbwNodejs\autoWxSigning> pip list Package Version
aiofiles 0.8.0 altgraph 0.17.2 beautifulsoup4 4.10.0 betterproto 1.2.5 blinker 1.4 certifi 2021.10.8 charset-normalizer 2.0.9 click 8.0.3 colorama 0.4.4 dnspython 2.1.0 Flask 2.0.2 future 0.18.2 grpclib 0.4.2 h11 0.13.0 h2 4.1.0 hpack 4.0.0 hypercorn 0.13.2 hyperframe 6.0.1 idna 3.3 itchat-uos 1.4.1 itsdangerous 2.0.1 Jinja2 3.0.3 lxml 4.7.1 MarkupSafe 2.0.1 multidict 5.2.0 MyPytools 2.2.4 pefile 2021.9.3 ping3 3.0.2 pip 21.3.1 priority 2.0.0 psutil 5.8.0 pycryptodome 3.12.0 pyee 9.0.3 pyinstaller 4.7 pyinstaller-hooks-contrib 2021.4 pypng 0.0.21 PyQRCode 1.2.1 pywin32-ctypes 0.2.0 qrcode 7.3.1 quart 0.16.2 requests 2.26.0 schedule 1.1.0 setuptools 58.1.0 soupsieve 2.3.1 stringcase 1.2.0 toml 0.10.2 typing_extensions 4.0.1 urllib3 1.26.7 wechaty 0.8.33 wechaty-grpc 0.20.19 wechaty-puppet 0.4.0 wechaty-puppet-service 0.8.8 Werkzeug 2.0.2 wsproto 1.0.0
PS E:\wbwNodejs\autoWxSigning> python --version Python 3.10.1
Error info
Your experiments