mirror of
https://github.com/nikdoof/smsbot.git
synced 2025-12-13 10:02:15 +00:00
Compare commits
23 Commits
smsbot-hel
...
0.0.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
74dac7603e
|
|||
|
076e2464a0
|
|||
|
85c72462c4
|
|||
| 41971aabdf | |||
| befa3df48d | |||
| d504dfb95d | |||
| e51541c79a | |||
| cd3699f185 | |||
| 7d7aa97c24 | |||
|
|
d51c6fbe73 | ||
| 21276e1c24 | |||
|
|
4e15d4a8ed | ||
| b1bdcb456a | |||
| f7a151235a | |||
| 1d8b177cb4 | |||
|
|
3389144484 | ||
|
|
aa3ca58b58 | ||
|
|
2854626c27 | ||
|
|
dc0745ce76 | ||
|
|
19f8183ddc | ||
|
|
f51928cb4b | ||
|
|
80be469a90 | ||
|
|
076216e089 |
8
.github/workflows/build-container.yaml
vendored
8
.github/workflows/build-container.yaml
vendored
@@ -12,11 +12,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v3
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
- name: Login to GHCR
|
- name: Login to GHCR
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
@@ -24,7 +24,7 @@ jobs:
|
|||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
id: docker_build
|
id: docker_build
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
|
|||||||
27
.github/workflows/lint.yaml
vendored
27
.github/workflows/lint.yaml
vendored
@@ -1,6 +1,6 @@
|
|||||||
name: Lint
|
name: Lint
|
||||||
|
|
||||||
'on':
|
"on":
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
@@ -9,13 +9,22 @@ name: Lint
|
|||||||
- main
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run-linters:
|
lint:
|
||||||
name: Run linters
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ["3.9"]
|
||||||
steps:
|
steps:
|
||||||
- name: Check out Git repository
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v3
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
- name: wemake-python-styleguide
|
with:
|
||||||
uses: wemake-services/wemake-python-styleguide@0.17.0
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Install Poetry
|
||||||
|
uses: snok/install-poetry@v1
|
||||||
|
with:
|
||||||
|
virtualenvs-create: true
|
||||||
|
virtualenvs-in-project: true
|
||||||
|
- name: Lint with ruff
|
||||||
|
run: |
|
||||||
|
make lint
|
||||||
|
|||||||
6
.github/workflows/release-chart.yaml
vendored
6
.github/workflows/release-chart.yaml
vendored
@@ -12,7 +12,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
@@ -21,12 +21,12 @@ jobs:
|
|||||||
git config user.name "$GITHUB_ACTOR"
|
git config user.name "$GITHUB_ACTOR"
|
||||||
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
||||||
- name: Install Helm
|
- name: Install Helm
|
||||||
uses: azure/setup-helm@v3
|
uses: azure/setup-helm@v4
|
||||||
with:
|
with:
|
||||||
version: v3.6.3
|
version: v3.6.3
|
||||||
|
|
||||||
- name: Run chart-releaser
|
- name: Run chart-releaser
|
||||||
uses: helm/chart-releaser-action@v1.5.0
|
uses: helm/chart-releaser-action@v1.6.0
|
||||||
env:
|
env:
|
||||||
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
CR_RELEASE_NAME_TEMPLATE: "smsbot-helm-chart-{{ .Version }}"
|
CR_RELEASE_NAME_TEMPLATE: "smsbot-helm-chart-{{ .Version }}"
|
||||||
|
|||||||
22
.github/workflows/release.yaml
vendored
22
.github/workflows/release.yaml
vendored
@@ -1,4 +1,3 @@
|
|||||||
---
|
|
||||||
name: Release
|
name: Release
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -10,20 +9,23 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: actions/setup-python@v4
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
|
||||||
|
- name: Install Poetry
|
||||||
|
uses: snok/install-poetry@v1
|
||||||
with:
|
with:
|
||||||
python-version: '3.10'
|
virtualenvs-create: true
|
||||||
- run: pip install -r requirements-dev.txt
|
virtualenvs-in-project: true
|
||||||
|
|
||||||
- name: Build Assets
|
- name: Build Release
|
||||||
run: python setup.py sdist bdist_wheel
|
run: poetry build
|
||||||
|
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
name: "Version ${{ github.ref_name }}"
|
name: "Version ${{ github.ref_name }}"
|
||||||
generate_release_notes: true
|
|
||||||
files: |
|
files: |
|
||||||
dist/*
|
dist/*
|
||||||
|
|||||||
37
Dockerfile
37
Dockerfile
@@ -1,5 +1,34 @@
|
|||||||
FROM python:3.11-alpine
|
FROM python:3.9-alpine AS base
|
||||||
WORKDIR /app
|
|
||||||
|
FROM base AS builder
|
||||||
|
|
||||||
|
ENV PYTHONFAULTHANDLER=1 \
|
||||||
|
PYTHONUNBUFFERED=1 \
|
||||||
|
PYTHONHASHSEED=random \
|
||||||
|
PIP_NO_CACHE_DIR=off \
|
||||||
|
PIP_DISABLE_PIP_VERSION_CHECK=on \
|
||||||
|
PIP_DEFAULT_TIMEOUT=100 \
|
||||||
|
POETRY_NO_INTERACTION=1 \
|
||||||
|
POETRY_VIRTUALENVS_CREATE=false \
|
||||||
|
PATH="$PATH:/runtime/bin" \
|
||||||
|
PYTHONPATH="$PYTHONPATH:/runtime/lib/python3.9/site-packages" \
|
||||||
|
# Versions:
|
||||||
|
POETRY_VERSION=2.1.1
|
||||||
|
|
||||||
|
# System deps:
|
||||||
|
RUN apk add build-base unzip wget python3-dev libffi-dev rust cargo openssl-dev
|
||||||
|
RUN pip install "poetry==$POETRY_VERSION" "poetry-plugin-export"
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
# Generate requirements and install *all* dependencies.
|
||||||
|
COPY pyproject.toml poetry.lock /src/
|
||||||
|
RUN poetry export --without-hashes --no-interaction --no-ansi -f requirements.txt -o requirements.txt
|
||||||
|
RUN pip install --prefix=/runtime --force-reinstall -r requirements.txt
|
||||||
|
|
||||||
|
FROM base AS runtime
|
||||||
|
COPY --from=builder /runtime /usr/local
|
||||||
COPY . /app
|
COPY . /app
|
||||||
RUN pip install .
|
WORKDIR /app
|
||||||
ENTRYPOINT smsbot
|
EXPOSE 8000/tcp
|
||||||
|
CMD ["/usr/local/bin/smsbot"]
|
||||||
7
Makefile
Normal file
7
Makefile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
.venv:
|
||||||
|
python3 -m pip install poetry
|
||||||
|
python3 -m poetry install --with github
|
||||||
|
|
||||||
|
lint: .venv
|
||||||
|
python3 -m poetry run ruff check --output-format=github --select=E9,F63,F7,F82 --target-version=py37 .
|
||||||
|
python3 -m poetry run ruff check --output-format=github --target-version=py37 .
|
||||||
1466
poetry.lock
generated
Normal file
1466
poetry.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
36
pyproject.toml
Normal file
36
pyproject.toml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
[project]
|
||||||
|
name = "smsbot"
|
||||||
|
version = "0.0.5"
|
||||||
|
description = "A simple Telegram bot to receive SMS messages."
|
||||||
|
authors = [
|
||||||
|
{name = "Andrew Williams",email = "andy@tensixtyone.com"}
|
||||||
|
]
|
||||||
|
license = {text = "MIT"}
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.9,<3.10"
|
||||||
|
dependencies = [
|
||||||
|
"flask (>=3.1.0,<4.0.0)",
|
||||||
|
"waitress (>=3.0.2,<4.0.0)",
|
||||||
|
"twilio (>=9.4.6,<10.0.0)",
|
||||||
|
"python-telegram-bot (<20)",
|
||||||
|
"prometheus-client (>=0.21.1,<0.22.0)"
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.poetry.scripts]
|
||||||
|
smsbot = "smsbot.cli:main"
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
||||||
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
|
[tool.poetry.group.dev.dependencies]
|
||||||
|
pytest = "^8.0.0"
|
||||||
|
ruff = "^0.9.0"
|
||||||
|
pytest-mock = "^3.12.0"
|
||||||
|
pytest-flask = "^1.3.0"
|
||||||
|
|
||||||
|
[tool.poetry.group.github]
|
||||||
|
optional = true
|
||||||
|
|
||||||
|
[tool.poetry.group.github.dependencies]
|
||||||
|
pytest-github-actions-annotate-failures = "^0.3.0"
|
||||||
@@ -1 +0,0 @@
|
|||||||
wheel
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
flask
|
|
||||||
waitress
|
|
||||||
twilio
|
|
||||||
python-telegram-bot
|
|
||||||
prometheus_client
|
|
||||||
36
setup.cfg
36
setup.cfg
@@ -1,36 +0,0 @@
|
|||||||
[metadata]
|
|
||||||
name = smsbot
|
|
||||||
version = 0.0.4
|
|
||||||
description = A simple Telegram bot to receive SMS messages.
|
|
||||||
long_description = file: README.md, LICENSE
|
|
||||||
license = MIT
|
|
||||||
license_file = LICENSE
|
|
||||||
classifiers =
|
|
||||||
Framework :: Flask
|
|
||||||
License :: OSI Approved :: MIT License
|
|
||||||
Programming Language :: Python :: 3
|
|
||||||
Programming Language :: Python :: 3.11
|
|
||||||
|
|
||||||
[options]
|
|
||||||
zip_safe = False
|
|
||||||
include_package_data = True
|
|
||||||
packages = smsbot
|
|
||||||
install_requires =
|
|
||||||
flask
|
|
||||||
waitress
|
|
||||||
twilio
|
|
||||||
python-telegram-bot<=14
|
|
||||||
prometheus_client
|
|
||||||
|
|
||||||
[options.entry_points]
|
|
||||||
console_scripts =
|
|
||||||
smsbot = smsbot.cli:main
|
|
||||||
|
|
||||||
[flake8]
|
|
||||||
format = wemake
|
|
||||||
ignore = D,E501,WPS432,WPS323,WPS2,S104,WPS412,WPS100
|
|
||||||
max-line-length = 120
|
|
||||||
exclude = setup.py,env,build
|
|
||||||
|
|
||||||
[darglint]
|
|
||||||
docstring_style=sphinx
|
|
||||||
@@ -2,12 +2,9 @@ import argparse
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import pkg_resources
|
|
||||||
|
|
||||||
from smsbot.telegram import TelegramSmsBot
|
from smsbot.telegram import TelegramSmsBot
|
||||||
from smsbot.webhook_handler import TwilioWebhookHandler
|
from smsbot.webhook_handler import TwilioWebhookHandler
|
||||||
|
from smsbot.utils import get_smsbot_version
|
||||||
pkg_version = pkg_resources.require('smsbot')[0].version
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -21,7 +18,7 @@ def main():
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
logging.basicConfig(level=logging.getLevelName(args.log_level))
|
logging.basicConfig(level=logging.getLevelName(args.log_level))
|
||||||
logging.info('smsbot v%s', pkg_version)
|
logging.info('smsbot v%s', get_smsbot_version())
|
||||||
logging.debug('Arguments: %s', args)
|
logging.debug('Arguments: %s', args)
|
||||||
|
|
||||||
# Start bot
|
# Start bot
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import pkg_resources
|
from importlib.metadata import version
|
||||||
|
|
||||||
|
|
||||||
def get_smsbot_version():
|
def get_smsbot_version():
|
||||||
return pkg_resources.require('smsbot')[0].version
|
return version("smsbot")
|
||||||
|
|||||||
Reference in New Issue
Block a user