Compare commits

..
6 Commits
Author SHA1 Message Date
KKlochko c12b94633e Add the CHANGELOG.
continuous-integration/drone/push Build is passing
2023-07-18 15:55:23 +03:00
KKlochko 5f8250380a Update the README. 2023-07-18 15:54:26 +03:00
KKlochko 3bb09413b1 Update the config class for the dots bot api. 2023-07-18 15:53:35 +03:00
KKlochko 32aa9f3225 Refactor the listeners of the commands.
continuous-integration/drone/push Build is passing
2023-07-10 17:23:33 +03:00
KKlochko fa81921fad Update the order formatter to show the currency, hryvnia.
continuous-integration/drone/push Build is passing
2023-06-22 14:16:41 +03:00
KKlochko 9bf2d8d41b Update the help.
continuous-integration/drone/push Build is passing
2023-06-22 11:24:29 +03:00
6 changed files with 100 additions and 12 deletions
+50
View File
@@ -0,0 +1,50 @@
* Change Log
** 0.1.0 <2023-06-16 Fri>
Add ApiFetcher to make requests to the server.
** 0.2.0 <2023-06-16 Fri>
Add CityAPI to get information about city from the server.
** 0.2.1 <2023-06-16 Fri>
Add the city handler to have cities-list in bot's command list.
** 0.2.2 <2023-06-16 Fri>
Update docker-compose file to run src.main as package.
** 0.2.3 <2023-06-16 Fri>
Fix fetcher's send_json to make post a request and get a response.
** 0.3.0 <2023-06-17 Sat>
Add the config file for DotsBotApi.
** 0.4.0 <2023-06-17 Sat>
Add UserAPI for register new user.
** 0.4.1 <2023-06-17 Sat>
Add the CI/CD configuration.
** 0.4.2 <2023-06-17 Sat>
Fixed the CI/CD configuration.
** 0.4.3 <2023-06-17 Sat>
Fixed the CI/CD configuration by adding all deps.
** 0.5.0 <2023-06-20 Tue>
Add methods to select a city and return message.
** 0.5.1 <2023-06-20 Tue>
Add the handler to select a city.
** 0.6.0 <2023-06-20 Tue>
Add company methods to get the list and to select a company.
** 0.6.1 <2023-06-20 Tue>
Add the company handlers.
** 0.7.0 <2023-06-20 Tue>
Add the method to show the items by categories.
** 0.7.1 <2023-06-20 Tue>
Add the handler to show items.
** 0.8.0 <2023-06-20 Tue>
Add the methods to show cart items and to add an item to a cart.
** 0.8.1 <2023-06-20 Tue>
Add the handlers to show cart items and to add an item to a cart.
** 0.9.0 <2023-06-22 Thu>
Add method to send and get the order.
** 0.9.2 <2023-06-22 Thu>
Add the order handler.
** 0.9.5 <2023-07-10 Mon>
Refactor the listeners of the commands.
** 0.9.6 <2023-07-18 Tue>
Update the config class for the dots bot api.
** 0.9.7 <2023-07-18 Tue>
Update the README.
** 0.9.7 <2023-07-18 Tue>
Add the CHANGELOG.
+1
View File
@@ -21,6 +21,7 @@ Setup
USERNAME=@example:example.com
PASSWORD=password
SERVER=https://example.com
BOT_API_BASE_URL=https://domain
- change the ``config.toml``: `more about allowlist and blocklist
formats <https://simple-matrix-bot-lib.readthedocs.io/en/latest/examples.html#id2>`__
+6 -1
View File
@@ -1,5 +1,10 @@
from environs import Env
env = Env()
env.read_env()
class DotsBotApiConfig():
_base_url = "https://domain"
_base_url = env('BOT_API_BASE_URL')
def __str__(self) -> str:
return f"{self._base_url=}"
+4 -4
View File
@@ -11,8 +11,8 @@ class OrderFormatter():
return f"Ваше замовлення має id: {id}.\n" \
f"Вид доставки: {order_type}.\n" \
f"Доставка до: {order_address}.\n" \
f"Ціна товарів: {item_price}.\n" \
f"Ціна пакування: {package_price}.\n" \
f"Ціна доставки: {delivery_price}.\n\n" \
f"Остаточна ціна: {full_price}."
f"Ціна товарів: {item_price} ₴.\n" \
f"Ціна пакування: {package_price} ₴.\n" \
f"Ціна доставки: {delivery_price} ₴.\n\n" \
f"Остаточна ціна: {full_price} ₴."
+19 -3
View File
@@ -23,11 +23,19 @@ def setup(bot: botlib.Bot, prefix: str):
if not match.prefix():
return
# No registered user required
if match.command('help'):
await help_handler(bot=bot, room_id=room.room_id, sender=message.sender, admin_id=bot.config.admin_id)
@bot.listener.on_message_event
async def guests_commands(room: nio.rooms.MatrixRoom, message: nio.events.room_events.Event):
match = botlib.MessageMatch(room, message, bot, prefix=prefix)
if not match.is_not_from_this_bot():
return
if not match.prefix():
return
if match.command('city-list'):
await city_list_handler(bot=bot, room_id=room.room_id, sender=message.sender, admin_id=bot.config.admin_id)
@@ -39,7 +47,15 @@ def setup(bot: botlib.Bot, prefix: str):
if match.command('register'):
await register_handler(bot=bot, room_id=room.room_id, sender=message.sender, admin_id=bot.config.admin_id, args=match.args())
# A registered user required
@bot.listener.on_message_event
async def authorized_commands(room: nio.rooms.MatrixRoom, message: nio.events.room_events.Event):
match = botlib.MessageMatch(room, message, bot, prefix=prefix)
if not match.is_not_from_this_bot():
return
if not match.prefix():
return
if match.command('company-list'):
await company_list_handler(bot=bot, room_id=room.room_id, sender=message.sender, admin_id=bot.config.admin_id)
+20 -4
View File
@@ -2,9 +2,25 @@ import simplematrixbotlib as botlib
async def help_handler(room_id: str, bot: botlib.Bot, sender: str, admin_id: str):
msg: str = 'Hi **{}**\n\n' \
'Prefix: `!`\n' \
'Its a simplematrixbotlib template!\n' \
'Admin contact: **{}**'
msg: str = 'Привіт, **{}**\n\n' \
'Префікс команда: `!`\n' \
'[dots-matrix-bot](https://gitlab.com/KKlochko/dots-matrix-bot) - це вільне програмне забезпечення за лацензією GNU AGPLv3 чи будь-яка новіша версія.\n' \
'Контакт адміна: **{}**\n\n' \
'\n\nКоманди:\n' \
'help - допомога.\n' \
'register - пов\'язати користувача та акаунт матриці.\n' \
'Приклад: `!register username 3806712312121`.\n\n' \
'city-list - перелік міст.\n' \
'company-list - перелік компаній.\n' \
'category-list - перелік категорій та товарів.\n' \
'cart - перелік товарів у кошику та їх вартість.\n\n' \
'select-city - обрати місто.\n' \
'Приклад: `!select-city Чернігів`.\n\n' \
'select-company - обрати компанію.\n' \
'Приклад: `!select-company Назва Компанії`.\n\n' \
'add-item - додати товар у кошик.\n' \
'Приклад: `!add-item !add-item Назва товару, 2`.\n\n' \
'order - замовити.'
await bot.api.send_markdown_message(room_id=room_id, message=msg.format(sender, admin_id))