Skip to content

Commit e767d78

Browse files
committed
Release v1.2.0
1 parent b2b5e9c commit e767d78

5 files changed

Lines changed: 25 additions & 20 deletions

File tree

README.MD

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ pip3 install -r requirements.txt
1111

1212
### Setup
1313
In order to setup the bot you need to copy `example_credentials.json` to `credentials.json` in `config/example_credentials.json`.
14-
Then add Bot Token (get it from [@BotFather](https://t.me/Botfather)) and Amazon configuration to the file `credentials.json`
15-
14+
Then add Bot Token (get it from [@BotFather](https://t.me/Botfather)) and Amazon configuration to the file `credentials.json`.
15+
You need help configuring the bot? or maybe you want to host it? Find me out in telegram: [@xorgconfig](https://t.me/xorgconfig)
1616
### Running
1717
```
1818
#If you want just run the bot
@@ -28,6 +28,13 @@ Now customizing is more easy, you can go to `utils/create_message.py` and edit t
2828
![](https://telegra.ph/file/4d9dc08b6415986161fdd.png)
2929
### Changelog
3030
```
31+
Version 1.2.0
32+
New features:
33+
- Show the percentage if the item is discounted
34+
Updated:
35+
- python-amazon-paapi 3.3.2 --> 4.2.1
36+
- Some functions were updated due to the module upgrade
37+
3138
Version 1.1.0
3239
New features:
3340
- Remove message from user when post is submitted successfully

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from telegram import Update
55
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext
66
# Amazon Stuff
7-
from amazon.tools import get_asin # Get asin from url
7+
from amazon_paapi import get_asin # Get asin from url
88
from utils.create_message import amazon_message # Create HTML template for amazon
99
from utils.product_amazon import Product
1010
from utils.tools import check_domain

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
python-amazon-paapi==3.3.2
1+
python-amazon-paapi==4.2.1
22
amightygirl.paapi5-python-sdk==1.0.0
33
python-telegram-bot==13.4.1
44
requests==2.25.1

utils/create_message.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ def amazon_message(product, update):
44

55
first_name = update.message.from_user['first_name']
66

7-
if product.get_price().pvp.value != None:
8-
price = f"❌{product.get_price().pvp.value}{product.get_price().price.value}"
9-
10-
elif product.get_price().price.value != None:
11-
price = f"{product.get_price().price.value}"
7+
if product.get_price().savings != None:
8+
price = f"❌{product.get_price().amount + product.get_price().savings.amount}{product.get_price().amount} {product.get_price().currency} (-{product.get_price().savings.percentage}%) "
9+
10+
elif product.get_price().amount != None:
11+
price = f"{product.get_price().amount} "
1212

1313
else:
1414
price = "Not available"
1515

1616
message = f"""<a href='{product.get_image()}'>​​​​​​​​​​</a>
1717
📌<b>{product.get_title()}</b>
1818
19-
💰Price: {price}
19+
💰Price: {price}
2020
2121
🔗Link: <a href=\"{product.return_url()}\">Click Here</a>
2222

utils/product_amazon.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
11

22
import json
3-
from amazon.paapi import AmazonAPI
4-
3+
from amazon_paapi import AmazonApi
54
from .tools import check_domain # To return url with asin
65

76
with open('config/credentials.json') as config_file:
87
config = json.load(config_file)
98

109
amz_config = config['amazon']
11-
amazon = AmazonAPI(amz_config['KEY'], amz_config['SECRET'], amz_config['TAG'], amz_config['COUNTRY'])
10+
amazon = AmazonApi (amz_config['KEY'], amz_config['SECRET'], amz_config['TAG'], amz_config['COUNTRY'])
1211

1312

1413
class Product():
1514

1615
def __init__(self, asin):
1716
self.asin = asin
18-
self.product = amazon.get_product(asin)
17+
self.product = amazon.get_items(asin)[0]
1918

2019
def get_title(self):
21-
return self.product.title
20+
return self.product.item_info.title.display_value
2221

2322
def get_price(self):
24-
25-
return self.product.prices
23+
return self.product.offers.listings[0].price
2624

2725
def get_image(self):
28-
return self.product.images.large
26+
return self.product.images.primary.large.url
2927

3028
def get_info(self):
31-
return self.product.raw_info
29+
return self.product
3230

3331
def return_url(self):
34-
url = self.product.raw_info.detail_page_url
32+
url = self.product.detail_page_url
3533
return 'https://' + check_domain(url) + 'dp/' + self.asin + '/?tag=' + amz_config['TAG']

0 commit comments

Comments
 (0)