Compare commits

...

112 Commits

Author SHA1 Message Date
Pavel_Durov
9f95d004c1 Merge branch '0.1.0-dev' of https://git.vdk2ch.ru/Pavel_Durov/python_bot into 0.1.0-dev
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-22 18:56:58 +03:00
Pavel_Durov
cfab19f4d4 cahnge data new year 2024 2023-06-22 18:55:27 +03:00
4229624763 Мелкофиксы для подключения БД
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-22 17:37:57 +10:00
3767417e23 Merge branch '0.1.0-dev' of https://git.vdk2ch.ru/Pavel_Durov/python_bot into 0.1.0-dev
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-22 15:27:41 +10:00
07db185d8f Закончена подготовка таблиц и миграций для ведения статы, новую версию можно считать готовой, requesting codereview перед мёрджем с мейном. 2023-06-22 15:26:49 +10:00
Pavel_Durov
63dabb0db5 edits in the text /dick
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-21 17:16:09 +03:00
420a945ea7 DICKBOT-6 fix
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-21 11:53:50 +10:00
d2e95a42c9 Merge branch '0.1.0-dev' of https://git.vdk2ch.ru/Pavel_Durov/python_bot into 0.1.0-dev
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-20 16:39:55 +10:00
33418e0c8b отпилен хуй от пользователей, вынесен в автономию 2023-06-20 13:21:28 +10:00
3a28cbb080 Update '.drone.yml'
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-19 08:57:59 -04:00
da06b5ad23 minor fixes and PEP8'ification
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-19 19:24:40 +10:00
6169e6e32a minor fixes and PEP8'ification
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-19 17:33:06 +10:00
61075491ec added statistics
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-19 17:09:04 +10:00
Pavel_Durov
2357ebe6bd add env to gitignore
All checks were successful
continuous-integration/drone/push Build is passing
2023-04-08 19:13:28 +03:00
Pavel_Durov
82652e1b82 hello 2023-04-08 18:54:22 +03:00
Pavel_Duron
67145b9657 change davinci position on handlers time is not working
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-06 23:10:13 +10:00
Pavel_Duron
8d2ebff6f3 change davinci position on handlers
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-06 22:45:18 +10:00
Pavel_Duron
fb54c27514 change davinci position on handlers
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-06 22:19:54 +10:00
Pavel_Duron
688c61642b add graylog back
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-06 22:02:53 +10:00
Pavel_Duron
b2d58f4320 add davinci003
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-06 21:54:41 +10:00
root
e619022112 pogromirovai davai
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-23 01:54:17 -05:00
Pavel_Duron
b849bc26b2 add some dicks
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-16 23:02:32 +10:00
Pavel_Duron
8caf244923 change html tag
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-16 22:46:34 +10:00
Pavel_Duron
9c06b19d12 add 88 word to dickSinonims
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-16 22:38:51 +10:00
Pavel_Duron
23328de316 fix "
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-16 22:20:11 +10:00
Pavel_Duron
9c91fc5420 add sinonims for dickup test done
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-16 22:16:21 +10:00
Pavel_Duron
157833e41a add sinonims for dick and def random word from dict
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-16 19:19:23 +10:00
Pavel_Duron
adcf425183 add tests in gitignore
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-16 18:26:45 +10:00
Pavel_Duron
fdd802a3c1 add tests in gitignore
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-16 18:26:13 +10:00
Pavel_Duron
226a6effd0 add tests in gitignore 2022-12-16 18:15:17 +10:00
Pavel_Duron
cbc8ba4710 add tests in gitignore 2022-12-16 18:11:46 +10:00
Pavel_Duron
d0e1d92d26 add tests in gitignore 2022-12-16 18:07:55 +10:00
Pavel_Duron
f277613a9c some fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-15 22:51:18 +10:00
Pavel_Duron
bb6e5c5a9b add random choise in dick change random words
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-15 22:37:12 +10:00
Pavel_Duron
bcc5f68151 add random choise in dick change random words
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-15 22:30:53 +10:00
1b868e430b добавил новую функию рассылки для админа/изменил регистрацию хендлеров
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-13 17:51:47 +10:00
41c4b7c1c4 откатываем изменения
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-13 16:42:19 +10:00
e954ffcef5 Revert "Изменил(а) на 'bot.py'"
All checks were successful
continuous-integration/drone/push Build is passing
This reverts commit 92db050945.
2022-12-13 16:34:55 +10:00
751bda0681 fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-11 20:48:14 +10:00
9b64b498ec revert 92db050945
All checks were successful
continuous-integration/drone/push Build is passing
revert Изменил(а) на 'bot.py'
2022-12-11 05:46:01 -05:00
771aaceaf3 Merge branch 'main' of http://git.vdk2ch.ru:3000/Pavel_Durov/python_bot
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-11 20:35:09 +10:00
21c41aebaa ыы бля
All checks were successful
continuous-integration/drone/push Build is passing
revert Изменил(а) на 'bot.py'
2022-12-11 05:34:55 -05:00
a26e02f9c9 Merge branch 'main' of http://git.vdk2ch.ru:3000/Pavel_Durov/python_bot 2022-12-11 20:26:39 +10:00
bd3ad3b459 revert 92db050945
All checks were successful
continuous-integration/drone/push Build is passing
revert Изменил(а) на 'bot.py'
2022-12-11 05:26:29 -05:00
8a9675cd0d change gitignore 2022-12-11 20:21:52 +10:00
230c03942d revert 92db050945
All checks were successful
continuous-integration/drone/push Build is passing
revert Изменил(а) на 'bot.py'
2022-12-11 05:19:10 -05:00
1215937856 revert 71b87a97ff
All checks were successful
continuous-integration/drone/push Build is passing
revert change imports
2022-12-11 01:21:07 -05:00
71b87a97ff change imports
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-11 16:16:33 +10:00
92db050945 Изменил(а) на 'bot.py'
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-09 11:34:44 -05:00
8864e1ce38 Изменил(а) на 'bot.py'
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-09 11:25:43 -05:00
f3e8454f58 Изменил(а) на 'bot.py'
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-09 11:20:22 -05:00
bc7a2e367d Изменил(а) на 'bot.py'
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-09 11:15:32 -05:00
d351c0eb72 Изменил(а) на 'bot.py'
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-09 11:12:10 -05:00
2b23fa727f Изменил(а) на 'bot.py'
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-09 11:08:11 -05:00
bfe6adea42 test logs
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-09 11:02:59 -05:00
7d28bb1093 Изменил(а) на 'requairements.txt'
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-09 10:59:01 -05:00
aefe9f6a09 add testfucn
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-09 19:20:50 +10:00
17bb367a3a fix tabilation
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-08 21:46:03 +10:00
18b1a1d7f8 rewrite code with try exc finaly
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-07 21:12:21 +10:00
4749ee885d fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-06 22:27:12 +10:00
82d5aa14ee fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-06 22:20:38 +10:00
ae13e5a8ff fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-06 22:19:47 +10:00
46fc25db39 fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-06 22:14:53 +10:00
e02089442f fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-06 22:12:15 +10:00
820e53b678 fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-06 22:11:21 +10:00
0316ef5e05 откатываем
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-06 21:22:05 +10:00
aae4506ffe testx
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-06 20:57:57 +10:00
456e37f07f testx
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-06 20:56:30 +10:00
4dff284b7f testx
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-06 20:55:55 +10:00
4b3c1f6f79 add alarm of job fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-06 20:37:40 +10:00
9cbe80b9ed add alarm of job fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-06 20:31:55 +10:00
78759e9a8a add alarm of job fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-06 20:27:55 +10:00
45d4aa8c9a add alarm of job
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-06 20:25:52 +10:00
502dca273d fix sesions
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-06 17:05:09 +10:00
8682555bcb add close_all_sesions
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-05 19:38:38 +10:00
0391206ee6 add close_all_sesions
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-05 19:25:06 +10:00
31abb3460a add structure to code
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-05 17:22:23 +10:00
c0e0b51dee fix session
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-04 17:12:42 +10:00
e748ee3913 fix session
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-04 17:11:30 +10:00
cc4549d598 fix session
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-04 17:05:35 +10:00
0861e266c7 fix session
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-04 16:56:43 +10:00
5b668f1a6d fix session
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-04 16:23:05 +10:00
89ccbf1810 fix session
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-04 16:21:45 +10:00
ec8c67a23b fix engine dispose
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-04 15:45:15 +10:00
5c7935e430 fix session
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-03 17:22:43 +10:00
3dd2b32086 fix session
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-03 16:45:15 +10:00
103f6222fa change chatid in any chats
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-02 23:13:45 +10:00
25760e4c60 change chatid in any chats
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-02 23:10:57 +10:00
2234545bda fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-02 23:03:02 +10:00
2abd634c4d fix
Some checks failed
continuous-integration/drone/push Build is failing
2022-12-02 22:59:11 +10:00
1a5cad9c0d fix localtop when users < 10
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-02 22:53:07 +10:00
3ac8fe1cb5 change icon in world top
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-02 18:45:24 +10:00
f1a147ead3 fix local top
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-02 18:37:45 +10:00
cc6627f664 impot sqdb succses
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-02 18:34:04 +10:00
73bf3af7a4 test impot sqdb
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-02 18:31:37 +10:00
50b7131b51 fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-01 19:51:59 +10:00
cdc65332a7 fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-01 19:50:55 +10:00
550406f699 fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-01 19:48:51 +10:00
ff50eed8e7 fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-01 19:46:34 +10:00
6f7989a5d6 fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-01 19:43:36 +10:00
0d945cfb36 chang bigint add global and loacl top
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-01 19:26:11 +10:00
aed4df32f9 add new column chat id
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-01 19:12:16 +10:00
445d624732 replace emoj in dik minus
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-01 17:17:32 +10:00
82c27c90a1 replace emoj in dik minus
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-01 17:16:02 +10:00
d7813e2b42 fix time null day
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-01 17:13:01 +10:00
e6d7d5f53f add emoj in top10 and replace emoj in dick minus(some fix)
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-26 00:34:48 +10:00
3662e02958 add emoj in top10 and replace emoj in dick minus
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-26 00:32:24 +10:00
7a02dad330 fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-24 18:40:25 +10:00
37a203a055 fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-24 18:38:48 +10:00
8b24b3e34f fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-24 18:36:17 +10:00
8b122a53d6 fix
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-24 18:33:38 +10:00
8bce6dc065 test topdic2k
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-24 18:33:05 +10:00
20 changed files with 755 additions and 155 deletions

