Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve images #55

Closed
controversial opened this issue Dec 8, 2015 · 6 comments
Closed

Retrieve images #55

controversial opened this issue Dec 8, 2015 · 6 comments

Comments

@controversial
Copy link

From a quick code and documentation search, there's no functionality for handling images sent, or sending images. Would this be hard to implement? There doesn't even seem to be functionality for downloading raw image data as a string. At least this functionality would be helpful, because:

import discord
from PIL import Image
from StringIO import StringIO

client = discord.Client()
client.login('user','password')

def on_message(message):
    buff = StringIO()
    buff.write(message.content)
    try:
        im = Image.open(buff)
        isImage=True
    except:
        text = message.content
        isImage=False
    if isImage:
        im.save("img.jpg")
    else:
        print text

Setting it up like this would be an easy way to download images. Uploading images might work similarly.

@Rapptz
Copy link
Owner

Rapptz commented Dec 8, 2015

Sending files is supported via send_file.

Getting files is your own thing. You can look at message.embeds or message.attachments and extract the images with an HTTP request if you want.

@controversial
Copy link
Author

Thanks. I'll look into it
On Tue, Dec 8, 2015 at 7:28 AM Danny [email protected] wrote:

Sending files is supported via send_file.

Getting files is your own thing. You can look at message.embeds or
message.attachments and extract the images with an HTTP request if you
want.


Reply to this email directly or view it on GitHub
#55 (comment).

@AlexisBG06
Copy link

hey how to extract the image, what http request to use

@FireFeathers06
Copy link

FireFeathers06 commented Jun 26, 2018

HTTP request is raising HTTP error
also pls unban me from the server 😢

@arifali123
Copy link

How to get the url of image

@TheRockettek
Copy link

attachment.url or attachment.proxy_url

Repository owner locked as resolved and limited conversation to collaborators Jul 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants