Closed ashen001 closed 2 years ago
What's your start script and the environment variables?
Please provide in details for analysing.
And please notice that the wevhaty-puppet-padlpcal is not upgraded to the v1 yet, you need to use wechaty v0.68 for using PadLocal. See:
感谢你的回复。我用0.68版本尝试了一次。出现了 Wechaty - ERROR - The network is not good, the bot will try to restart after 60 seconds.
并且在重新回到0.56版本后。脚本运行一段时间同样出现了 Wechaty - ERROR - The network is not good, the bot will try to restart after 60 seconds. 然后导致 scheduler 运行出错 Job "tick (trigger: interval[0:10:00], next run at: 2022-03-02 17:45:46 CST)" raised an exception Traceback (most recent call last):
请问我该如何解决。谢谢
server的配置
export WECHATY_LOG="verbose" export WECHATY_PUPPET="wechaty-puppet-padlocal" export WECHATY_PUPPET_PADLOCAL_TOKEN="puppet_padlocal_xxxxxxxx"
export WECHATY_PUPPET_SERVER_PORT="9099" export WECHATY_TOKEN="888" export WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER="true"
docker run -ti \ --name wechaty_puppet_service_token_gateway \ --rm \ -e WECHATY_LOG \ -e WECHATY_PUPPET \ -e WECHATY_PUPPET_PADLOCAL_TOKEN \ -e WECHATY_PUPPET_SERVER_PORT \ -e WECHATY_TOKEN \ -p "$WECHATY_PUPPET_SERVER_PORT:$WECHATY_PUPPET_SERVER_PORT" \ wechaty/wechaty:0.68
client端:
import os import asyncio from typing import Optional, Union
from wechaty import Wechaty, Contact, Room from wechaty.user import Message
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from wechaty_puppet import get_logger
from datetime import datetime
logger = get_logger(name)
os.environ['WECHATY_PUPPET'] = "wechaty-puppet-service" os.environ['WECHATY_PUPPET_SERVICE_TOKEN'] = "888" os.environ['WECHATY_PUPPET_SERVICE_ENDPOINT'] = "101.xxx.xxx.xxx:9099" os.environ['WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_CLIENT'] = "true"
class MyBot(Wechaty): def init(self): super().init() self.busy = False self.auto_reply_comment = "Automatic Reply: I cannot read your message because I'm busy now, will talk to you when I get back."
async def on_message(self, msg: Message):
"""back on message"""
from_contact = msg.talker()
text = msg.text()
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')
async def on_login(self, contact: Contact):
print(f'user: {contact} has login')
bot: Optional[MyBot] = None
async def tick(bot: Wechaty): """ find a specific room, and say something to it. """ room = bot.Room.load('195625838710@chatroom') await room.ready() await room.say('#ding')
async def main(): """Async Main Entry""" if 'WECHATY_PUPPET_SERVICE_TOKEN' not in os.environ: print(''' Error: WECHATY_PUPPET_SERVICE_TOKEN is not found in the environment variables You need a TOKEN to run the Python Wechaty. Please goto our README for details https://github.com/wechaty/python-wechaty-getting-started/#wechaty_puppet_service_token ''')
global bot
bot = MyBot()
scheduler = AsyncIOScheduler(timezone='Asia/Shanghai')
scheduler.add_job(tick, 'interval', minutes=10, args=[bot])
scheduler.start()
await bot.start()
asyncio.run(main())
非常感谢
Move to Python
启动后一直卡在 03:43:11 VERB StateSwitch active(true) <- (pending)
日志:
然后就一直卡在这里