This commit is contained in:
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.gitignore
|
||||||
|
LICENSE
|
||||||
|
penis.db
|
||||||
24
.github/workflows/deploy.yml
vendored
Normal file
24
.github/workflows/deploy.yml
vendored
Normal file
@ -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
|
||||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.env
|
||||||
|
penis.db
|
||||||
9
Dockerfile
Normal file
9
Dockerfile
Normal file
@ -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" ]
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -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.
|
||||||
3
requirements.txt
Normal file
3
requirements.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
aiogram
|
||||||
|
sqlite3
|
||||||
|
asyncio
|
||||||
63
src/main.py
Normal file
63
src/main.py
Normal file
@ -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())
|
||||||
Reference in New Issue
Block a user