From 642fa815847487b4ea36e4434102f8c541ae0b43 Mon Sep 17 00:00:00 2001 From: saddydead1 Date: Wed, 24 Dec 2025 22:13:09 +0300 Subject: [PATCH] first commit --- .dockerignore | 3 ++ .github/workflows/deploy.yml | 24 ++++++++++++++ .gitignore | 2 ++ Dockerfile | 9 ++++++ LICENSE | 21 ++++++++++++ requirements.txt | 3 ++ src/main.py | 63 ++++++++++++++++++++++++++++++++++++ 7 files changed, 125 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/deploy.yml create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 requirements.txt create mode 100644 src/main.py diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3dfd8e2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.gitignore +LICENSE +penis.db \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..b14ce20 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,24 @@ +name: docker + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + docker-push: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Build the Docker image + run: docker build -t docker.sonoma.su/penisbot . + + - name: Login Sonoma Docker registry + run: docker login docker.sonoma.su --username ${{ secrets.DOCKER_LOGIN }} --password ${{ secrets.DOCKER_PASSWORD }} + + - name: Push image + run: docker push docker.sonoma.su/penisbot \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..df5032b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env +penis.db \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7256c98 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.13-bookworm + +COPY ./src /src +COPY ./requirements.txt /src + +RUN apt update +RUN pip install -r /app/requirements.txt + +CMD [ "python", "/src/main.py" ] \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..074d6b1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 SaddyDEAD + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..3c25ed4 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +aiogram +sqlite3 +asyncio \ No newline at end of file diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..57e2d49 --- /dev/null +++ b/src/main.py @@ -0,0 +1,63 @@ +import asyncio +import logging +import sys +import sqlite3 +from os import getenv + +from aiogram import Bot, Dispatcher, html +from aiogram.client.default import DefaultBotProperties +from aiogram.enums import ParseMode +from aiogram.filters import CommandStart, Command +from aiogram.types import Message + + +TOKEN = "8549282447:AAGyzuDjOa6V7fqvxCsVUYydp9VEn4t7t3M" + + +dp = Dispatcher() +con = sqlite3.connect("penis.db") +cur = con.cursor() + +@dp.message(CommandStart()) +async def command_start_handler(message: Message) -> None: + await message.answer(f"Hello, {html.bold(message.from_user.full_name)}!") + + +@dp.message(Command("penis")) +async def handler(message: Message) -> None: + res = cur.execute(f"SELECT user FROM penis WHERE user={message.from_user.id}").fetchone() + + if res == None: + await message.answer(f"У вас пенисов: {html.bold(0)}") + else: + penis = cur.execute(f"SELECT count FROM penis WHERE user={message.from_user.id}").fetchone() + await message.answer(f"У вас пенисов: {html.bold(penis[0])}") + + +@dp.message() +async def echo_handler(message: Message) -> None: + if message.text == "пенис" or message.text == "Пенис": + res = cur.execute(f"SELECT user FROM penis WHERE user={message.from_user.id}").fetchone() + + if res == None: + cur.execute(f"INSERT INTO penis VALUES ({message.from_user.id}, 0)") + + cur.execute(f"UPDATE penis SET count=count+1 WHERE user={message.from_user.id}") + con.commit() + + logging.info("Penis detected!") + + +async def main() -> None: + cur.execute("CREATE TABLE IF NOT EXISTS penis(user TEXT, count INT)") + con.commit() + + bot = Bot(token=TOKEN, default=DefaultBotProperties(parse_mode=ParseMode.HTML)) + + await dp.start_polling(bot) + + + +if __name__ == "__main__": + logging.basicConfig(level=logging.INFO, stream=sys.stdout) + asyncio.run(main()) \ No newline at end of file