Giter Site home page Giter Site logo

Support for "answer" posts about pytumblr HOT 13 OPEN

tumblr avatar tumblr commented on August 17, 2024
Support for "answer" posts

from pytumblr.

Comments (13)

sintelligentdesign avatar sintelligentdesign commented on August 17, 2024 3

@Macman1234 I may have a slight improvement on your solution for answering questions: instead of adding 'answer' to the list of valid options for all post types, what about adding
elif post_type == 'answer': valid += ['answer']
near the bottom of _post_valid_options() where all the other if statements are, and then answer asks using
client.edit_post('[blog name]', id=[ask ID], type='answer', answer=[answer], state='published') (note the inclusion of a 'type' arg)?

from pytumblr.

jonfortescue avatar jonfortescue commented on August 17, 2024 1

The method _post_valid_options doesn't have any valid options for answer posts (see https://github.com/tumblr/pytumblr/blob/master/pytumblr/__init__.py#L469). Last time I tried working on this (which admittedly was a while ago), I thought it was more complicated than simply adding an if-statement to this one method... if I have time this weekend, I'll see if I can dig up what I did to get answer support. IIRC, though, it was fairly kludgey, which is why I opened an issue instead of making a pull request.

from pytumblr.

Macman1234 avatar Macman1234 commented on August 17, 2024 1

Sorry about not responding earlier, but I got that to work simply by changing

valid = ['type', 'state', 'tags', 'tweet', 'date', 'format', 'slug']

to

valid = ['type', 'state', 'tags', 'tweet', 'date', 'format', 'slug', 'answer']

then used

asklist = client.submission('[my blog's name]')

for ask in asklist['posts']:
    if ask['type'] == 'answer':
        if ask['state'] == 'submission':
            client.edit_post('[my blog's name]', id=ask['id'], answer=[whatever I want my bot to answer to any given ask], state='published');

to answer every ask that hasn't yet been answered.

sorry if that was weirdly ambiguous with the brackets.

from pytumblr.

Macman1234 avatar Macman1234 commented on August 17, 2024

Do you mean creating answers to questions asked? If so, the way to do that through the tumblr API is to, through editing it, setting the "answer" tag to whatever you want to answer (which requires the changing of the valid parameters in the code), and setting the state from "submission" to "published"

from pytumblr.

Macman1234 avatar Macman1234 commented on August 17, 2024

However, if you mean submitting answer posts to other blogs using pytumblr, I have no idea whether that is possible or how to do that if it is.

from pytumblr.

jonfortescue avatar jonfortescue commented on August 17, 2024

@sintelligentdesign That looks great to me. Have you done any testing with that solution?

from pytumblr.

sintelligentdesign avatar sintelligentdesign commented on August 17, 2024

I've been using it in one of my projects and it's been working reliably. That said, I haven't written any tests for it. It's a minor change but that's still probably important (I'm just garbage at writing tests).

from pytumblr.

Macman1234 avatar Macman1234 commented on August 17, 2024

@sintelligentdesign That's almost certainly a better way of implementing that then the way that I've been using: a lot more sane to prevent using "answer" in editing other types of posts. Thanks for that, I'll probably switch over to using it that way.

from pytumblr.

bratchan avatar bratchan commented on August 17, 2024

For answering the ask, is there a way to use an image with it?

from pytumblr.

sintelligentdesign avatar sintelligentdesign commented on August 17, 2024

You can include an HTML <img> element in your answer field, which appears to work on desktop (but not mobile?), unless the post is set to a draft before being published, in which case the image seems to disappear (??). I can try to see if I can figure out something better (read: reliable) sometime this week.

from pytumblr.

bratchan avatar bratchan commented on August 17, 2024

Cool

from pytumblr.

bratchan avatar bratchan commented on August 17, 2024

Any luck for images? I know that when i answer one it auto uploads it. I was hoping not to host the images and let tumbrl handle them like i have been with answers.

from pytumblr.

sintelligentdesign avatar sintelligentdesign commented on August 17, 2024

By "when I answer one it auto uploads it," are you talking about using the website and answering questions with images manually, or using the API? I assume the first but i just wanted to be sure.

According to the API docs, answer posts don't support the data field used in image posts, and when I gave editing an answer post by adding a data field a shot, it didn't return an error but it didn't work either.

One possibility, although you mentioned wanting to avoid hosting images outside of Tumblr, could be to use an image hosting service's API (I initially was going to suggest Imgur but when I looked the Imgur Python API was deprecated, bummer) and adding the link to the image in the answer field of the answer post. That still has the issue though of apparently not working on mobile (Maybe? Can anybody else test this? Maybe I'm just doing something wrong and dumb. I haven't tried Markdown as the post format but I can't imagine it would make a difference).

from pytumblr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.