-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.py
89 lines (70 loc) · 3.87 KB
/
functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from aiogram.dispatcher.filters import state
from aiogram.dispatcher import FSMContext
from main import bot, dp
from aiogram import types
from aiogram.types import ParseMode
from language_middleware import i18n
from sql import SQL
from config import DB_NAME
dp.middleware.setup(i18n)
_ = i18n.gettext
database = SQL(f'{DB_NAME}')
def unpack_geo(geopositions: list):
return '\n'.join(geopositions)
async def register(id: int):
await bot.send_message(chat_id=id, text=_("You've already been registered!"))
def throw_buttons():
keyboards = types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
button_location = types.KeyboardButton(_("Here I Am"), request_location=True)
button_victory = types.KeyboardButton("\u270C")
button_snowflake = types.KeyboardButton("\u2744")
button_cold = types.KeyboardButton("\U0001F976")
button_like = types.KeyboardButton("\U0001F44D")
button_fire = types.KeyboardButton("\U0001F525")
button_swear = types.KeyboardButton("\U0001F621")
keyboards.add(button_location, button_victory, button_snowflake, button_cold, button_fire, button_swear, button_like)
return keyboards
async def send_request(ids: int, first_name: str, message_id:int, contact):
await bot.send_message(ids,
text=_("User [{0}](tg://user?id={1}) with number {2} waves {3} to you\.\n*Switch on your location before answer 'Here I Am'*\.").format(first_name, message_id, contact, '\u270B'),
reply_markup=throw_buttons(),
parse_mode=ParseMode.MARKDOWN_V2)
def button_contact():
keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
button = types.KeyboardButton(_("Share a contact"), request_contact=True)
keyboard.add(button)
return keyboard
async def aware_of_contact(id: int):
await bot.send_message(chat_id=id, text=_('In order to use a bot please share your contact!')
, reply_markup=button_contact())
async def thank(id: int):
await bot.send_message(chat_id=id,
text=_("Thank you for the registration!"))
async def action_after_registration(id: int, first_name: str):
await bot.send_message(id,
text=_("Welcome, {0}!\nYou can find instruction in menu!\nPlease, choose your further action from menu!").format(
first_name),
)
async def cancel(id: int):
await bot.send_message(id, text=_("Your action has been cancelled"))
async def share_a_contact(id: int):
await bot.send_message(id,
text=_("Please share a contact of a person (choose from your contacts)!"))
async def request_acceptance(id: int):
await bot.send_message(id,
text=_(
"Your request has been accepted!\nA person will share his location or state soon, meanwhile you can continue using a bot!"))
async def forwarding(id: int):
await bot.send_message(id,
text=_("Unfortunately, this user has not been registered yet, tell him/her about this bot by forwarding the following message:"))
async def send_request_live(ids: int, first_name: str, message_id:int, contact):
await bot.send_message(ids,
text=_("User [{0}](tg://user?id={1}) with number {2} wants to track your *live* location\.\n*Switch on your location before answer 'Location'*\.").format(first_name, message_id, contact),
reply_markup=throw_buttons(),
parse_mode=ParseMode.MARKDOWN_V2)
async def check_queries(query: list, id: int):
if len(query[id]) != 0:
await send_request(id,
database.get_name(query[id][-1])[0][0],
query[id][-1],
database.get_contact(query[id][-1])[0][0])