salz0 / telegram_flea Goto Github PK
View Code? Open in Web Editor NEWA open-source flea market bot, to be used in any Community
License: MIT License
A open-source flea market bot, to be used in any Community
License: MIT License
Currently the picture is mandatory, this shouldn't be the case.
After the price part, I would suggest a button "send without photo"
This can be done even with chatGPT, prefered to use GPT4
Can be also split to several small PR's for newcomers, do as you like ๐ค
Enhance user interaction by replacing text commands with intuitive action buttons. ๐๐
Expected Behavior:
Instead of typing commands, users can click on the keyboard buttons for common actions, making the app more user-friendly and accessible. ๐ค๐ฒ
Docs: https://docs.aiogram.dev/en/latest/api/types/reply_keyboard_markup.html
Example:
https://github.com/aiogram/aiogram/blob/dev-2.x/examples/regular_keyboard_example.py
Make it simple
Create a condition to use aiogram
's MemoryStorage()
class when the user did not input the REDIS_URL
This would make it simpler for newcomers and contributors to work on the project without redundant functionality
This is easy to implement
The README.md right now is rather ordinary and deserves some refreshment.
Provide a nice new version of the first page of our project
Okay so prior to my earlier issue raised i have all my modules installed via poetry & my environment set up however i still come across a KeyError of a missing env variable.
Steps to reproduce
Run project from scratch with python main.py
Expected result:
Bot started (success message)
Actual result:
Traceback (most recent call last):
File "/Users/macbookpro/telegram_flea/main.py", line 18, in <module>
bot = aiogram.Bot(os.environ["TELEGRAM_BOT_TOKEN"])
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "<frozen os>", line 679, in __getitem__
KeyError: 'TELEGRAM_BOT_TOKEN'
Create documentation that provides instruction on how to use and install the Flea Market Telegram Bot, aimed at both users and potential contributors.
This documentation will be the primary source of information for users and new contributors, so it needs to be as clear and comprehensive as possible. It would be beneficial to get feedback from both users and other developers to ensure all bases are covered.
Thank you for considering this issue. Proper documentation will significantly improve the user experience and encourage more contributions to the project. ๐๐ค๐ฅ
Description ๐:
Implement support for multiple languages in the bot using Aiogram's built-in i18n features. The language setting will not be interactive and will be a bot-level configuration.
Requirements ๐:
Installation: Install any necessary packages for i18n.
Configuration: Configure i18n settings in Aiogram bot.
Translations: Add translation files for supported languages.
Fallback: Ensure there's a fallback language (ENGLISH or UKRAINIAN) if the set language translation isn't available.
Acceptance Criteria ๐ฏ:
from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.contrib.middlewares.i18n import I18nMiddleware
bot = Bot(token='YOUR_BOT_TOKEN')
storage = MemoryStorage()
dp = Dispatcher(bot, storage=storage)
i18n = I18nMiddleware('bot', 'path/to/locales')
dp.middleware.setup(i18n)
Add Translation Files: Create .po files and automate .mo creation for supported languages in the /locales directory.
Configure Language in Bot: Set the language to be used in the bot settings, and not allow users to change it.
@dp.message_handler(commands=['start'])
async def send_welcome(message: types.Message):
await message.reply(i18n.t('bot.start_message'))
Test: Make sure all features work in the specified language, and a fallback language is used when necessary.
Sellers without usernames are displayed incorrectly in the listing.
For such users, their user IDs are displayed where the username is supposed to be, resulting in the mention @[some numbers here]
. Such mentions are parsed by Telegram incorrectly, as it treats these IDs as actual usernames.
To Reproduce
Steps to reproduce the behavior:
Additional
It is possible to create a link to a user using formatting: [some text](tg://user?id=), then, with the proper formatting method, "some text" will be displayed as a link to an account. With this method, there might be some issues with account privacy settings.
boto3
or rather aioboto3
.UUID4
s (or similar) to the Database so that in the database we have a full local copy of an ad.I would argue for using async version of boto3
- aioboto3
(or analogs) because uploading an image to S3 is a heavy I/O-bound operation and having it be done async is a great plus.
You can split this into multiple issues:
the strings are:
Make sure to include in the tanslated version the {listing} variable
Describe the bug
On loading the repo to my IDE, i get bugs requesting I install missing modules even after rightly installing them.
To Reproduce
Steps to reproduce the behavior:
Screenshots
To ensure the robustness and correctness of the image handling functionality in the project, it's essential to create unit tests that thoroughly validate its behavior. ๐งช๐ผ๏ธ
Expected Behavior:
The unit tests should verify that the image handling function correctly processes incoming photos, downloads them, prepares the data, and sends the image to the specified channel with the appropriate caption.
Acceptance Criteria ๐ฏ:
Steps for Implementation ๐จ:
Set Up Testing Environment: Ensure that you have a test environment that closely mimics the production environment.
Test Incoming Messages: Write tests to simulate incoming photo messages.
def test_incoming_messages():
# your code here
Test Photo Download and Data Preparation: Create tests that ensure photos are downloaded and data is prepared correctly.
def test_photo_download():
# your code here
Test Caption Generation: Validate that captions are generated in the expected format.
def test_caption_generation():
# your code here
Test Image Sending: Test whether the image is sent to the specified channel.
def test_image_sending():
# your code here
Test Different Formats: Include tests for different image formats.
def test_image_formats():
# your code here
Run and Validate Tests: Run the tests and ensure they all pass. If any fail, debug and rerun the tests.
Additional Notes ๐:
Include logging within tests to capture important debugging information.
Consult the documentation for any external libraries you're using for image processing.
You can do one test at a time, no problem!
At present, the bot doesn't keep track of useful statistics and user data that could be crucial for improving user experience and analyzing usage patterns. We would like to capture and store this data in a PostgreSQL database.
The aim is to implement a PostgreSQL database using Tortoise-ORM to store statistics and user metrics, while ensuring that all data is anonymized for user privacy.
You can divide these into separate PullRequests, to make the task easier:
Implement basic data saving:
Suggestions on what to save:
Do something with the data:
matplotlib
)โ Important: this functionality should be optional, as the usage of a sophisticated database and statistical analysis can be unnecessary for some projects.
Below is a hypothetical Python code snippet that demonstrates how you might use Tortoise-ORM to interact with a PostgreSQL database:
from tortoise import Tortoise, fields
from tortoise.models import Model
class UserStatistics(Model):
id = fields.IntField(pk=True)
command_used = fields.CharField(max_length=50)
session_length = fields.FloatField()
# any other fields
Tortoise.init(
db_url='postgres://username:password@localhost:5432/mydatabase',
modules={'models': ['your_project.models']}
)
async def track_start_command(user_id: int):
await UserStatistics.create(command_used='start', session_length=0.0)
# other logic
Note: Make sure to adhere to privacy guidelines and policies such as GDPR when implementing this feature.
You can divide this task by creating multiple pull requests! No need to do all this work at once โฅ
Main.py expects locale files to be compiled before first run.
Steps to reproduce
Run project from scratch with python main.py
Expected result:
Bot started (success message)
Actual result:
RuntimeError: Found locale 'uk' but this language is not compiled!
The user should be notified that this length has a constraint, let it be around 2k symbols
Looks something like this:
2023-11-06T13:06:08.294794+00:00 app[bot.1]: File "/app/.heroku/python/lib/python3.11/site-packages/aiogram/bot/base.py", line 236, in request
2023-11-06T13:06:08.294794+00:00 app[bot.1]: return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files,
2023-11-06T13:06:08.294794+00:00 app[bot.1]: โ โ โ โ โ โ โ โ โ โ {'photo': <InputFile 'attach://Zr7EVo7IeESjfXai5uPjYQ' with file='<_io.BufferedReader name='item_photo.jpg'>'>}
2023-11-06T13:06:08.294795+00:00 app[bot.1]: โ โ โ โ โ โ โ โ โ {'chat_id': , 'caption': 'ะขะตะบััะพะฒั ะบะฐััะธะฝะบะธ ะท ัะธะผะฒะพะปัะฒ, ัะบั ัะฐะบะพะถ ะฝะฐะทะธะฒะฐััั ASCII ะฐัั ัะต ะพะดะฝะต ะท ะผะธััะตััะฒ ะดะพัััะฟะฝะธั
ะบ...
2023-11-06T13:06:08.294796+00:00 app[bot.1]: โ โ โ โ โ โ โ โ 'sendPhoto'
2023-11-06T13:06:08.294796+00:00 app[bot.1]: โ โ โ โ โ โ โ <aiogram.bot.bot.Bot object at 0x7fab07b39910>
2023-11-06T13:06:08.294796+00:00 app[bot.1]: โ โ โ โ โ โ TelegramAPIServer(base='https://api.telegram.org/bot{token}/{method}', file='https://api.telegram.org/file/bot{token}/{path}')
2023-11-06T13:06:08.294796+00:00 app[bot.1]: โ โ โ โ โ <aiogram.bot.bot.Bot object at 0x7fab07b39910>
2023-11-06T13:06:08.294796+00:00 app[bot.1]: โ โ โ โ <function BaseBot.get_session at 0x7fab07f20360>
2023-11-06T13:06:08.294796+00:00 app[bot.1]: โ โ โ <aiogram.bot.bot.Bot object at 0x7fab07b39910>
2023-11-06T13:06:08.294797+00:00 app[bot.1]: โ โ <function make_request at 0x7fab07ea3c40>
2023-11-06T13:06:08.294797+00:00 app[bot.1]: โ <module 'aiogram.bot.api' from '/app/.heroku/python/lib/python3.11/site-packages/aiogram/bot/api.py'>
2023-11-06T13:06:08.294797+00:00 app[bot.1]: File "/app/.heroku/python/lib/python3.11/site-packages/aiogram/bot/api.py", line 140, in make_request
2023-11-06T13:06:08.294797+00:00 app[bot.1]: return check_result(method, response.content_type, response.status, await response.text())
2023-11-06T13:06:08.294797+00:00 app[bot.1]: โ โ โ โ โ โ โ โ <function ClientResponse.text at 0x7fab08381620>
2023-11-06T13:06:08.294800+00:00 app[bot.1]: โ โ โ โ โ โ โ <ClientResponse(https://api.telegram.org/bot6738102641:AAG9NTvl5IFG1qTBDmBe7vlAHteaUFhc-zA/sendPhoto) [400 Bad Request]>
2023-11-06T13:06:08.294800+00:00 app[bot.1]: โ โ โ โ โ โ <CIM...
2023-11-06T13:06:08.294800+00:00 app[bot.1]: โ โ โ โ โ โ 400
2023-11-06T13:06:08.294800+00:00 app[bot.1]: โ โ โ โ โ <ClientResponse(https://api.telegram.org/bot6738102641:AAG9NTvl5IFG1qTBDmBe7vlAHteaUFhc-zA/sendPhoto) [400 Bad Request]>
2023-11-06T13:06:08.294800+00:00 app[bot.1]: โ โ โ โ <CIM...
2023-11-06T13:06:08.294801+00:00 app[bot.1]: โ โ โ โ <property object at 0x7fab0854d850>
2023-11-06T13:06:08.294802+00:00 app[bot.1]: โ โ โ <ClientResponse(https://api.telegram.org/bot6738102641:AAG9NTvl5IFG1qTBDmBe7vlAHteaUFhc-zA/sendPhoto) [400 Bad Request]>
2023-11-06T13:06:08.294802+00:00 app[bot.1]: โ โ <CIM...
2023-11-06T13:06:08.294802+00:00 app[bot.1]: โ โ 'sendPhoto'
2023-11-06T13:06:08.294802+00:00 app[bot.1]: โ <function check_result at 0x7fab07ea3d80>
2023-11-06T13:06:08.294802+00:00 app[bot.1]: File "/app/.heroku/python/lib/python3.11/site-packages/aiogram/bot/api.py", line 115, in check_result
2023-11-06T13:06:08.294803+00:00 app[bot.1]: exceptions.BadRequest.detect(description)
2023-11-06T13:06:08.294803+00:00 app[bot.1]: โ โ โ โ 'Bad Request: message caption is too long'
2023-11-06T13:06:08.294803+00:00 app[bot.1]: โ โ โ <classmethod(<function _MatchErrorMixin.detect at 0x7fab080c2de0>)>
2023-11-06T13:06:08.294803+00:00 app[bot.1]: โ โ <class 'aiogram.utils.exceptions.BadRequest'>
2023-11-06T13:06:08.294803+00:00 app[bot.1]: โ <module 'aiogram.utils.exceptions' from '/app/.heroku/python/lib/python3.11/site-packages/aiogram/utils/exceptions.py'>
2023-11-06T13:06:08.294804+00:00 app[bot.1]: File "/app/.heroku/python/lib/python3.11/site-packages/aiogram/utils/exceptions.py", line 141, in detect
2023-11-06T13:06:08.294804+00:00 app[bot.1]: raise cls(description)
2023-11-06T13:06:08.294804+00:00 app[bot.1]: โ โ 'bad request: message caption is too long'
2023-11-06T13:06:08.294804+00:00 app[bot.1]: โ <class 'aiogram.utils.exceptions.BadRequest'>
Enhance user support by implementing a /help command to provide guidance and information within the application. ๐ค๐
Users can type /help in the chat to receive a list of available commands, FAQs, and basic usage instructions, improving their understanding of the app's functionality. ๐ฌโ
Currently, the bot is using in-memory storage for FSM (Finite State Machine) which loses all its data when the bot is restarted. This may not be ideal for production where uptime and data integrity are important.
Implement a Redis storage solution to replace the existing MemoryStorage
for better data persistence.
storage = MemoryStorage()
line to use Redis-based storage.Replace:
storage = MemoryStorage()
Please contribute by making a Pull Request that resolves this issue. Thank you! ๐๐
Currently, after a user presses an inline button associated with a message in a channel, the button remains active. This allows for repeated actions, which is undesirable. Additionally, the message gets deleted from the channel upon successful action. The goal is to make the inline button disappear or be disabled once pressed, and to prevent further actions after a successful operation.
await bot.edit_message_reply_markup(
chat_id=callback_query.message.chat.id,
message_id=callback_query.message.message_id,
reply_markup=None
)
Add a feature to the Flea Market Telegram Bot that allows users to manually cancel the selling request for items, effectively removing them from the Telegram channel.
Currently, once an item is posted for sale in the Telegram channel, it stays there indefinitely. Users should have the ability to manually remove their items from the channel, whether it's because the item was sold outside of the channel, withdrawn from sale, or for any other reason.
Add a /cancel [item_id] command to the bot.
When a user triggers this command, the bot should prompt for a confirmation to ensure it's not a mistake.
Upon confirmation, the bot should remove the corresponding item post from the Telegram channel.
This feature adds flexibility for users in managing their selling requests and contributes to keeping the channel clean and relevant.
Thank you for considering this feature request. This will greatly enhance user autonomy and improve the overall experience in the Telegram channel. ๐๐ค๐
Issue Description:
To ensure a top-notch marketplace, we need a moderation system for selling requests. This will guarantee that all listed items follow our rules and policies. ๐๐ง
Expected Behavior:
When a user submits a selling request, it should go first to a admin (who's ID has been identified in the .env) with two buttons APPROVAL / DECLINATION inline-button attached. Moderators can approve, reject. ๐๐ฎโโ๏ธ
Suggestions are welcome ๐
Current README.md file is not up-to-date, please add:
Create a generalized starting message that provides a warm welcome and essential information to new users. ๐๐
It should be the answer to the /start command
As part of our ongoing efforts to make our project more accessible to a global audience, we would like to extend our existing i18n (Internationalization) support to include the Ukrainian language.
Requirements ๐:
Acceptance Criteria ๐ฏ:
Currently the bot simply types the cancelation message without any reference to the request
It should be more intuitive to do a bot.reply()
instead of bot.send_message()
because the person will understand what is happening
This is easy to fix
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.