I have my bot working by now, but the thing is it can only send text. I have seen in the Bot API there are functions to send photos, videos... but I can't get it to work. Someone has achieved it? I'm using python source code from yukuku/telebot
elif text == '/image':
img = Image.new('RGB', (512, 512))
base = random.randint(0, 16777216)
pixels = [base+i*j for i in range(512) for j in range(512)] # generate sample image
img.putdata(pixels)
output = StringIO.StringIO()
img.save(output, 'JPEG')
reply(img=output.getvalue())
When I change the code, nothing happened.
img = Image.open('image.png')
img.show()
Please help me. I need the correct code. Sorry for my bad English.
I have included two functions, one is good for sending local images, the other one is good for sending remote images.
Before sending the photo, you have to do
output.seek(0)
to put the cursor back to the beginning of the file, else it will be read as zeroThe solution is
or
I understand the question. Here's the answer:
Make sure your server does have python module: requests.
You can download here: https://pypi.python.org/pypi/requests#downloads
And put in your application like this
Credit: https://stackoverflow.com/a/17128168/1097372
Put in main.py after line 10