create-tg-shop 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: create-tg-shop
3
+ Version: 0.1.0
4
+ Summary: Turn any online shop into a Telegram storefront bot — scaffold, scrape, and launch in under a minute
5
+ Author-email: Zak Krevitt <zakkrevitt@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/ZakKrevitt/shop-to-telegram-template
8
+ Project-URL: Repository, https://github.com/ZakKrevitt/shop-to-telegram-template
9
+ Keywords: telegram,bot,shop,ecommerce,scraper,cli
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Environment :: Console
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: python-telegram-bot
16
+ Requires-Dist: requests
17
+ Requires-Dist: beautifulsoup4
18
+ Requires-Dist: playwright
19
+ Requires-Dist: python-dotenv
20
+
21
+ # create-tg-shop
22
+
23
+ Turn any online shop into a Telegram storefront bot — scrape products, let users browse, add to cart, and checkout, all inside Telegram.
24
+
25
+ ## Quickstart
26
+
27
+ **Python (pip):**
28
+ ```bash
29
+ pip install create-tg-shop
30
+ create-tg-shop
31
+ ```
32
+
33
+ **Node (npx) — no install needed:**
34
+ ```bash
35
+ npx create-tg-shop
36
+ ```
37
+
38
+ The wizard scaffolds a project, asks for your Telegram bot token and shop URL, installs dependencies, and gets you running in under a minute.
39
+
40
+ ## What it sets up
41
+
42
+ - `bot.py` — ShopEngine + CartManager + Telegram message formatting
43
+ - `scraper.py` — base scraper class (plug in Playwright or BeautifulSoup)
44
+ - `products.json` — product catalog (edit directly or regenerate via scraper)
45
+ - `.env` — your bot token and shop config
46
+
47
+ ## Customizing
48
+
49
+ - Implement `ShopScraper.scrape()` to pull real products from your shop
50
+ - Wire the checkout callback to Stripe, Shopify, or your payment provider
51
+ - Swap CartManager for Redis/database for persistent carts
52
+
53
+ ## License
54
+
55
+ MIT
@@ -0,0 +1,35 @@
1
+ # create-tg-shop
2
+
3
+ Turn any online shop into a Telegram storefront bot — scrape products, let users browse, add to cart, and checkout, all inside Telegram.
4
+
5
+ ## Quickstart
6
+
7
+ **Python (pip):**
8
+ ```bash
9
+ pip install create-tg-shop
10
+ create-tg-shop
11
+ ```
12
+
13
+ **Node (npx) — no install needed:**
14
+ ```bash
15
+ npx create-tg-shop
16
+ ```
17
+
18
+ The wizard scaffolds a project, asks for your Telegram bot token and shop URL, installs dependencies, and gets you running in under a minute.
19
+
20
+ ## What it sets up
21
+
22
+ - `bot.py` — ShopEngine + CartManager + Telegram message formatting
23
+ - `scraper.py` — base scraper class (plug in Playwright or BeautifulSoup)
24
+ - `products.json` — product catalog (edit directly or regenerate via scraper)
25
+ - `.env` — your bot token and shop config
26
+
27
+ ## Customizing
28
+
29
+ - Implement `ShopScraper.scrape()` to pull real products from your shop
30
+ - Wire the checkout callback to Stripe, Shopify, or your payment provider
31
+ - Swap CartManager for Redis/database for persistent carts
32
+
33
+ ## License
34
+
35
+ MIT
@@ -0,0 +1,2 @@
1
+ # create-tg-shop
2
+ __version__ = "0.1.0"
@@ -0,0 +1,250 @@
1
+ import os
2
+ import sys
3
+ import subprocess
4
+ import shutil
5
+
6
+ BOLD = "\033[1m"
7
+ GREEN = "\033[0;32m"
8
+ CYAN = "\033[0;36m"
9
+ YELLOW= "\033[1;33m"
10
+ RED = "\033[0;31m"
11
+ RESET = "\033[0m"
12
+
13
+ TEMPLATE_FILES = {
14
+ "bot.py": '''\
15
+ import os
16
+ import json
17
+ from typing import Dict, List, Optional
18
+ from scraper import Product, load_products
19
+
20
+ class CartManager:
21
+ def __init__(self):
22
+ self.carts: Dict[int, Dict[str, int]] = {}
23
+
24
+ def add_to_cart(self, user_id: int, product_id: str):
25
+ if user_id not in self.carts:
26
+ self.carts[user_id] = {}
27
+ self.carts[user_id][product_id] = self.carts[user_id].get(product_id, 0) + 1
28
+
29
+ def get_cart(self, user_id: int) -> Dict[str, int]:
30
+ return self.carts.get(user_id, {})
31
+
32
+ def clear_cart(self, user_id: int):
33
+ self.carts[user_id] = {}
34
+
35
+ class ShopEngine:
36
+ def __init__(self, products_path: str):
37
+ self.products = load_products(products_path)
38
+ self.cart_manager = CartManager()
39
+
40
+ def search(self, query: str) -> List[Product]:
41
+ if not query:
42
+ return self.products
43
+ query = query.lower()
44
+ return [p for p in self.products if
45
+ query in p.name.lower() or
46
+ query in p.description.lower() or
47
+ any(query in t.lower() for t in p.tags)]
48
+
49
+ def get_product_by_id(self, product_id: str) -> Optional[Product]:
50
+ return next((p for p in self.products if p.id == product_id), None)
51
+
52
+ def get_product_markup(product):
53
+ return [
54
+ [{"text": f"Add to Cart - ${product.price}", "callback_data": f"add_{product.id}"}],
55
+ [{"text": "View on Site", "url": product.url}]
56
+ ]
57
+
58
+ def get_cart_markup():
59
+ return [
60
+ [{"text": "🛒 View Cart", "callback_data": "view_cart"}],
61
+ [{"text": "💳 Checkout", "callback_data": "checkout"}]
62
+ ]
63
+
64
+ def format_product_caption(product) -> str:
65
+ return (
66
+ f"**{product.name}**\\n\\n"
67
+ f"{product.description}\\n\\n"
68
+ f"Price: {product.currency} {product.price}\\n"
69
+ f"Tags: {', '.join(product.tags)}"
70
+ )
71
+
72
+ if __name__ == "__main__":
73
+ engine = ShopEngine("products.json")
74
+ print(f"Loaded {len(engine.products)} products.")
75
+ ''',
76
+
77
+ "scraper.py": '''\
78
+ import json
79
+ from dataclasses import dataclass, asdict
80
+ from typing import List
81
+
82
+ @dataclass
83
+ class Product:
84
+ id: str
85
+ name: str
86
+ description: str
87
+ price: float
88
+ currency: str
89
+ image_url: str
90
+ url: str
91
+ tags: List[str]
92
+
93
+ class ShopScraper:
94
+ """
95
+ Base scraper. Replace scrape() with real Playwright or BeautifulSoup logic.
96
+ """
97
+ def __init__(self, shop_url: str):
98
+ self.shop_url = shop_url
99
+
100
+ def scrape(self) -> List[Product]:
101
+ return [
102
+ Product("p1", "Minimalist Desk Lamp",
103
+ "Elegant LED lamp with adjustable brightness.",
104
+ 89.0, "USD", "https://images.unsplash.com/photo-1534073828943-f801091bb18c",
105
+ f"{self.shop_url}/products/lamp", ["lighting", "minimalist", "office"]),
106
+ Product("p2", "Ergonomic Walnut Stand",
107
+ "Hand-crafted walnut wood laptop stand.",
108
+ 120.0, "USD", "https://images.unsplash.com/photo-1527443224154-c4a3942d3acf",
109
+ f"{self.shop_url}/products/stand", ["accessories", "wood", "ergonomic"]),
110
+ Product("p3", "Mechanical Keyboard",
111
+ "Compact 65% layout with hot-swappable switches.",
112
+ 150.0, "USD", "https://images.unsplash.com/photo-1511467687858-23d96c32e4ae",
113
+ f"{self.shop_url}/products/keyboard", ["tech", "peripheral", "keyboard"]),
114
+ ]
115
+
116
+ def save_products(products: List[Product], filepath: str):
117
+ with open(filepath, "w") as f:
118
+ json.dump([asdict(p) for p in products], f, indent=2)
119
+
120
+ def load_products(filepath: str) -> List[Product]:
121
+ try:
122
+ with open(filepath, "r") as f:
123
+ return [Product(**p) for p in json.load(f)]
124
+ except FileNotFoundError:
125
+ return []
126
+
127
+ if __name__ == "__main__":
128
+ import os
129
+ url = os.getenv("SHOP_URL", "https://example.com")
130
+ scraper = ShopScraper(url)
131
+ products = scraper.scrape()
132
+ save_products(products, "products.json")
133
+ print(f"Saved {len(products)} products to products.json")
134
+ ''',
135
+
136
+ "products.json": '''\
137
+ [
138
+ {
139
+ "id": "p1",
140
+ "name": "Minimalist Desk Lamp",
141
+ "description": "Elegant LED lamp with adjustable brightness and warm color temperature.",
142
+ "price": 89.0,
143
+ "currency": "USD",
144
+ "image_url": "https://images.unsplash.com/photo-1534073828943-f801091bb18c",
145
+ "url": "https://example.com/products/lamp",
146
+ "tags": ["lighting", "minimalist", "office"]
147
+ },
148
+ {
149
+ "id": "p2",
150
+ "name": "Ergonomic Walnut Stand",
151
+ "description": "Hand-crafted walnut wood laptop stand.",
152
+ "price": 120.0,
153
+ "currency": "USD",
154
+ "image_url": "https://images.unsplash.com/photo-1527443224154-c4a3942d3acf",
155
+ "url": "https://example.com/products/stand",
156
+ "tags": ["accessories", "wood", "ergonomic"]
157
+ }
158
+ ]
159
+ ''',
160
+
161
+ ".env.example": '''\
162
+ TELEGRAM_BOT_TOKEN=your_token_here
163
+ SHOP_URL=https://yourshop.com
164
+ SHOP_NAME=My Shop
165
+ ''',
166
+
167
+ "requirements.txt": '''\
168
+ python-telegram-bot
169
+ requests
170
+ beautifulsoup4
171
+ playwright
172
+ python-dotenv
173
+ ''',
174
+ }
175
+
176
+ def wizard():
177
+ print()
178
+ print(f"{BOLD}──────────────────────────────────────────{RESET}")
179
+ print(f"{BOLD} 🛍️ agentic-shop-tg | setup wizard{RESET}")
180
+ print(f"{BOLD}──────────────────────────────────────────{RESET}")
181
+ print()
182
+
183
+ # Directory
184
+ default_dir = "my-shop-bot"
185
+ raw = input(f"{CYAN}Project folder name [{default_dir}]: {RESET}").strip()
186
+ target = raw or default_dir
187
+
188
+ if os.path.exists(target):
189
+ print(f"{YELLOW}⚠ '{target}' already exists.{RESET}")
190
+ confirm = input(" Overwrite? [y/N]: ").strip().lower()
191
+ if confirm != "y":
192
+ sys.exit(0)
193
+ shutil.rmtree(target)
194
+
195
+ os.makedirs(target)
196
+
197
+ # Write template files
198
+ for filename, content in TEMPLATE_FILES.items():
199
+ filepath = os.path.join(target, filename)
200
+ with open(filepath, "w") as f:
201
+ f.write(content)
202
+
203
+ print(f"{GREEN}✔ Project scaffolded in ./{target}{RESET}")
204
+ print()
205
+
206
+ # Bot token
207
+ print(f" Get your token from {CYAN}@BotFather{RESET} on Telegram (/newbot)")
208
+ token = input(" Telegram Bot Token: ").strip()
209
+
210
+ # Shop URL
211
+ shop_url = input(" Your shop URL [https://example.com]: ").strip() or "https://example.com"
212
+ shop_name = input(" Shop name [My Shop]: ").strip() or "My Shop"
213
+
214
+ # Write .env
215
+ with open(os.path.join(target, ".env"), "w") as f:
216
+ f.write(f"TELEGRAM_BOT_TOKEN={token}\n")
217
+ f.write(f"SHOP_URL={shop_url}\n")
218
+ f.write(f"SHOP_NAME={shop_name}\n")
219
+
220
+ print(f"{GREEN}✔ .env written{RESET}")
221
+ print()
222
+
223
+ # Install deps
224
+ venv_path = os.path.join(target, ".venv")
225
+ print(f"{CYAN}Creating virtual environment...{RESET}")
226
+ subprocess.run([sys.executable, "-m", "venv", venv_path], check=True)
227
+
228
+ pip = os.path.join(venv_path, "bin", "pip") if os.name != "nt" else os.path.join(venv_path, "Scripts", "pip")
229
+ print(f"{CYAN}Installing dependencies...{RESET}")
230
+ subprocess.run([pip, "install", "--quiet", "-r", os.path.join(target, "requirements.txt")], check=True)
231
+ print(f"{GREEN}✔ Dependencies installed{RESET}")
232
+
233
+ # Done
234
+ print()
235
+ print(f"{BOLD}──────────────────────────────────────────{RESET}")
236
+ print(f"{BOLD} ✅ Ready!{RESET}")
237
+ print(f"{BOLD}──────────────────────────────────────────{RESET}")
238
+ print()
239
+ print(f" {CYAN}cd {target}{RESET}")
240
+ print(f" {CYAN}source .venv/bin/activate{RESET} (or .venv\\Scripts\\activate on Windows)")
241
+ print()
242
+ print(f" Scrape your shop: {CYAN}python scraper.py{RESET}")
243
+ print(f" Start the bot: {CYAN}python bot.py{RESET}")
244
+ print()
245
+
246
+ def main():
247
+ wizard()
248
+
249
+ if __name__ == "__main__":
250
+ main()
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: create-tg-shop
3
+ Version: 0.1.0
4
+ Summary: Turn any online shop into a Telegram storefront bot — scaffold, scrape, and launch in under a minute
5
+ Author-email: Zak Krevitt <zakkrevitt@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/ZakKrevitt/shop-to-telegram-template
8
+ Project-URL: Repository, https://github.com/ZakKrevitt/shop-to-telegram-template
9
+ Keywords: telegram,bot,shop,ecommerce,scraper,cli
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Environment :: Console
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: python-telegram-bot
16
+ Requires-Dist: requests
17
+ Requires-Dist: beautifulsoup4
18
+ Requires-Dist: playwright
19
+ Requires-Dist: python-dotenv
20
+
21
+ # create-tg-shop
22
+
23
+ Turn any online shop into a Telegram storefront bot — scrape products, let users browse, add to cart, and checkout, all inside Telegram.
24
+
25
+ ## Quickstart
26
+
27
+ **Python (pip):**
28
+ ```bash
29
+ pip install create-tg-shop
30
+ create-tg-shop
31
+ ```
32
+
33
+ **Node (npx) — no install needed:**
34
+ ```bash
35
+ npx create-tg-shop
36
+ ```
37
+
38
+ The wizard scaffolds a project, asks for your Telegram bot token and shop URL, installs dependencies, and gets you running in under a minute.
39
+
40
+ ## What it sets up
41
+
42
+ - `bot.py` — ShopEngine + CartManager + Telegram message formatting
43
+ - `scraper.py` — base scraper class (plug in Playwright or BeautifulSoup)
44
+ - `products.json` — product catalog (edit directly or regenerate via scraper)
45
+ - `.env` — your bot token and shop config
46
+
47
+ ## Customizing
48
+
49
+ - Implement `ShopScraper.scrape()` to pull real products from your shop
50
+ - Wire the checkout callback to Stripe, Shopify, or your payment provider
51
+ - Swap CartManager for Redis/database for persistent carts
52
+
53
+ ## License
54
+
55
+ MIT
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ create_tg_shop/__init__.py
4
+ create_tg_shop/cli.py
5
+ create_tg_shop.egg-info/PKG-INFO
6
+ create_tg_shop.egg-info/SOURCES.txt
7
+ create_tg_shop.egg-info/dependency_links.txt
8
+ create_tg_shop.egg-info/entry_points.txt
9
+ create_tg_shop.egg-info/requires.txt
10
+ create_tg_shop.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ create-tg-shop = create_tg_shop.cli:main
@@ -0,0 +1,5 @@
1
+ python-telegram-bot
2
+ requests
3
+ beautifulsoup4
4
+ playwright
5
+ python-dotenv
@@ -0,0 +1 @@
1
+ create_tg_shop
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "create-tg-shop"
7
+ version = "0.1.0"
8
+ description = "Turn any online shop into a Telegram storefront bot — scaffold, scrape, and launch in under a minute"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ authors = [
13
+ {name = "Zak Krevitt", email = "zakkrevitt@gmail.com"}
14
+ ]
15
+ keywords = ["telegram", "bot", "shop", "ecommerce", "scraper", "cli"]
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "Operating System :: OS Independent",
19
+ "Environment :: Console",
20
+ ]
21
+ dependencies = [
22
+ "python-telegram-bot",
23
+ "requests",
24
+ "beautifulsoup4",
25
+ "playwright",
26
+ "python-dotenv",
27
+ ]
28
+
29
+ [project.scripts]
30
+ create-tg-shop = "create_tg_shop.cli:main"
31
+
32
+ [project.urls]
33
+ Homepage = "https://github.com/ZakKrevitt/shop-to-telegram-template"
34
+ Repository = "https://github.com/ZakKrevitt/shop-to-telegram-template"
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = ["."]
38
+ include = ["create_tg_shop*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+