2024-07-29 07:08:11 +03:00
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
|
2024-07-29 04:39:44 +03:00
|
|
|
|
from aiogram import Bot, types
|
|
|
|
|
from aiogram.dispatcher import Dispatcher
|
|
|
|
|
from aiogram.utils import executor
|
|
|
|
|
|
|
|
|
|
from config import TOKEN
|
|
|
|
|
|
2024-07-29 07:08:11 +03:00
|
|
|
|
import os
|
|
|
|
|
import re
|
|
|
|
|
import random
|
|
|
|
|
import time
|
2024-07-29 04:39:44 +03:00
|
|
|
|
|
2024-07-29 07:08:11 +03:00
|
|
|
|
#import pymysql
|
|
|
|
|
#import pymysql.cursors
|
|
|
|
|
|
|
|
|
|
import sqlite3
|
|
|
|
|
|
|
|
|
|
print('Bot started')
|
2024-07-29 04:39:44 +03:00
|
|
|
|
|
2024-07-29 07:08:11 +03:00
|
|
|
|
con = sqlite3.connect("db4tg.sqlite")
|
|
|
|
|
cur = con.cursor()
|
|
|
|
|
|
|
|
|
|
cur.execute('''CREATE TABLE IF NOT EXISTS users (
|
2024-07-29 07:51:17 +03:00
|
|
|
|
user_id INTEGER NOT NULL DEFAULT 0 UNIQUE,
|
|
|
|
|
f_name VARCHAR NOT NULL DEFAULT 'хз',
|
|
|
|
|
reg_int INTEGER NOT NULL DEFAULT 0,
|
2024-07-29 09:08:44 +03:00
|
|
|
|
lng_code VARCHAR NOT NULL DEFAULT 0
|
2024-07-29 07:51:17 +03:00
|
|
|
|
)''');
|
2024-07-29 07:08:11 +03:00
|
|
|
|
|
|
|
|
|
async def reg_user(message: types.Message):
|
|
|
|
|
print(message)
|
|
|
|
|
msg = "🖖"
|
2024-07-29 09:08:44 +03:00
|
|
|
|
user_id = int(message["from"]["id"])
|
|
|
|
|
user_fn = 'хз'
|
|
|
|
|
lngcode = 'хз'
|
|
|
|
|
if message["from"]["first_name"]:
|
|
|
|
|
user_fn = message["from"]["first_name"]
|
|
|
|
|
if message["from"]["language_code"]:
|
|
|
|
|
lngcode = message["from"]["language_code"]
|
2024-07-29 07:08:11 +03:00
|
|
|
|
whenint = int(datetime.timestamp(message.date))
|
|
|
|
|
try:
|
2024-07-29 09:08:44 +03:00
|
|
|
|
cur.execute("INSERT INTO users(user_id,reg_int,f_name,lng_code) VALUES (?,?,?,?)", (int(user_id),int(whenint),user_fn,lngcode)); con.commit()
|
2024-07-29 07:08:11 +03:00
|
|
|
|
msg="✅ ok"
|
|
|
|
|
if lngcode=='uk':
|
|
|
|
|
msg = f"✅ {user_fn} успішно зареєструвавсь(лась)"
|
|
|
|
|
if lngcode=='ru':
|
|
|
|
|
msg = f"✅ {user_fn} успешно зарегистрировался(лась)"
|
|
|
|
|
if lngcode=='be':
|
|
|
|
|
msg = f"✅ паспяхова зарэгістраваны"
|
|
|
|
|
if lngcode=='en':
|
|
|
|
|
msg = f"✅ successfully registered"
|
|
|
|
|
print (msg)
|
2024-07-29 09:08:44 +03:00
|
|
|
|
except:
|
|
|
|
|
pass
|
2024-07-29 07:08:11 +03:00
|
|
|
|
return msg
|
|
|
|
|
|
|
|
|
|
bot = Bot(token=TOKEN)
|
|
|
|
|
dp = Dispatcher(bot)
|
2024-07-29 04:39:44 +03:00
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=['start'])
|
|
|
|
|
async def process_start_command(message: types.Message):
|
|
|
|
|
#print(message)
|
2024-07-29 07:08:11 +03:00
|
|
|
|
await message.answer(await reg_user(message))
|
2024-07-29 04:39:44 +03:00
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=['help'])
|
|
|
|
|
async def process_help_command(message: types.Message):
|
|
|
|
|
#print(message)
|
|
|
|
|
await message.answer(emoji="🤷")
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=['ping'])
|
|
|
|
|
async def process_ping_command(message: types.Message):
|
|
|
|
|
#print(message)
|
|
|
|
|
await message.reply("PONG!")
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=['code'])
|
|
|
|
|
async def cmd_code(message: types.Message):
|
|
|
|
|
#print(message)
|
|
|
|
|
await message.reply("https://github.com/S1S13AF7/misc_beta_bot")
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=['кубик'])
|
|
|
|
|
async def cmd_dice(message: types.Message):
|
|
|
|
|
#print(message)
|
|
|
|
|
await message.answer_dice(emoji="🎲")
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=['coffee','кава','кофе','кофи','кофі'])
|
|
|
|
|
async def cmd_coffee(message: types.Message):
|
|
|
|
|
#print(message)
|
|
|
|
|
await message.answer("☕️")
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=['tea','чай','чяй'])
|
|
|
|
|
async def cmd_tea(message: types.Message):
|
|
|
|
|
#print(message)
|
|
|
|
|
await message.answer("🍵")
|
|
|
|
|
|
|
|
|
|
@dp.message_handler(commands=['chats','чати','чаты','чаті'])
|
|
|
|
|
async def cmd_chats(message: types.Message):
|
|
|
|
|
#print(message)
|
|
|
|
|
await message.answer('''
|
|
|
|
|
• ☕️ @misc_chat
|
|
|
|
|
• 🦠 @misc_games
|
|
|
|
|
• 🗃 @misc_files_v2
|
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
executor.start_polling(dp)
|