Compare commits
No commits in common. "6b0f99d5adb6350112a3f96806cad1dde8da04c4" and "dd5d35d043e41f4d93a827ab4fa036fb0ce6c82e" have entirely different histories.
6b0f99d5ad
...
dd5d35d043
@ -5,15 +5,16 @@ PyMenu is a discord bot to create grocery list
|
|||||||
- Add items to your list by sending a message to a channel within the `GROCERY_LIST` category.
|
- Add items to your list by sending a message to a channel within the `GROCERY_LIST` category.
|
||||||
- Support for multiple lists, one for each channel.
|
- Support for multiple lists, one for each channel.
|
||||||
- Easily remove items from your list by clicking on the check mark reaction.
|
- Easily remove items from your list by clicking on the check mark reaction.
|
||||||
- Set prices for items.
|
|
||||||
- Specify quantities for items.
|
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
![](https://media.discordapp.net/attachments/501841539161522176/1161285342914170970/image.png?ex=6537be41&is=65254941&hm=3ace3096fd0a5d66cb8bfc8c744dbd79dcba84fc02cbaf7a02b01ffbcc7ed58d&=)
|
![](https://media.discordapp.net/attachments/501841539161522176/1161285342914170970/image.png?ex=6537be41&is=65254941&hm=3ace3096fd0a5d66cb8bfc8c744dbd79dcba84fc02cbaf7a02b01ffbcc7ed58d&=)
|
||||||
|
|
||||||
## Planned feature
|
## Planned feature
|
||||||
|
- Set prices for items.
|
||||||
|
- Specify quantities for items.
|
||||||
- Customize the category name.
|
- Customize the category name.
|
||||||
- Add images.
|
- Add images.
|
||||||
|
- Complete the Dockerfile for easy deployment
|
||||||
- Implement statistics for nerd
|
- Implement statistics for nerd
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#pragma once
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
const std::string BOT_TOKEN = "token";
|
const std::string BOT_TOKEN = "token";
|
||||||
|
18
src/main.cpp
18
src/main.cpp
@ -3,7 +3,6 @@
|
|||||||
#include <dpp/channel.h>
|
#include <dpp/channel.h>
|
||||||
#include <dpp/unicode_emoji.h>
|
#include <dpp/unicode_emoji.h>
|
||||||
|
|
||||||
#include "utils.hpp"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
int main(int ac, char **av)
|
int main(int ac, char **av)
|
||||||
@ -30,23 +29,10 @@ int main(int ac, char **av)
|
|||||||
dpp::embed embed = dpp::embed()
|
dpp::embed embed = dpp::embed()
|
||||||
.set_color(dpp::colors::sea_green)
|
.set_color(dpp::colors::sea_green)
|
||||||
.set_title(event.msg.content)
|
.set_title(event.msg.content)
|
||||||
|
//.add_field("Quantite", "1", true)
|
||||||
|
//.add_field("Prix", "3.29")
|
||||||
.set_author(event.msg.author.username, "", "")
|
.set_author(event.msg.author.username, "", "")
|
||||||
.set_footer(dpp::embed_footer().set_text("PyMenuVersion:2.0"));
|
.set_footer(dpp::embed_footer().set_text("PyMenuVersion:2.0"));
|
||||||
|
|
||||||
std::string str = event.msg.content;
|
|
||||||
|
|
||||||
unsigned int quantity;
|
|
||||||
float price;
|
|
||||||
|
|
||||||
get_article_data(str, quantity, price);
|
|
||||||
|
|
||||||
if (quantity != 0)
|
|
||||||
embed.add_field("Quantity", std::to_string(quantity));
|
|
||||||
|
|
||||||
if (price != 0)
|
|
||||||
embed.add_field("Price", std::to_string(price) + "€");
|
|
||||||
|
|
||||||
embed.set_title(str);
|
|
||||||
|
|
||||||
dpp::message msg(event.msg.channel_id, embed);
|
dpp::message msg(event.msg.channel_id, embed);
|
||||||
event.send(msg);
|
event.send(msg);
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
#include <cctype>
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstring>
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
static float get_price(std::string& str)
|
|
||||||
{
|
|
||||||
|
|
||||||
float price = 0;
|
|
||||||
const char* str_c = str.c_str();
|
|
||||||
char* next;
|
|
||||||
|
|
||||||
for (size_t i = 0; i != str.size(); i++)
|
|
||||||
{
|
|
||||||
price = std::strtof(str_c + i, &next);
|
|
||||||
if (next == NULL)
|
|
||||||
break;
|
|
||||||
if (std::strncmp(next, "€", 3) == 0)
|
|
||||||
{
|
|
||||||
str.erase(i, next - (str_c + i) + 3);
|
|
||||||
return price;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// pain 2€ 1
|
|
||||||
static int get_quantity(std::string& str)
|
|
||||||
{
|
|
||||||
unsigned int quantity = 0;
|
|
||||||
size_t len = 0, i;
|
|
||||||
|
|
||||||
for (i = 0; i != str.size(); i++)
|
|
||||||
{
|
|
||||||
std::cout << str[i] << std::endl;
|
|
||||||
if (!std::isdigit(str[i]))
|
|
||||||
{
|
|
||||||
if (quantity != 0)
|
|
||||||
break;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
quantity = quantity * 10 + str[i] - '0';
|
|
||||||
len++;
|
|
||||||
}
|
|
||||||
std::cout << str << std::endl;
|
|
||||||
str.erase(i - len, len);
|
|
||||||
return quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_article_data(std::string& str, unsigned int& quantity, float& price)
|
|
||||||
{
|
|
||||||
price = get_price(str);
|
|
||||||
std::cout << str << std::endl;
|
|
||||||
quantity = get_quantity(str);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
int get_article_data(std::string& str, unsigned int& quantity, float& price);
|
|
Loading…
Reference in New Issue
Block a user