Hi everyone! Love discourse, it’s the backbone of our community.
We are an open source project with a strong presence on Github. We have a robot written in Python which manages our Github repositories and does things like merge pull requests automatically if they have been approved. Since we have a lot of repositories and not everyone follows every repository it would be awesome if the robot could post in the forums when a new project is created or when a pull request needs to be reviewed.
Can anyone point me in the direction of how I could best call the Discourse API from Python?
I’m suddenly seeing this error too over the weekend when attempting to fetch a topic. This topic fetch code hasn’t changed in over a year, so something about the API must have changed. I’m investigating.
I don’t know about the project mentioned above, but here is the status for bennylope’s project. Maybe the same fix is needed on other wrappers as well.
Thanks! This worked. I uninstalled pydiscourse, and used a local copy based on what you suggested. And now, it works!
I am trying to use Python’s Sentiment analyzer to get a sentiment analysis of the latest posts. I will keep you updated on how it goes.
Yes I know this is an old post but since it is essentially what I seek no sense it creating a new post when this one works but just needs to be brought up to date.
While I do know how to program in many programming languages, sorry to say Ruby is not one. Was wondering if there are newer are better answers to this question.
Interact with Discourse from Python?
As a side question, can Discourse Plugins and/or themes be created using Python?
I use it in Production for a very specific purpose as there is no equivalent module maintained in the RoR ecosystem so it avoids me having to translate and then maintain all that specialist code in Ruby.
It works surprisingly well.
That said, the base of that Plugin is still written in Ruby.
I would recommend you simply learnt Ruby on Rails as well - it really is a very pleasant language and imho the code is nicer to read than Python
I should also take the time to learn more Python if/when needs must.
Interesting side note: some of the code in Discourse Chatbot 🤖 (Now smarter than ChatGPT!*) that creates the agent behaviour was based on a Python agent called “Funkagent” which I first translated into Ruby on Rails (and then modified, enhanced.). So translation can be an option of course if it makes sense to do so. In that case it made sense.
I wrote several import scripts before I really “learned” ruby. Depending on what you want to do you might be able to do more with your current skill set than you think. It’s likely easier to use ruby than figure out how to use something else.
If you’re interacting with the API, though, then you can use whatever language you want.
Ruby is beautifully designed and a doddle to learn, imho.
Ruby on Rails requires a bit more learning and as a framework relying on conventions can be fiddly at times but very powerful once you get the hang of it.
Choose something that you want to do that seems simple. If you want something like cakeday that changes the definition of an anniversary, then cakeday could be a fine place to start. You’d select on small thing you want to change and do things one tiny step at a time.