def finish(update: Update , context : CallbackContext) -> int : update.message.reply_text(finishText) #getting info about user contact = update.effective_message.contact phone = contact['phone_number'] contact = update.effective_message.contact info = update.message.from_user name = info.first_name userId = info.id userInfo = DataBase.getLastActionByUser(userId) reserveTime = userInfo['reserveTime'] guests = userInfo['guests'] longTime = userInfo["longTime"] #send message in admin chat context.bot.send_message( chat_id = adminChannel, text= f'*Новая запись* \nИмя: {name} \nХочет придти в {reserveTime} \nКоличество гостей : {guests} \nПросидят {longTime} \nНомер телефона: {phone}', parse_mode = telegram.ParseMode.MARKDOWN_V2 ) dbInfo = { "name" : name, "phone" : phone } #записываем в базу инфу о пользователе, если он в первый раз DataBase.createUser(dbInfo, userId = userId) return ConversationHandler.END
def start(update: Update , context : CallbackContext) -> int : reply_keyboard = first_button info = update.message.from_user name = info.first_name userId= info.id update.message.reply_text( f"Привет, {name}! Ты хочешь посетить нашу уютную кальянную?", reply_markup=ReplyKeyboardMarkup(reply_keyboard, one_time_keyboard=True), ) DataBase.createAction(userId, name = name) return NAME
def getHoldTime(update: Update , context : CallbackContext) -> int : reply_keyboard = hold update.message.reply_text( getHolTimeText, reply_markup=ReplyKeyboardMarkup(reply_keyboard, one_time_keyboard=True), ) info = update.message.from_user userId= info.id funcName = "getHoldTime" guestsCount = update.message.text DataBase.updateAction(guestsCount, funcName=funcName , userId= userId) return TIMETOHOLD
def getGuests(update: Update , context : CallbackContext) -> int : reply_keyboard = guests update.message.reply_text( getGuestsText, reply_markup=ReplyKeyboardMarkup(reply_keyboard, one_time_keyboard=True), ) info = update.message.from_user userId= info.id funcName = "getGuests" reserveTime = update.message.text DataBase.updateAction(reserveTime, funcName=funcName , userId= userId) return GUESTS
def getPhone(update: Update , context : CallbackContext) -> int : reply_markups = telegram.ReplyKeyboardMarkup([[telegram.KeyboardButton(phone_button, request_contact=True)]]) update.message.reply_text( getPhoneText, reply_markup= reply_markups, ) info = update.message.from_user userId= info.id funcName = "getPhone" longTime = update.message.text DataBase.updateAction(longTime, funcName=funcName , userId= userId) return PHONE
def getSocLinks(self): cities = self.getAllCities() for city in cities: htmlCode = requests.get(city, headers=parseHeaders) soup = BeautifulSoup(htmlCode.text, 'lxml') elements = soup.find_all('div', class_='logo') count = 0 for div in elements: a = div.find('a', href=True) if a['href'][0] != '/': continue else: link = parseMainUrl + a['href'] pageInfo = self.getInfoByPage(link) print(pageInfo) DataBase.updatePlace(pageInfo) count += 1
def mailing(update: Update , context : CallbackContext) : info = update.message.from_user userId = info.id if str(userId) in admins : message = update.message.text users = DataBase.getUsersList(message) for user in users : context.bot.send_message(chat_id=user, text=message) else : pass
import os.path as pt import json from datetime import datetime, timedelta from db.configuredb import DataBase userId = '331392389' userInfo = DataBase.getLastActionByUser(userId)