Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
317f329
:sparkles: Add Docker support (#168, #102)
Steffo99 Mar 28, 2022
339760a
:whale: Lowercase image tag
Steffo99 Mar 28, 2022
ad0372c
:pencil: Fix documentation error
Steffo99 Apr 14, 2022
0bd8a0c
:pencil: Better description of product deletion message
meh3lp May 10, 2022
55e14b1
Code refactor (#178)
meh3lp May 20, 2022
8701071
Migrate README to GitHub Wikis
Steffo99 Jun 6, 2022
bb99472
Add option to disable cash payments (#190)
Steffo99 Nov 19, 2022
fe751cb
Prevent bypassing the requirement for certain privileges
Steffo99 Nov 19, 2022
2087b7f
Build ARM Docker images
Steffo99 Dec 4, 2022
1ed470d
Update `Steffo99/actions-semver` to v0.3.5
Steffo99 Dec 4, 2022
1d13982
Do not run CodeQL on every push
Steffo99 Dec 4, 2022
b6fd156
Update built image tag names
Steffo99 Dec 4, 2022
29f3397
Add missing commas
Steffo99 Dec 4, 2022
85862a0
Do not tag images with the full name
Steffo99 Dec 4, 2022
3881012
Specify `linux/arm64/v8`
Steffo99 Dec 4, 2022
47337d0
Upgrade `docker/build-push-action` to v3.2.0
Steffo99 Dec 4, 2022
6007aa4
Remove `linux/arm/v7`, as pip is broken there?
Steffo99 Dec 4, 2022
2772309
Remove `linux/arm64/v8` too, as something does not work there
Steffo99 Dec 4, 2022
b6b3902
Improve GitHub Actions workflows (based on #198)
Steffo99 Dec 19, 2022
8bf23d4
Dockerfile refactoring (#198)
skrashevich Mar 22, 2023
c553e3d
Bump certifi from 2020.12.5 to 2022.12.7 (#197)
dependabot[bot] Mar 22, 2023
e9b6450
Bump requests from 2.25.1 to 2.31.0 (#202)
dependabot[bot] May 23, 2023
8c85f2b
Bump tornado from 6.1 to 6.3.2 (#203)
dependabot[bot] May 29, 2023
4ad9ef0
Bump certifi from 2022.12.7 to 2023.7.22
dependabot[bot] Jul 25, 2023
d1a8f01
Bump tornado from 6.3.2 to 6.3.3
dependabot[bot] Aug 14, 2023
1529e26
Bump urllib3 from 1.26.5 to 1.26.17
dependabot[bot] Oct 3, 2023
e513fa8
Bump urllib3 from 1.26.17 to 1.26.18
dependabot[bot] Oct 18, 2023
8f8a188
Add Hindi language (by @hybridvamp, in #218)
hybridvamp Oct 27, 2023
0cd756c
Ignore .directory files
Steffo99 May 14, 2024
13dc13e
Add extra documentation
Steffo99 May 14, 2024
74c1a85
Fix README links
Steffo99 May 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 0 additions & 70 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "Periodic quality and security analysis"

on:
# Every monday at 09:48 UTC
schedule:
- cron: "48 9 * * 1"
workflow_dispatch:

jobs:
codeql:
uses: Steffo99/.github/.github/workflows/quality-python-codeql.yml@main
permissions:
actions: read
contents: read
security-events: write
16 changes: 16 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "Release new version"

on:
# Creation of a new tag starting with v
push:
tags:
- "v*"

jobs:
test:
uses: ./.github/workflows/test.yml

ghcrio:
uses: Steffo99/.github/.github/workflows/buildrelease-docker.yml@main
needs:
- test
17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Test suite"

on:
# Modification of a project file in the main branch
push:
branches:
- main
# Pull request to the main branch modifying a project file
pull_request:
branches:
- main
# Triggered by a new release
workflow_call:

jobs:
test:
uses: Steffo99/.github/.github/workflows/test-poetry-compileall.yml@main
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,5 @@ config/config.ini
config/config.toml
*.sqlite
*.sqlite-journal
data/
.directory
Binary file added .media/icon-128x128_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .media/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .media/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .media/screenshot-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM python:3.10-alpine AS dependencies
RUN apk add --update build-base python3-dev py-pip musl-dev

WORKDIR /usr/src/greed
COPY ./requirements.txt ./requirements.txt
RUN pip install --no-cache-dir --requirement requirements.txt

#############################################################################

FROM python:3.10-slim AS final

COPY --from=dependencies /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages

WORKDIR /usr/src/greed
COPY . /usr/src/greed

ENTRYPOINT ["python", "-OO"]
CMD ["core.py"]

ENV PYTHONUNBUFFERED=1
ENV CONFIG_PATH="/etc/greed/config.toml"
ENV DB_ENGINE="sqlite:////var/lib/greed/database.sqlite"

LABEL org.opencontainers.image.title="greed"
LABEL org.opencontainers.image.description="A customizable, multilanguage Telegram shop bot"
LABEL org.opencontainers.image.licenses="AGPL-3.0-or-later"
LABEL org.opencontainers.image.url="https://github.com/Steffo99/greed/"
LABEL org.opencontainers.image.authors="Stefano Pigozzi <[email protected]>"
203 changes: 12 additions & 191 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,200 +1,21 @@
# Greed

A [customizable](/config/template_config.toml), [multilanguage](/strings) Telegram shop bot with [Telegram Payments support](https://core.telegram.org/bots/payments)!

## Demo

Send a message to [@greedtestbot](https://t.me/greedtestbot) on Telegram to view a demo of the bot in action!

Use the special credit card number `4242 4242 4242 4242` to add unlimited credit to your account.

## Screenshots

![](https://i.imgur.com/FdT2tRV.png)

![](https://i.imgur.com/rDYWdUB.png)

![](https://i.imgur.com/9plMzO6.png)

## Installation

This installation procedure assumes you are on a Linux system, using `bash` and have `python3.8` installed.

### Requirements

* [Git](https://git-scm.com/)
* [Python 3.6 (or higher)](https://www.python.org/)
* An Internet connection
* A Telegram bot token (obtainable at [@Botfather](https://t.me/Botfather))
* A payment provider token (obtainable by [connecting a provider with your bot](https://t.me/Botfather))

Consider renting a VPS to host the bot on; a cheap one should do, as greed is pretty lightweight! :)

### Steps

1. Download the project files by running:
```bash
git clone https://github.com/Steffo99/greed.git
```

2. Enter the newly created folder:
```bash
cd greed
```

3. Create a new virtualenv:
```bash
python3.8 -m venv venv
```

4. Activate the virtualenv:
```bash
source venv/bin/activate
```

5. Install the project requirements:
```bash
pip install -r requirements.txt
```

6. _Optional:_ For colored console output, install [coloredlogs](https://pypi.org/project/coloredlogs/):
```bash
pip install coloredlogs
```

7. Generate the configuration file:
```bash
python -OO core.py
```

8. Edit the configuration file, adding your bot and payment tokens to it:
```bash
nano config/config.toml
```
(Press **Ctrl+X** and then two times **Enter** to save and quit `nano`.)

9. _Optional:_ customize the files in the `strings` folder for custom messages.

10. Start the bot:
```bash
python -OO core.py
```

11. Open Telegram, and send a `/start` command to your bot to be automatically promoted to πŸ’Ό Manager.
<div align="center">

12. Stop the bot by pressing **Ctrl+C**.
![](.media/icon-128x128_round.png)

### Running the bot

After the installation, to run the bot, you'll need to:

1. Activate the virtualenv (if it's not already activated in the current console session):
```bash
source venv/bin/activate
```

2. Start the bot:
```bash
python -OO core.py
```

### Keep the bot running

If you want to keep the bot open even after you closed your terminal window, you'll need to use some external program.

Some of them are:

- `screen` (easier, but doesn't restart automatically)
- `systemd` (recommended, but more difficult)

#### `screen`

1. Open a `screen` that will be running the bot with the following command:
```bash
screen venv/bin/python -OO core.py
```
To safely detach the screen, press Ctrl+A and then Ctrl+D.

#### `systemd`

Assuming you downloaded `greed` in `/srv/greed`:

1. Create a new user named `greed`:
```bash
useradd greed --system
```

2. Give ownership of the greed folder you downloaded earlier to the `greed` user:
```bash
chown -R greed: /srv/greed
```

3. Create a new file in `/etc/systemd/system` named `bot-greed.service` with the following contents:
```ini
[Unit]
Name=bot-greed
Description=Greed Bot
Wants=network-online.target
After=network-online.target nss-lookup.target

[Service]
Type=exec
User=greed
WorkingDirectory=/srv/greed
ExecStart=/srv/greed/venv/bin/python -OO /srv/greed/core.py
Environment=PYTHONUNBUFFERED=1

[Install]
WantedBy=multi-user.target
```

4. Start the bot-greed service:
```bash
systemctl start bot-greed
```

5. If everything goes well, enable the bot-greed service, so it will automatically start on a reboot:
```bash
systemctl enable bot-greed
```

### Updating

To update the bot, run the following commands:

```bash
git stash
git pull
git stash pop
```

> If you're using an older version of greed, you may need to recreate the configuration, as greed won't use `config.ini` anymore and will use `config.toml` instead.

## Usage

All features can be accessed through the Telegram bot chat.

As a πŸ’Ό Manager, you can add new products, check the placed orders, create new transactions and generate .csv log files.
You can also add additional πŸ’Ό Managers.

Users will be able to add credit to their wallet, place orders and contact you in case they require assistance.

## Documentation and help

If you find a bug, have an idea for a new feature or just require help with `greed`, please [post an issue](https://github.com/Steffo99/greed/issues/new) or [open a discussion](https://github.com/Steffo99/greed/discussions/new) on GitHub, or, if GitHub is blocked in your country, send me an email at [[email protected]](mailto:[email protected])!
# Greed

If you can read Italian, you can try to read the [paper](https://docs.google.com/document/d/1f4MKVr0B7RSQfWTSa_6ZO0LM4nPpky_GX_qdls3EHtQ/edit?usp=sharing) I wrote about greed for my final High School exam.
[Customizable](config/template_config.toml) and [multilanguage](strings) Telegram shop bot with [Telegram Payments support](https://core.telegram.org/bots/payments)

If you are proficient in Python, you can also try reading the code. Most of the bot interactions can be found in the [`worker.py`](worker.py) file, so try to have a look there.
</div>

## Forks
## Links

[![Documentation](https://img.shields.io/badge/docs-available-blue)](docs/README.md)

Some people made a copy of Greed and added or changed some things to it (they made a _fork_).
These forks are listed below.
## Screenshots

> Please note that @Steffo99, the main developer of `greed`, does not endorse any of these forks.
> **Do not file bug reports here for bugs in a fork!**
![](.media/screenshot-1.png)

### Bitcoin - Blockonomics
![](.media/screenshot-2.png)

[DarrenWestwood](https://github.com/DarrenWestwood) is currently maintaining a [`greed`](https://github.com/DarrenWestwood/greed) fork adding **Bitcoin support** through [Blockonomics](https://www.blockonomics.co/).
![](.media/screenshot-3.png)
Loading