<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alexander Petrosyan on Medium]]></title>
        <description><![CDATA[Stories by Alexander Petrosyan on Medium]]></description>
        <link>https://medium.com/@modernpacifist?source=rss-920925d0bdfd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1YcVV4EZTFu9JJdNvdlrxg.jpeg</url>
            <title>Stories by Alexander Petrosyan on Medium</title>
            <link>https://medium.com/@modernpacifist?source=rss-920925d0bdfd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 08 Jun 2026 06:57:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@modernpacifist/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Telegram chunk reader]]></title>
            <link>https://medium.com/@modernpacifist/telegram-chunk-reader-3640b89df2d8?source=rss-920925d0bdfd------2</link>
            <guid isPermaLink="false">https://medium.com/p/3640b89df2d8</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[reading]]></category>
            <category><![CDATA[telegram-bot]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Alexander Petrosyan]]></dc:creator>
            <pubDate>Sat, 25 Mar 2023 18:11:44 GMT</pubDate>
            <atom:updated>2023-03-25T19:00:19.657Z</atom:updated>
            <content:encoded><![CDATA[<p>As a software developer with experience in the IT field, I have had the opportunity to work on several projects that have challenged me and allowed me to grow as a developer. One such project was the creation of a Telegram bot that allows users to read epub books by chunks of text contained within them. In this paper, I will share my experience working on this project, including the challenges I faced, the key technologies I used, and the lessons I learned from it.</p><p>I developed this bot as a personal project, with the aim of creating a tool that would make reading long books more convenient for users. With the rise of digital books, I noticed that many people found it difficult to read lengthy books in one go, due to time constraints or other factors. To solve this problem, I came up with the idea of creating a Telegram bot that would break down books into smaller chunks of text, allowing users to read them at their own pace. One of the key challenges I faced while developing this project was handling epub files, which have a complex structure and can contain large amounts of data. I had to spend a considerable amount of time researching epub file formats and finding ways to extract the necessary data from them. I also had to ensure that the bot could handle books of different sizes and formats, while maintaining a consistent user experience. To overcome these challenges, I used several technologies, including Python programming language 3.9, python-telegram-bot version 20.04, ebooklib library and MongoDB database. These tools allowed me to extract text from epub files, break it down into smaller chunks, and it to users via Telegram and store some progress per user in Mongo collections. Overall, working on this project was a valuable learning experience for me, as it taught me the importance of perseverance, research, and problem-solving skills in software development. I believe that this project has the potential to make reading more accessible and enjoyable for users, and I look forward to continuing to improve and refine it in the future.</p><h4>Why MongoDB</h4><p>Choosing the right database system is an important decision that can have a significant impact on the success of a project. In my case, I chose MongoDB as the database system for my project, due to its many benefits and features. One of the main reasons I chose MongoDB is its flexible data model, which allows me to store data in a schema-less format. This is particularly useful for my project, as I needed to store data related to epub books, which can have a complex structure and varying data fields. With MongoDB, I can easily add or remove fields from my documents without having to modify the underlying schema, making it a very versatile solution. Scalability is another important factor that led me to choose MongoDB. As my project grows and more users start using it, I need a database system that can handle the increased load and data volume. MongoDB is designed to be highly scalable, allowing me to easily add or remove servers as needed without affecting the performance of the system. Performance was also a key consideration in my decision to choose MongoDB. With support for indexing and other performance optimization features, MongoDB is designed to be fast and efficient, with a rich query language that makes it easy to retrieve data from the database. This is essential for my project, as I need to be able to quickly retrieve and display data to users in real-time. Lastly, MongoDB has a large and active community of developers, with many resources available online to help me learn and troubleshoot any issues I may encounter. This was important to me, as I wanted to ensure that I had access to a wide range of expertise and support as I worked on my project. Overall, I believe that MongoDB is the right choice for my project, and I look forward to continuing to use and explore its many features and benefits.</p><h4>Implemented functionality</h4><p>I implemented several commands to improve the user experience and functionality of the Telegram bot. These commands include <br>“nextchunk”, “mybooks”, “pause”, “unpause”, “changebook” and “changechunksize”. The “nextchunk” command is designed to send the user the next chunk of the uploaded book. This allows users to read books in smaller, more manageable chunks, making it easier to keep track of their progress and stay engaged with the material. The “mybooks” command lists all of the books that the user has uploaded to the bot. This provides an easy way for users to keep track of their books and switch between them as needed. The “pause” command is used to stop the bot from sending book chunks automatically. This is useful if the user needs to take a break from reading or if they want to read at their own pace. Conversely, the “unpause” command is used to resume sending book chunks automatically. This allows users to continue reading without having to manually request the next chunk. The “changebook” command allows users to change the book they are currently reading. This is useful if the user wants to switch between books or if they accidentally selected the wrong book. Finally, the “changechunksize” command allows users to change the size of the chunks that the bot sends automatically. This gives users more control over their reading experience and allows them to adjust the chunk size to suit their preferences. Overall, these commands improve the usability and functionality of the Telegram bot, making it a more effective tool for reading books in a digital format. By providing users with more control over their reading experience and allowing them to easily switch between books, this bot makes reading more accessible and enjoyable for users.</p><h4>Basic usage with examples</h4><p>Before you can use the bot you need to simply send a book as file to the bot, you can do it without execution of any commands just send the epub file you want to read, just drag and drop the file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*iOiMxgAHELPUNxVTeLysHw.png" /><figcaption>successful upload</figcaption></figure><p>In addition to the previously mentioned commands, my Telegram bot also includes a functionality that allows users to receive book chunks at regular <br>intervals specified by them. This is achieved through a scheduling feature that sends book chunks to the user at set intervals, allowing them to read books in a more structured and organized manner. The scheduling feature is highly customizable, allowing users to specify the exact time intervals at which they want to receive book chunks. This means that users can set the bot to send book chunks at specific times of the day or week, depending on their preferences and availability. This feature is particularly useful for users who want to establish a regular reading routine, as it provides a structured and consistent approach to reading. By receiving book chunks at regular intervals, users can make progress through their books in a more efficient and effective manner, without having to worry about keeping track of their progress or manually requesting the next chunk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*i_EC22HDHr--i5Tqmo2j5A.png" /><figcaption>help command</figcaption></figure><p>The help command to list the available commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*fSqq-b6Xs_h8NQU_zizYCA.png" /><figcaption>mybooks command</figcaption></figure><p>The mybooks command returns a list of uploaded books with the data about their completion in percentage to track how much you’ve read the book. Each book has unique index assigned to it, to change the currently reading book with the next command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*ojcAYlUxfUf6724e5dSWsA.png" /><figcaption>changebook command</figcaption></figure><p>The changebook command accepts integer of the book you want to read, in this example I was reading a book with the index 5 about algorithmic trading, now I’m changing it to “Crime and punishment”, the book by Fedor Dostoevsky.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*uzbr_MhoMa62JQc7W-qeDg.png" /><figcaption>nextchunk command</figcaption></figure><p>The nextchunk command sends you the next chunk of the currently reading book, the size of the message is set by the changechunksize with the correspoding argument of the quantity of chars you want.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*xo1E3GsTNdOo6DNgiknYWA.png" /><figcaption>feedchunk command</figcaption></figure><p>The feedchunk command that works automatically as a subroutine. The default time for this routine is 10 AM. The inner-workings of this function are the same as nextchunk command.</p><h4>How to run</h4><p>The source code is public, and is available on GitHub at the following link: <br><a href="https://github.com/modernpacifist/chunk-reader-tg-bot">https://github.com/modernpacifist/chunk-reader-tg-bot</a>. Of course since this software is deeply integrated with Telegram messenger you’ll have to create your own telegram bot with BotFather, use can use this guide as a manual to do that: <a href="https://sendpulse.com/knowledge-base/chatbot/telegram/create-telegram-chatbot">https://sendpulse.com/knowledge-base/chatbot/telegram/create-telegram-chatbot</a></p><p>If you want to run it you can do so using docker-compose tool by running following commands:</p><pre>git clone https://github.com/modernpacifist/chunk-reader-tg-bot.git<br>docker-compose up</pre><p>In case you already have MongoDB installed on your system and you are familiar with poetry you can run it via the mentioned poetry tool:</p><pre>poetry install # to install dependencies<br>poetry run src/main.py # to run the project</pre><h4>Conclusion</h4><p>While the bot is still a work in progress, I am excited to share it with the wider community and welcome any contributions or feedback that others may have. By making the bot open source, I hope to encourage collaboration and innovation, and to create a tool that truly meets the needs of users. Whether you are a developer looking to contribute to the project or a user interested in trying out the bot for yourself, I invite you to take a look at the source code and see what this powerful tool can do. With your help and support, I am confident that we can create a Telegram bot that revolutionizes the way we read books in a digital format. You can actually access the bot in the telegram by this link <a href="https://t.me/chunkreader_bot">https://t.me/chunkreader_bot</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3640b89df2d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>