예제 #1
0
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
예제 #2
0
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
예제 #3
0
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
예제 #4
0
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
예제 #5
0
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
예제 #6
0
    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
예제 #7
0
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
예제 #8
0
import os.path as pt
import json
from datetime import datetime, timedelta
from db.configuredb import DataBase

userId = '331392389'
userInfo = DataBase.getLastActionByUser(userId)