View File

@@ -20,6 +20,12 @@ steps:
- cd /usr/share/$DRONE_REPO_NAME
- git pull
- chown -R jack:jack .
when:
branch:
- main
- name: restart systemd unit
commands:
- systemctl restart jack_bot
when:
branch:
- main

3
.gitignore vendored
View File

@@ -2,3 +2,6 @@ __pycache__
testDB.py
TIME.py
.vscode
tests
qeqeqe
env

110
alembic.ini Normal file
View File

@@ -0,0 +1,110 @@
# A generic, single database configuration.
[alembic]
# path to migration scripts
script_location = alembic
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
# Uncomment the line below if you want the files to be prepended with date and time
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
# for all available tokens
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
# sys.path path, will be prepended to sys.path if present.
# defaults to the current working directory.
prepend_sys_path = .
# timezone to use when rendering the date within the migration file
# as well as the filename.
# If specified, requires the python-dateutil library that can be
# installed by adding `alembic[tz]` to the pip requirements
# string value is passed to dateutil.tz.gettz()
# leave blank for localtime
# timezone =
# max length of characters to apply to the
# "slug" field
# truncate_slug_length = 40
# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false
# set to 'true' to allow .pyc and .pyo files without
# a source .py file to be detected as revisions in the
# versions/ directory
# sourceless = false
# version location specification; This defaults
# to alembic/versions. When using multiple version
# directories, initial revisions must be specified with --version-path.
# The path separator used here should be the separator specified by "version_path_separator" below.
# version_locations = %(here)s/bar:%(here)s/bat:alembic/versions
# version path separator; As mentioned above, this is the character used to split
# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep.
# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas.
# Valid values for version_path_separator are:
#
# version_path_separator = :
# version_path_separator = ;
# version_path_separator = space
version_path_separator = os # Use os.pathsep. Default configuration used for new projects.
# set to 'true' to search source files recursively
# in each "version_locations" directory
# new in Alembic version 1.10
# recursive_version_locations = false
# the output encoding used when revision files
# are written from script.py.mako
# output_encoding = utf-8
sqlalchemy.url = postgresql+psycopg2://postgres:postgres@postgres.vdk2ch.ru:5432/jack_bot
[post_write_hooks]
# post_write_hooks defines scripts or Python functions that are run
# on newly generated revision scripts. See the documentation for further
# detail and examples
# format using "black" - use the console_scripts runner, against the "black" entrypoint
# hooks = black
# black.type = console_scripts
# black.entrypoint = black
# black.options = -l 79 REVISION_SCRIPT_FILENAME
# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
qualname =
[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
[logger_alembic]
level = INFO
handlers =
qualname = alembic
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S

1
alembic/README Normal file
View File

@@ -0,0 +1 @@
Generic single-database configuration.

78
alembic/env.py Normal file
View File

@@ -0,0 +1,78 @@
from logging.config import fileConfig
from sqlalchemy import engine_from_config
from sqlalchemy import pool
from sqdb import Base
from alembic import context
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
if config.config_file_name is not None:
fileConfig(config.config_file_name)
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = Base.metadata
# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
def run_migrations_offline() -> None:
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url,
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online() -> None:
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
connectable = engine_from_config(
config.get_section(config.config_ini_section, {}),
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(
connection=connection, target_metadata=target_metadata
)
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()

24
alembic/script.py.mako Normal file
View File

@@ -0,0 +1,24 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
branch_labels = ${repr(branch_labels)}
depends_on = ${repr(depends_on)}
def upgrade() -> None:
${upgrades if upgrades else "pass"}
def downgrade() -> None:
${downgrades if downgrades else "pass"}

View File

@@ -0,0 +1,47 @@
"""empty message
Revision ID: 7521d874503f
Revises:
Create Date: 2023-06-22 15:21:26.835612
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '7521d874503f'
down_revision = None
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('dick_requests',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('size_change', sa.Integer(), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('date_changed', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['users.user_id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_foreign_key(None, 'user_dicks', 'users', ['user_id'], ['user_id'])
op.add_column('users', sa.Column('date_created', sa.DateTime(), nullable=True))
op.add_column('users', sa.Column('date_updated', sa.DateTime(), nullable=True))
op.drop_column('users', 'chat_id')
op.drop_column('users', 'datetimes')
op.drop_column('users', 'dick_size')
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('users', sa.Column('dick_size', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('users', sa.Column('datetimes', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
op.add_column('users', sa.Column('chat_id', sa.BIGINT(), autoincrement=False, nullable=True))
op.drop_column('users', 'date_updated')
op.drop_column('users', 'date_created')
op.drop_constraint(None, 'user_dicks', type_='foreignkey')
op.drop_table('dick_requests')
# ### end Alembic commands ###

157
bot.py
View File

@@ -1,160 +1,27 @@
from cgitb import text
import datetime
import logging
from random import randint
from sqlalchemy import create_engine, MetaData, Table, Integer, String, \
Column, DateTime, ForeignKey, Numeric
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from aiogram import Bot, Dispatcher, executor, types
from aiogram.types import ReplyKeyboardRemove, ReplyKeyboardMarkup, KeyboardButton
from sqdb import user
import graypy
from aiogram import executor
from create_bot import dp
import handlers
API_TOKEN = '5724991559:AAEuLvpLsgP6LHRGMSyFtQLlR5qPQUO4b_w'
logging.basicConfig(level=logging.DEBUG)
bot = Bot(token=API_TOKEN, parse_mode="HTML")
dp = Dispatcher(bot)
logging.basicConfig(
level=logging.DEBUG,
handlers=[graypy.GELFUDPHandler('localhost', 12201)]
)
# pipisa.register_handlers_pipisa(dp)
# time_new_year.register_handlers_time(dp)
# sendalarm.register_handlers_test(dp)
# start_help.register_handlers_StartHelp(dp)
@dp.message_handler(commands=["time"])
async def send_time(message: types.Message):
new_year = datetime.datetime(2022, 12, 31) #дата нового года
ct = datetime.datetime.now() #датавремя
cd = datetime.datetime.now().strftime("%d/%m/%Y") #дата (д,м,г)
ct1 = ct+datetime.timedelta(hours=15) # +14 часов от сервера
ct2 = ct1.strftime('%H:%M') # форматирует датувремя просто во время(ч,м)
raznitsa = (new_year - ct).days #отнимает от нг текущее время и получаем разницу в днях
days = ['день', 'дня', 'дней']
if raznitsa % 10 == 1 and raznitsa % 100 != 11:
p = 0
elif 2 <= raznitsa % 10 <= 4 and (raznitsa % 100 < 10 or raznitsa % 100 >= 20):
p = 1
else:
p = 2
num=(str(raznitsa) + ' ' + days[p])
await message.reply(f'Сегодня {cd} \nВремя: {ct2} \nДо Нового Года осталось {num}')
#####______________________ПИПИСА БОТ БУДЕТ ЗДЕСЬ__________________________________
@dp.message_handler(commands=["dick"])
async def ident(message: types.Message):
# рандомайзер
numb = randint(-7,10)
global size_change, dick_plus, dick_minus
dick_plus = f'<b>вырос</b> 🚀 на <b>{numb}</b> см!'
dick_minus = f'<b>уменьшился</b> на <b>{abs(numb)}</b> см!😔'
if numb > 0:
size_change = dick_plus
else: size_change = dick_minus
####
# работа с таблицей
engine = create_engine('postgresql+psycopg2://postgres:postgres@postgres.vdk2ch.ru:5432/jack_bot', echo=True)
Session = sessionmaker(bind=engine)
session = Session()
Base = declarative_base()
if session.query(user).filter(user.user_id == message.from_user.id).first():
b = session.query(user).filter(user.user_id == message.from_user.id).first()
now_time = datetime.datetime.now()
last_time = b.datetimes
diff = now_time.day - last_time.day
if diff <= 0:
await bot.send_message(message.chat.id, f'@{message.from_user.username},🚫 вы уже крутили пипису, ее размер <b>{b.dick_size}</b> см! ')
session.close_all()
print(diff)
print(type(diff))
else:
a = session.query(user).filter(user.user_id == message.from_user.id).first() # запрос на поиск в таблице
a.dick_size = (a.dick_size + numb)
a.datetimes = datetime.datetime.now()
session.commit() #обновляет запись
await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш писюн {size_change}\n\
Теперь он равен <b>{a.dick_size}</b> см! ')
session.close_all()
else:
int_table = user(user_id = message.from_user.id, user_fullname = message.from_user.full_name, dick_size = numb, datetimes = datetime.datetime.now())
session.add(int_table)
session.commit()
await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш писюн {size_change}\n\
Теперь он равен <b>{int_table.dick_size}</b> см!')
session.close_all()
# int_table = user(user_id = message.from_user.id, user_fullname = message.from_user.full_name, dick_size = numb) #импортирую юзер из sqdb
# session.add(int_table)
# session.commit()
#обновление
# dick_update = session.query(user).filter_by(user.user_id = message.from_user.id).update({'dick_size': user.dick_size + numb})
# session.add(dick_update)
# session.commit()
#last_size = session.query(user).filter_by(user_id = message.from_user.id).select_from(dick_size = 'dick_size: ').one()
#####______________________ПИПИСА БОТ БУДЕТ ЗДЕСЬ__________________________________
@dp.message_handler(commands=["topdick"])
async def send_time(message: types.Message):
engine = create_engine('postgresql+psycopg2://postgres:postgres@postgres.vdk2ch.ru:5432/jack_bot', echo=True)
Session = sessionmaker(bind=engine)
session = Session()
Base = declarative_base()
top = session.query(user.user_fullname, user.dick_size).order_by(user.dick_size.desc()).limit(10).all()
delimiter = ': '
await bot.send_message(message.chat.id, f'{red}')
# {top[0]}\n\сууука
# {top[1]}\n\
# {top[2]}\n\
# {top[3]}\n\
# {top[4]}\n\
# {top[5]}\n\
# {top[6]}\n\
# {top[7]}\n\
# {top[8]}\n\
# {top[9]}ff')
session.close_all()
@dp.message_handler(commands=['start'])
async def start_func(message: types.Message):
# user_id = message.from_user.id
# user_full_name = message.from_user.full_name
# logging.INFO(f'{user_id=} {user_full_name=}', {time.asctime()})
await message.reply('похуй')
@dp.message_handler(commands=['photo'])
async def send_image(message: types.Message):
await bot.send_photo(message.chat.id, photo='https://memepedia.ru/wp-content/uploads/2018/08/ya-pidoras.jpg', reply_to_message_id=message.message_id)
@dp.message_handler(content_types=types.ContentTypes.TEXT)
async def send_faggot(message: types.Message):
print(message.text)
if message.text == 'хто я':
await bot.send_photo(message.chat.id, photo='https://www.meme-arsenal.com/memes/ecebd2339c7eab40e09874bd86a38a09.jpg')
#хуй
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True)

4
create_bot.py Normal file
View File

@@ -0,0 +1,4 @@
from aiogram import Bot, Dispatcher
API_TOKEN = '5724991559:AAEuLvpLsgP6LHRGMSyFtQLlR5qPQUO4b_w'
bot = Bot(token=API_TOKEN, parse_mode="HTML")
dp = Dispatcher(bot)

16
dicktxt/ForReadDict.py Normal file
View File

@@ -0,0 +1,16 @@
import random
def RandomDick():
# Забирает рандомный синоним к слову хуй из dick_sinonims.txt
# у линуха и винды не забывай про разные \/
# когда указываешь путь
with open('dicktxt/dick_sinonims.txt', 'r', encoding='utf-8') as file:
words = file.readlines()
random_line = random.choice(words).strip()
return random_line

1
dicktxt/__init__.py Normal file
View File

@@ -0,0 +1 @@
from . import ForReadDict

95
dicktxt/dick_sinonims.txt Normal file
View File

@@ -0,0 +1,95 @@
Кожаный бабах
пистон
дуршлаг
елдак
шлямбур
шмайсер
хохотунчик
головастик
пистон
мундштук
мухомор
головач
красненький
чупа-чупс
щекотунчик
питательный
тюбик
джойстик
хоббит
крючок
ласкун
красавец
хозяин
хрящ
чудильник
царь пижамы
целколом
щуп
эклер
долбильник
народник
духопер
ежик малиновый
жрец любви
жизненный конус
злой одноглазый пиратик
главтрах
веселый парнишка
вставень висюлек
волосатый чикатило
агрессор
анакондаз
антихрист
Анютин глазок
бензонасос
блудень
бог плодородия
божий леденец
волосатый змiй
витамин "Х"
вспотевший объектив
гендерный габитус
двадцать первый палец
калдыбобер
боброчес
кукурузик
красноголовый воин
красный богатырь
любовный мускул
леденец
обелиск
окурок
органайзер
отбойный
молоток
посох королей
пламенный алмаз мудрости
монофалический потенциометр
розовый кадилак
сексофон
трахальник
торчильник
факало
кочанчик
писюн
губашлеп
потенциальный кредитор
кок
чилим
пажилой кабан
малой
начальник унитаза
бесперебойник
корнишон
банановый смузи
кизляк
проныра
пенис детров
бенис
кокошник
членикс
маленький жиголо
венерический суккуб
боец невидимого фронта
сморчок

7
handlers/__init__.py Normal file
View File

@@ -0,0 +1,7 @@
from handlers import pipisa
from handlers import davinci
from handlers import time_new_year
from handlers import sendalarm
from handlers import start_help

26
handlers/davinci.py Normal file
View File

@@ -0,0 +1,26 @@
import openai
from aiogram import types
from create_bot import dp
token = '5947963644:AAF_GKgMmU5ovqMpc1KXIpcf4aN0JMyKPqc'
openai.api_key = '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'
@dp.message_handler()
async def send(message: types.Message):
if 'тупица' in message.text.lower():
response = openai.Completion.create(
model="text-davinci-003",
prompt=message.text[7:],
temperature=0.7,
max_tokens=1000,
top_p=1.0,
frequency_penalty=0.0,
presence_penalty=0.6,
stop=["сброс"]
)
await message.reply(response['choices'][0]['text'])

201
handlers/pipisa.py Normal file
View File

@@ -0,0 +1,201 @@
from aiogram import types
from sqlalchemy.orm.session import close_all_sessions
from create_bot import bot, dp
from sqdb import User, session, DickRequest, UserDick
import random
import traceback
from random import randint
import datetime
from dicktxt import ForReadDict
size_change = None
dick_plus = None
dick_minus = None
def get_dick(user_id, chat_id):
dick = session.query(UserDick).filter(UserDick.user_id == user_id, UserDick.chat_id == chat_id).first()
return dick
def top_dick_message(delimiter, top_list):
message = f'🏆Топ 10 бубылд чата🏆\n\n'
f'🚀 {delimiter.join(map(str, top_list[0]))}\n'
f'💫 {delimiter.join(map(str, top_list[1]))}\n'
f'🍆 {delimiter.join(map(str, top_list[2]))}\n'
f'🍌 {delimiter.join(map(str, top_list[3]))}\n'
f'🐍 {delimiter.join(map(str, top_list[4]))}\n'
f'🐎 {delimiter.join(map(str, top_list[5]))}\n'
f'🌭 {delimiter.join(map(str, top_list[6]))}\n'
f'🌶 {delimiter.join(map(str, top_list[7]))}\n'
f'👌 {delimiter.join(map(str, top_list[8]))}\n'
f'💩 {delimiter.join(map(str, top_list[9]))}\n'
return message
@dp.message_handler(commands=["maintenance"])
async def stop_for_maintenance(message: types.Message): # остановить бота
if message.from_user.id == 226765676:
bot.send_message(message.from_user.id, "Блять. Как же больно. Мне холодно. Наверное это конец...")
close_all_sessions()
dp.stop_polling()
@dp.message_handler(commands=["dick"])
async def up_dick(message: types.Message): # рандомайзер
numb = randint(-6, 10)
global size_change, dick_plus, dick_minus
dick_plus = ('<b>вырос</b>', '<b>подрос</b>', '<b>привстал</b>')
dick_minus = ('<b>уменьшился</b>', '<b>откусила злая гадюка</b>', '<b>продали евреи, он стал дешевле</b>')
if numb > 0:
size_change = random.choice(dick_plus) + '🚀'
# if numb = 0 size_change = random.choice(const) TODO
else:
size_change = random.choice(dick_minus) + ''
# работа с таблицей
try:
dick_request = DickRequest(size_change=numb, date_changed=datetime.datetime.now())
b = session.query(User).filter(User.user_id == message.from_user.id).first()
if b:
last_time = b.date_updated
now_time = datetime.datetime.now()
diff = now_time.day - last_time.day
if abs(diff) <= 0:
try:
current_dick = b.dick_size
await bot.send_message(message.chat.id, f'@{message.from_user.username},'
f'🚫 вы уже крутили пипису, '
f'ее размер <b>{current_dick}</b> см! ')
except Exception as e:
print('ошибка в if diff <=0 ' + "\n".join(traceback.format_tb(e.__traceback__)))
session.rollback()
finally:
session.close_all()
print('пользователь уже крутил')
else:
try:
usr = session.query(User)
a = usr.filter(User.user_id == message.from_user.id).first() # запрос на поиск в таблице
dick = get_dick(User.user_id, message.chat.id)
updated_dick = dick.dick_size = (dick.dick_size + numb)
dick_request.user = a
a.date_updated = datetime.datetime.now()
session.add(dick_request)
session.flush()
session.commit() # обновляет запись
randomword = ForReadDict.RandomDick()
await bot.send_message(message.chat.id, f'@{message.from_user.username}, '
f'ваш <em>{randomword}</em> {size_change}'
f'на <b>{abs(numb)}</b> см!\n'
f'Теперь он равен <b>{updated_dick}</b> см! ')
except Exception as e:
session.rollback()
print('ошибка в обновлении пиписы, трейсбек-бек-бек: ' +
"\n".join(traceback.format_tb(e.__traceback__)))
finally:
session.close_all()
print('пиписа обновлена')
else:
session.close()
try:
numb = randint(1, 10)
int_table = User(user_id=message.from_user.id,
user_fullname=message.from_user.full_name,
date_updated=datetime.datetime.now(),
date_created=datetime.datetime.now())
new_dick = DickRequest(user_id=message.from_user.id,
chat_id=message.chat.id,
dick_size=numb)
dick_request.user = int_table
session.add(int_table)
session.add(new_dick)
session.add(dick_request)
session.flush()
session.commit()
session.close()
await bot.send_message(message.chat.id, f'@{message.from_user.username}, '
f'ваш писюн показал головку 🚀 \n'
f'на <b>{abs(numb)}</b> см!\n'
f'Теперь он равен <b>{numb}</b> см!')
except Exception as e:
print('ошибка в добавлении нового пользователя, трейсбек: ' +
'\n'.join(traceback.format_tb(e.__traceback__)))
session.rollback()
finally:
session.close_all()
print('Успешно добавлен пользователь')
except Exception as e:
session.rollback()
print('ошибка в основном коде, трейсбек:' + '\n'.join(traceback.format_tb(e.__traceback__)))
finally:
session.close_all()
@dp.message_handler(commands=["topdick"])
async def send_top_chat(message: types.Message):
try:
top = []
chats = message.chat.id
changechat_id = session.query(DickRequest).filter(DickRequest.user_id == message.from_user.id,
DickRequest.chat_id == chats).first()
dicks = session.query(DickRequest)\
.filter(DickRequest.chat_id == chats)\
.limit(10).all()\
.order_by(DickRequest.dick_size.desc())
for dick in dicks:
user = session.query(User.user_fullname).filter(User.user_id == dick.user_id)
top.append([user.full_name, dick.dick_size])
delimiter = ': '
# проверка на длину списка, если меньше limit, то:
size_len = len(top)
if size_len < 10:
len_minus = 10 - size_len
top.extend([('-'*len_minus),""])
await bot.send_message(message.chat.id, top_dick_message(delimiter, top))
session.close()
# если все нормально и участников минимум 10
else:
await bot.send_message(message.chat.id, top_dick_message(delimiter, top))
except Exception as e:
session.rollback()
print('ошибка в /topdick. Трейсбэк:\n' + '\n'.join(traceback.format_tb(e.__traceback__)))
finally:
session.close_all()
@dp.message_handler(commands=["globaldick"])
async def send_global_top(message: types.Message):
try:
top = []
dicks = session.query(DickRequest) \
.limit(10).all() \
.order_by(DickRequest.dick_size.desc())
for dick in dicks:
user = session.query(User.user_fullname).filter(User.user_id == dick.user_id)
top.append([user.full_name, dick.dick_size])
delimiter = ': '
await bot.send_message(message.chat.id, top_dick_message(delimiter, top))
except Exception as e:
session.rollback()
print('ошибка в /globaldick, трейсбэк:\n' + '\n'.join(traceback.format_tb(e.__traceback__)))
finally:
session.close_all()
# def register_handlers_pipisa(dp: Dispatcher):
# dp.register_message_handler(up_dick)
# dp.register_message_handler(send_topchat)
# dp.register_message_handler(send_global_top)

32
handlers/sendalarm.py Normal file
View File

@@ -0,0 +1,32 @@
import traceback
from create_bot import dp, bot
from aiogram import types, Dispatcher
from sqdb import User, session
@dp.message_handler(commands=['sendall'])
async def sendall(message: types.Message):
print('команда прошла')
if message.chat.type == 'private':
if message.from_user.id == 226765676:
text = message.text[9:]
try:
chats_id = session.query(User.chat_id).distinct()
for row in chats_id:
try:
await bot.send_message(row[0], text)
except Exception as e:
print('вероятно бота нет в чате, на всякий случай трейсбек:\n' +
"\n".join(traceback.format_tb(e.__traceback__)))
await bot.send_message(message.from_user.id, 'Сообщение успешно отправлено во все чаты')
except Exception as e:
session.rollback()
print('error sendall, traceback:\n' +
"\n".join(traceback.format_tb(e.__traceback__)))
finally:
session.close_all()
# def register_handlers_test(dp: Dispatcher):
# dp.register_message_handler(send_welcome)

28
handlers/start_help.py Normal file
View File

@@ -0,0 +1,28 @@
from aiogram import types
from create_bot import dp, bot
@dp.message_handler(commands=['start'])
async def start_func(message: types.Message):
await message.reply('похуй')
@dp.message_handler(commands=['photo'])
async def send_image(message: types.Message):
await bot.send_photo(message.chat.id,
photo='https://memepedia.ru/wp-content/uploads/2018/08/ya-pidoras.jpg',
reply_to_message_id=message.message_id)
@dp.message_handler(content_types=types.ContentTypes.TEXT)
async def send_faggot(message: types.Message):
print(message.text)
if message.text == 'хто я':
await bot.send_photo(message.chat.id,
photo='https://www.meme-arsenal.com/memes/ecebd2339c7eab40e09874bd86a38a09.jpg')
# def register_handlers_StartHelp(dp: Dispatcher):
# dp.register_message_handler(start_func)
# dp.register_message_handler(send_faggot)
# dp.register_message_handler(send_image)

28
handlers/time_new_year.py Normal file
View File

@@ -0,0 +1,28 @@
from aiogram import types
from create_bot import dp
import datetime
@dp.message_handler(commands=["time"])
async def send_time(message: types.Message):
new_year = datetime.datetime(2024, 12, 31) # дата нового года
ct = datetime.datetime.now() # дата/время
cd = datetime.datetime.now().strftime("%d/%m/%Y") # дата (д,м,г)
ct1 = ct+datetime.timedelta(hours=15) # +14 часов от сервера
ct2 = ct1.strftime('%H:%M') # форматирует дату/время просто во время(ч, м)
date_difference = (new_year - ct).days # отнимает от нг текущее время и получаем разницу в днях
days = ['день', 'дня', 'дней']
if date_difference % 10 == 1 and date_difference % 100 != 11:
p = 0
elif 2 <= date_difference % 10 <= 4 and (date_difference % 100 < 10 or date_difference % 100 >= 20):
p = 1
else:
p = 2
num = (str(date_difference) + ' ' + days[p])
await message.reply(f'Сегодня {cd} \nВремя: {ct2} \nДо Нового Года осталось {num}')
# def register_handlers_time(dp: Dispatcher):
# dp.register_message_handler(send_time)

View File

@@ -1,3 +1,6 @@
aiogram
sqdb
sqlalchemy
graypy
openai
psycopg2

39
sqdb.py
View File

@@ -1,29 +1,52 @@
from sqlalchemy import create_engine, MetaData, Table, Integer, String, \
from sqlalchemy import create_engine, MetaData, Table, Integer, String, BIGINT, \
Column, DateTime, ForeignKey, Numeric
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import sessionmaker, relationship
from sqlalchemy import select, update
engine = create_engine('postgresql+psycopg2://postgres:postgres@postgres.vdk2ch.ru:5432/jack_bot', echo=True)
Session = sessionmaker(bind=engine)
session = Session()
Base = declarative_base()
class user(Base):
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
user_id = Column(Integer)
date_created = (Column(DateTime))
user_fullname = Column(String)
date_updated = (Column(DateTime))
dick_requests = relationship("DickRequest", back_populates="user")
user_dicks = relationship("UserDick", back_populates="user")
class UserDick(Base):
__tablename__ = 'user_dicks'
id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey("users.user_id"))
dick_size = (Column(Integer))
datetimes = (Column(DateTime))
chat_id = Column(BIGINT)
user = relationship("User", back_populates="user_dicks")
class DickRequest(Base):
__tablename__ = 'dick_requests'
id = Column(Integer, primary_key=True)
size_change = Column(Integer)
user_id = Column(Integer, ForeignKey("users.user_id"))
user = relationship("User", back_populates="dick_requests")
date_changed = (Column(DateTime))
session.close()
engine.dispose()
# top = session.query(user.user_fullname, user.dick_size)
# .order_by(user.dick_size.desc())
# .filter(user.chat_id == user.chat_id).limit(10).all()
# print(top)
#Base.metadata.create_all(engine)