EbookFoundation / free-programming-books

:books: Freely available programming books
https://ebookfoundation.github.io/free-programming-books/
Creative Commons Attribution 4.0 International
338.14k stars 61.67k forks source link

Telegram bot #6263

Open LuigiImVector opened 3 years ago

LuigiImVector commented 3 years ago

It would be nice to create a telegram bot that would allow you to quickly view free resources belonging to a certain category/subcategory. I created a small bot in python to use it as an example (it's just a concept, the code is really bad): https://gist.github.com/LuigiImVector/c748aa5801c8f3fdfeb4114eb35d1eac

The idea is to make it self-manageable, to send the resources it will save a copy of the desired file and search for the name of the desired subcategory ("Android" for example) and the program will send all the updated resources assigned to that subcategory. There are many other ways to do this, if you like this I can help create it.

eshellman commented 3 years ago

Is there anything we need to do to enable someone to make this? Does it relate to #5778?

LuigiImVector commented 3 years ago

You don't need to do anything, maybe in a few days I'll start creating a more serious bot that can be hosted for free on platforms like Heroku. I hadn't seen the API proposal, if one day they will be created the hypothetical bot would be even easier to create.

nbehrnd commented 3 years ago

I'm not a regular visitor and user of free programming books, so the following does not provide help to set up this assistant application, but asks:

On Sat, 16 Oct 2021 11:30:50 -0700 ImVector @.***> wrote:

You don't need to do anything, maybe in a few days I'll start creating a more serious bot that can be hosted for free on platforms like Heroku. I hadn't seen the API proposal, if one day they will be created the hypothetical bot would be even easier to create.

LuigiImVector commented 3 years ago

My idea is something much simpler and more banal @nbehrnd . The user must indicate a language, a type of resource (books, courses...) and the subcategory (Android, C++, Java...) and the bot will download the markdown file from the github page (maybe I could use the Github API) and will search the subcategory, save it and send to the user a markdown formatted message with the links to the resources of the chosen subcategory.Nothing too complex, there are many other better ways to do this, anyway any advice is always welcome.

LuigiImVector commented 2 years ago

I finally created the telegram bot: @freeprogrammingbooks_bot. It isn't perfect, could be better but I decided to create it this way so that it can self-maintain despite constant updates of the repository. I'm hosting the bot on heroku.

Tell me how it is.

eshellman commented 2 years ago

Testers needed!

stupid-kid-af commented 2 years ago

@eshellman @LuigiImVector Bot is not giving any response. Can you please link the bot source code it would be very helpful image

LuigiImVector commented 2 years ago

Can you please link the bot source code it would be very helpful

You have to write /search and after the thing to search. I will now edit and make it clearer.

stupid-kid-af commented 2 years ago

Can you please link the bot source code it would be very helpful

You have to write /search and after the thing to search. I will now edit and make it clearer.

Am I doing it wrong?? See in the above img

LuigiImVector commented 2 years ago

Am I doing it wrong?? See in the above img

Write the thing to search in new message: first message: /search second message: python

stupid-kid-af commented 2 years ago

Am I doing it wrong?? See in the above img

Write the thing to search in new message: first message: /search second message: python No response Is bot open source??

LuigiImVector commented 2 years ago

No response

Retry and send screenshot

Is bot open source??

The repository is private for the moment because the TOKEN bot is written in plain text in the file but this is the current code: https://gist.github.com/LuigiImVector/2a82893078b7515a9b296a16ae13789c

nbehrnd commented 2 years ago

Is bot open source??

The repository is private because there isthe TOKEN bot in the file

I interpret (and maybe misunderstand) this as the script contains some login details (yours?). It would not be good if this were the case.

Because the project for this script is written strives for free (as in open, accessible) programming, would it be acceptable for you if the source code truly would become public (i.e., going beyond the snapshot/gist shared) for code review and maybe addition of features, including addition of a permissive license (the project itself using CC BY 4.0)?

Visual inspection of file bot.py: Welcome if the script provides the functionality you envisioned on your local set up. (I don't use telegram). To ease the navigation in your code (for others than you), may you add brief doc strings for the functions you defined? (If it is intended to be run directly from the CLI, a shebang line, and joining the functions in a def main function plus a block like

if __name__ == "__main__":
    try:
        main()
    except KeyboardInterrupt:
        logging.info("Received KeyboardInterrupt")

eventually calling this one would be advantageous details, too.)

LuigiImVector commented 2 years ago

I interpret (and maybe misunderstand) this as the script contains some login details (yours?). It would not be good if this were the case. Because the project for this script is written strives for free (as in open, accessible) programming, would it be acceptable for you if the source code truly would become public (i.e., going beyond the snapshot/gist shared) for code review and maybe addition of features, including addition of a permissive license (the project itself using CC BY 4.0)?

The TOKEN is the identification code of the bot that allows you to manage it, I'm working on hiding it and making the repository public. I didn't do it right away because everything was in a beta phase (still is).

Welcome if the script provides the functionality you envisioned on your local set up. (I don't use telegram). To ease the navigation in your code (for others than you), may you add brief doc strings for the functions you defined? (If it is intended to be run directly from the CLI, a shebang line, and joining the functions in a def main function plus a block like eventually calling this one would be advantageous details, too.)

The only way to run the bot in local is creating a local heroku server, I need to figure out what is the best option to make everything more opensource and maintenable by the community as well.

nbehrnd commented 2 years ago

The TOKEN is the identification code of the bot that allows you to manage it, I'm working on hiding it and making the repository public. I didn't do it right away because everything was in a beta phase (still is).

Ok, the project is in early development.

The only way to run the bot in local is creating a local heroku server, I need to figure out what is the best option to make everything more opensource and maintenable by the community as well.

While searching for something different about Python, I stumbled over a presentation by Philip James on PyCon 2019 about setting up and interacting/moderating such a server for Mastodon with Python. Maybe it is good to have this as a spare wheel in the trunk, because (apparently) this equally may run from an instance on replit, and would be open source, too.

https://en.wikipedia.org/wiki/Mastodon_(software) https://www.youtube.com/watch?v=3AQZfXG-ZXs https://blog.replit.com/setting%20up%20a%20mastodon

LuigiImVector commented 2 years ago

While searching for something different about Python, I stumbled over a presentation by Philip James on PyCon 2019 about setting up and interacting/moderating such a server for Mastodon with Python. Maybe it is good to have this as a spare wheel in the trunk, because (apparently) this equally may run from an instance on replit, and would be open source, too.

Do you say to create something for Mastodon too?


Anyway, I made the bot repository public: https://github.com/LuigiImVector/freeprogrammingbooks-bot In the README there is a guide that explains how to contribute to the project, maybe there is still some imperfection in it but I'm testing and improving it.

nbehrnd commented 2 years ago

Do you say to create something for Mastodon too?

No, at present, I do not plan to set up a Mastodon robot because for me Mastodon is a recent find a few days old. Somewhat influenced by the books by Edward Tufte and color maps in general (like e.g., colorbrewer), the presentation mentioned was encountered on my way to an other by Jake van der Plas.

Maybe familiarization with Mastodon and their API for Python once is going to exceed «the critical mass» to pick this idea up.

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity during last 60 days :sleeping:

It will be closed in 30 days if no further activity occurs. To unstale this issue, remove stale label or add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest.

Thank you for your patience :heart:

LuigiImVector commented 2 years ago

The telegram bot continues to work, despite some minor fixes that need to be made. Currently:

If the idea of having a bot on telegram you think is still interesting I continue to work on it.

pAkalpa commented 2 years ago

@LuigiImVector Did you tried render Cloud Platform?

LuigiImVector commented 2 years ago

@LuigiImVector Did you tried render Cloud Platform?

nice website but I preferred to host it on a VPS from DigitalOcean

Ajay-singh1 commented 1 month ago

@LuigiImVector We would love to have a telegram bot it would help many people.