Open AP-Kai opened 3 years ago
Unfortunately, there are some problems sending GIF pictures. Here is my simple code which should be right.
import asyncio
from wechaty import Wechaty, Message, FileBox
class Bot(Wechaty):
async def on_message(self, message: Message):
text = message.text()
if not text.startswith('image'):
return
index = int(text.split()[1])
image_file = f'./examples/image-{index}.gif'
file_box: FileBox = FileBox.from_file(image_file)
talker = message.talker()
room = message.room()
conversation = room if room else talker
await conversation.say(file_box)
async def main():
bot = Bot()
await bot.start()
asyncio.run(main())
Please keep eyes on this issue, which I will track on. Thanks for your issue.
Unfortunately, there are some problems sending GIF pictures. Here is my simple code which should be right.
import asyncio from wechaty import Wechaty, Message, FileBox class Bot(Wechaty): async def on_message(self, message: Message): text = message.text() if not text.startswith('image'): return index = int(text.split()[1]) image_file = f'./examples/image-{index}.gif' file_box: FileBox = FileBox.from_file(image_file) talker = message.talker() room = message.room() conversation = room if room else talker await conversation.say(file_box) async def main(): bot = Bot() await bot.start() asyncio.run(main())
Please keep eyes on this issue, which I will track on. Thanks for your issue.
I tried your method, but it doesn't run correctly. I still got a GIF "生日快乐".
Yes,my goal is to run the above code correctly. If you are interested at it, you can have a try to solve this bug.
I'm sorry to tell you that wechaty can't send gif image file beacuase of some wechaty structure reasons, and there will be some changes in sending file implementation. please refer to : https://github.com/wechaty/python-wechaty-puppet-service/pull/64#issuecomment-911103851
Please keep eyes on this issue to get latest progress of this problem.
1. Versions
Answer:
Answer:
Windows 10
2. Describe the bug
I find a bug when I want to send a GIF by wechaty-python, each time I want to send a GIF(about 30KB) by
The robot only send me a GIF what I had never used before like this:
The GIF what I want is another one.
Besides, when the robot try to send a big GIF(about 20MB), it do nothing.
3. To Reproduce
How to create a Minimal, Reproducible Example
Steps to reproduce the behavior:
os.environ['WECHATY_PUPPET'] = "wechaty-puppet-service" os.environ['WECHATY_PUPPET_SERVICE_TOKEN'] = "" # 这里填Wechaty token os.environ['CUDA_VISIBLE_DEVICES'] = "0"
async def on_message(msg: Message): if msg.text() == 'ding': file_box = FileBox.from_file('./1.gif') await msg.say(file_box)
async def on_scan( qrcode: str, status: ScanStatus, _data, ): print('Status: ' + str(status)) print('View QR Code Online: https://wechaty.js.org/qrcode/' + qrcode)
async def on_login(user: Contact): print(user)
async def main():
确保我们在环境变量中设置了WECHATY_PUPPET_SERVICE_TOKEN
asyncio.run(main())