-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mairror/feat/telegram_bot
feat: New telegram bot
- Loading branch information
Showing
22 changed files
with
826 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.dockerignore | ||
Dockerfile | ||
.hadolint.yml | ||
.git/ | ||
.gitignore | ||
.isort.cfg | ||
.pre-commit-config.yaml | ||
LICENSE | ||
Makefile | ||
README.md | ||
setup.cfg | ||
**/**/__pycache__/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Bug report | ||
description: You've found a bug with the Mairror API. | ||
labels: ['type:bug', 'status:requirements', 'priority-5-triage'] | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Before you begin to fill out the form, make sure you have actually found a bug. | ||
If you're not sure then create a [discussion](https://github.com/mairror/infrastructure/discussions) first. | ||
If you have questions or want help with Mairror infrastructure, then also create a [discussion](https://github.com/mairror/infrastructure/discussions). | ||
- type: dropdown | ||
id: how-are-you-running | ||
attributes: | ||
label: How are you running Mairror API? | ||
options: | ||
- 'Running without Docker' | ||
- 'Running using Docker' | ||
- 'Other' | ||
validations: | ||
required: true | ||
|
||
- type: dropdown | ||
id: what-component-is-causing-the-bug | ||
attributes: | ||
label: What component is causing the bug? | ||
options: | ||
- 'Python' | ||
- 'Dependencies' | ||
- 'Bot' | ||
validations: | ||
required: true | ||
|
||
- type: input | ||
id: commit-hash | ||
attributes: | ||
label: Tell us what is the commit hash you run. | ||
validations: | ||
required: false | ||
|
||
- type: dropdown | ||
id: regression-error | ||
attributes: | ||
label: Was this something which used to work for you, and then stopped? | ||
options: | ||
- 'It used to work, and then stopped' | ||
- 'I never saw this working' | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: describe-bug | ||
attributes: | ||
label: Describe the bug | ||
description: 'Do not report any security concerns here. Email organization members instead.' | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: debug-logs | ||
attributes: | ||
label: Relevant debug logs | ||
description: | | ||
Try not to raise a bug report unless you've looked at the logs first. | ||
Paste the *relevant* logs here, not the entire thing and not just a link. to the dashboard (others do not have permissions to view them). | ||
value: | | ||
<details><summary>Logs</summary> | ||
``` | ||
Copy/paste any log here, between the starting and ending backticks | ||
``` | ||
</details> | ||
validations: | ||
required: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
blank_issues_enabled: false | ||
contact_links: | ||
- name: Start a discussion (config, doubts, docs) | ||
url: https://github.com/mairror/telegram-bot/discussions/new | ||
about: If you have any questions about Mairror Telegram Bot configuration or doubts about whether you should create a feature request or bug report, or have problems with the documentation please click here to create a Discussion instead of an Issue. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Feature request | ||
description: Suggest an idea for this project. | ||
labels: ['type:feature', 'status:requirements', 'priority-5-triage'] | ||
body: | ||
- type: textarea | ||
id: what-would-you-like-renovate-to-be-able-to-do | ||
attributes: | ||
label: What would you like Mairror Telegram Bot to be able to do? | ||
description: Tell us what requirements you need solving, and be sure to mention too if this is part of any bigger problem you're trying to solve. | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: implementation-idea-textbox | ||
attributes: | ||
label: If you have any ideas on how this should be implemented, please tell us here. | ||
description: | | ||
In case you've already dug into existing options or source code and have ideas, mention them here. | ||
Try to keep implementation ideas separate from requirements. | ||
validations: | ||
required: true | ||
|
||
- type: dropdown | ||
id: interested-in-implementing-the-feature | ||
attributes: | ||
label: Is this a feature you are interested in implementing yourself? | ||
options: | ||
- 'Yes' | ||
- 'Maybe' | ||
- 'No' | ||
validations: | ||
required: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Refactor (internal) | ||
description: For internal use only. | ||
labels: ['type:refactor', 'status:requirements', 'priority-5-triage'] | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: '# This form is for Mairror maintainers only.' | ||
|
||
- type: textarea | ||
id: describe-proposed-changes | ||
attributes: | ||
label: Describe the proposed change(s). | ||
description: 'Do not report any security concerns here. Email the organization members instead.' | ||
validations: | ||
required: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/about-dependabot-version-updates | ||
# https://sysdogs.com/articles/automating-terraform-updates-with-dependabot | ||
|
||
# Set update schedule for GitHub Actions | ||
|
||
version: 2 | ||
updates: | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
target-branch: "main" | ||
schedule: | ||
interval: "weekly" | ||
assignees: | ||
- "aacecandev" | ||
- "blopezpi" | ||
commit-message: | ||
prefix: "[Github]" | ||
|
||
# Maintain dependencies for pip on telegram bot | ||
- package-ecosystem: "pip" | ||
directory: "/src" | ||
target-branch: "main" | ||
schedule: | ||
interval: "weekly" | ||
assignees: | ||
- "aacecandev" | ||
- "blopezpi" | ||
commit-message: | ||
prefix: "[PIP]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: "Build Bot" | ||
on: | ||
push: | ||
tags: | ||
- v*.*.* | ||
|
||
jobs: | ||
build-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: ${{ runner.os }}-buildx- | ||
|
||
- name: Login to DockerHub Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
|
||
- name: Push to Docker Hub | ||
uses: docker/build-push-action@v2 | ||
with: | ||
platforms: linux/amd64 | ||
push: true | ||
tags: | | ||
mairror/mairror-bot:${{ github.ref_name }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max | ||
|
||
- name: Move cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: "Release Bot" | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
new-release: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
persist-credentials: false | ||
- name: Semantic Release | ||
uses: cycjimmy/semantic-release-action@v2 | ||
id: semantic | ||
with: | ||
semantic_version: "18.0.1" | ||
extra_plugins: | | ||
@semantic-release/github@8.0.2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.PAT }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Docker linter https://github.com/hadolint/hadolint | ||
# # https://github.com/hadolint/hadolint#rules | ||
|
||
failure-threshold: warning | ||
|
||
label-schema: | ||
maintainer: text | ||
|
||
override: | ||
warning: | ||
- DL3049 # Label <label> is missing. | ||
info: | ||
- DL3008 # Specify version with apt-get install -y <package>=<version> | ||
- DL3013 # Pin versions in pip. Instead of `pip install <package>` use `pip install <package>==<version>` or `pip install --requirement <requirements file> | ||
- DL3018 # Pin versions in apk add. Instead of apk add <package> use apk add <package>=<version> | ||
- SC2174 # When used with -p, -m only applies to the deepest directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
hooks: | ||
- id: check-ast | ||
- id: check-byte-order-marker | ||
- id: check-case-conflict | ||
- id: check-docstring-first | ||
- id: check-executables-have-shebangs | ||
- id: check-json | ||
- id: check-yaml | ||
- id: debug-statements | ||
- id: detect-aws-credentials | ||
- id: detect-private-key | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: mixed-line-ending | ||
- repo: https://github.com/psf/black | ||
rev: 20.8b1 | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/asottile/blacken-docs | ||
rev: v1.8.0 | ||
hooks: | ||
- id: blacken-docs | ||
additional_dependencies: [black==20.8b1] | ||
- repo: https://github.com/zricethezav/gitleaks | ||
rev: v8.2.0 | ||
hooks: | ||
- id: gitleaks | ||
- repo: https://github.com/asottile/seed-isort-config | ||
rev: v2.2.0 | ||
hooks: | ||
- id: seed-isort-config | ||
- repo: https://github.com/pre-commit/mirrors-isort | ||
rev: v5.4.2 | ||
hooks: | ||
- id: isort | ||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v2.7.2 | ||
hooks: | ||
- id: pyupgrade | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.2.0 | ||
hooks: | ||
- id: check-ast # Is it valid Python? | ||
# Check for debugger imports and py37+ breakpoint() calls | ||
# in python source. | ||
- id: debug-statements | ||
# - repo: https://github.com/pre-commit/mirrors-mypy | ||
# # https://github.com/python/mypy | ||
# rev: v0.782 | ||
# hooks: | ||
# - id: mypy | ||
# args: [--ignore-missing-imports, --no-strict-optional, --show-error-codes] | ||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: '3.8.3' | ||
hooks: | ||
- id: flake8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"branches": ["main"], | ||
"plugins": [ | ||
"@semantic-release/github", | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
FROM python:3.9-slim | ||
|
||
# Maintainer of the Dockerfile | ||
LABEL maintainer="Mairror Team" | ||
|
||
# Input data | ||
ARG NON_ROOT_USER=nroot | ||
ARG ID=1000 | ||
|
||
# Hadolint DL4006 | ||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
||
# Switch to root user to make administrative tasks | ||
# hadolint ignore=DL3002 | ||
USER root | ||
|
||
# Change directory to /tmp to do administrative tasks | ||
WORKDIR /tmp | ||
|
||
# Create a non-root user group | ||
RUN addgroup ${NON_ROOT_USER} --gid ${ID} && \ | ||
adduser \ | ||
--disabled-password \ | ||
--uid ${ID} --gid ${ID} \ | ||
--shell /bin/bash \ | ||
--gecos "" \ | ||
${NON_ROOT_USER} | ||
|
||
# Upgrade OS && install all OS dependencies | ||
RUN apt-get update && \ | ||
# APT and /tmp cleanup | ||
apt-get clean && apt-get autoremove -y && \ | ||
rm -rf /var/lib/{apt,dpkg,cache,log}/ && \ | ||
rm -rf -- * | ||
|
||
WORKDIR /app | ||
|
||
# Change the ownership of /app to the non-root user | ||
RUN chown -R ${NON_ROOT_USER}:${NON_ROOT_USER} /app | ||
|
||
# Use non-root user | ||
USER ${NON_ROOT_USER} | ||
|
||
# Install python libraries | ||
COPY requirements.txt /app | ||
|
||
RUN pip install --upgrade pip==21.3.1 --no-cache-dir && \ | ||
pip install -r /app/requirements.txt --no-cache-dir | ||
|
||
|
||
# Add local files as late as possible to avoid cache busting | ||
COPY --chown=${NON_ROOT_USER}:${ID} src/ /app | ||
|
||
CMD ["python", "main.py"] |
Oops, something went wrong.