this post was submitted on 28 Jun 2023
89 points (97.8% liked)

Fediverse

17677 readers
27 users here now

A community dedicated to fediverse news and discussion.

Fediverse is a portmanteau of "federation" and "universe".

Getting started on Fediverse;

founded 4 years ago
MODERATORS
 

Someone’s started a Python wrapper around the lemmy API

https://github.com/db0/pythorhead (@db0)

Could make writing bots and other tools easier and quicker.

@fediverse @fediversenews

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 57 points 1 year ago (6 children)

Hey everyone, "someone" here, AMA :D

[–] [email protected] 7 points 1 year ago* (last edited 1 year ago) (1 children)
[–] [email protected] 5 points 1 year ago (1 children)

I'd love to write a bot for my own community. I used to use praw, when reddit was a thing.

Can you see your wrapper being used this way? If so, is it ready for this yet? If so, is there any example code or docs on this?

Thanks for your work, it's very much appreciated.

[–] [email protected] 3 points 1 year ago

Yes there isn't a reason not to use it as a bot. We don't have all the API endpoints yet as we add them usually as we need them, but if you need one we don't have, just open a PR or send an issue and we'll handle it.

[–] [email protected] 3 points 1 year ago (1 children)

Where does the name come from and what's going on on that logo?

[–] [email protected] 8 points 1 year ago (1 children)

Python + Motörhead and what do you mean?

[–] [email protected] 9 points 1 year ago

Where ... for those who don't know ... Motörhead was band headed by a fellow named ... "Lemmy" (who's partly responsible for the name of this place!)

[–] [email protected] 1 points 1 year ago (1 children)

I think that this question from my non bot account has not reached you:

@[email protected] wrote:

Thanks for the wrapper :)

Two questions:

  1. Where can I find the relation between languages and the languages_id ints?

  2. When I log in into a lemmy instance I check the protected member _requestor.nodeinfo to detect if the problem it’s the connection or the user/password:

     lemmy = Lemmy(instance)
    
     if not lemmy.log_in(user, password):
         if not lemmy._requestor.nodeinfo:
             raise LemmyException(f"Sorry, cannot connect to lemmy instance {instance}.")
         raise LemmyException(
             f"Sorry, cannot login {user} into {instance}. Bad user or wrong password."
         )
    

    There is a better way to validate it?

[–] [email protected] 2 points 1 year ago

I believe pythorhead writes a specific log when you try too login to a non python instance. The node info likewise has a function to retrieve it

[–] [email protected] 0 points 1 year ago* (last edited 1 year ago) (1 children)

(Sorry for repeating myself, my instance had a minor rollback)

Where does the name come from and what's going on on that logo? It looks like a snake with sunglasses, but I can't locate it's head or tail.