Пример #1
0
def card_order(chat_id, update_id):
    sender = {'sender_id': chat_id, 'user_data': {}}
    commands = [
        'sifariş et', 'faizlər və ödəniş', 'harada keçir', 'geriyə qayıt'
    ]
    text = "Xidmətlərdən birini seçin"
    reply_markup = bot.reply_markup_maker(commands)
    bot.send_message(chat_id, text, reply_markup)
    chat_id, text, update_id = bot.get_last_id_text(
        bot.get_updates(update_id + 1))
    bot.insert_sender(sender)
    while text.lower() == 'kart sifarişi':
        chat_id, text, update_id = bot.get_last_id_text(
            bot.get_updates(update_id + 1))
        sleep(0.5)
    if text.lower() == commands[0]:
        credit_calculator.ask_credit_details(chat_id, update_id)
    elif text.lower() == commands[1]:
        rates_and_payments(chat_id, update_id)
    elif text.lower() == commands[2]:
        message = eligibility
        commands = ["partnyor təklifi", "geriyə qayıt"]
        reply_markup = bot.reply_markup_maker(commands)
        bot.send_message(chat_id, message, reply_markup)
        chat_id, text, update_id = bot.get_last_id_text(
            bot.get_updates(update_id + 1))
        if text.lower() == commands[0]:
            message = 'BirKart taksit kartı partnyorları siyahısına yeni partnyorun əlavə olunması ilə bağlı müraciətinizi aşağıdaki linkdən edə bilərsiniz:' + url_partner
            bot.send_message(chat_id, message, reply_markup=None)
            chat_id, text, update_id = bot.get_last_id_text(
                bot.get_updates(update_id + 1))
        elif text.lower() == commands[1]:
            card_order(chat_id, update_id)
    elif text.lower() == commands[3]:
        bot.menu(chat_id, text, update_id)
Пример #2
0
def main():
    on = True
    while on:
        initial_length = len(bot.get_updates()["result"])
        text = to_string(predicted_transformed)
        if len(bot.get_updates()["result"]) > initial_length:
            bot.show_bets(bot.get_updates(), text)
            continue
    """user_ids = get_users(get_updates())
def ask_credit_details(chat_id, update_id):
    """ Ask user's information (user_name, user_surname, user_phone, user_company,
    user_credit_amount, user_reason) so as to confirm borrowing credit
    """
    new_values = {'$set': {}}
    sender = {'sender_id': chat_id, 'user_data': {}}
    bot.insert_sender(sender)
    questions = [
        "Zəhmət olmasa adınızı daxil edin",
        "Zəhmət olmasa soyadınızı daxil edin",
        "Zəhmət olmasa telefon nömrənizi daxil edin",
        "İşlədiyiniz təşkilatin adını daxil edin",
        "Kredit götürmək istədiyiniz məbləği daxil edin",
        "Krediti nə üçün götürmək istəyirsiniz?",
        "Sizin kredit sorğunuz qeydə alındı, təşəkkürlər. Tezliklə sizə cavab veriləcək."
    ]
    columns = [
        "user_name", "user_surname", "user_phone", "user_company",
        "user_credit_amount", "user_reason"
    ]

    for i in range(len(questions)):
        message = questions[i]
        bot.send_message(chat_id, message)
        if i != len(questions) - 1:
            chat_id, text, update_id = bot.get_last_id_text(
                bot.get_updates(update_id + 1))
            while text == questions[i]:
                chat_id, text, update_id = bot.get_last_id_text(
                    bot.get_updates(update_id + 1))
                sleep(0.5)
            if text:
                if columns[i] == "user_phone":
                    while True:
                        try:
                            new_values['$set']['user_data.amount'] = int(text)
                            break
                        except ValueError:
                            message = "Zəhmət olmasa, mobil nömrənizi rəqəmlərlə daxil edin, məsələn: 0705505050"
                            bot.send_message(chat_id, message)
                            message = questions[i]
                            bot.send_message(chat_id, message)
                            chat_id, text, update_id = bot.get_last_id_text(
                                bot.get_updates(update_id + 1))
                else:
                    new_values['$set']['user_data.{}'.format(
                        columns[i])] = text
                    sender = bot.update_sender(sender, new_values)
        else:
            break
Пример #4
0
def cards_info(chat_id, update_id):
    sender = {'sender_id': chat_id,
              'user_data': {}}
    commands = ['birkart taksit', 'birkart cashback', 'birkart miles']
    text = "Xidmətlərdən birini seçin"
    reply_markup = bot.reply_markup_maker(commands)
    bot.send_message(chat_id, text, reply_markup)
    chat_id, text, update_id = bot.get_last_id_text(bot.get_updates(update_id + 1))
    bot.insert_sender(sender)
    while text.lower() == 'kart növləri':
        chat_id, text, update_id = bot.get_last_id_text(bot.get_updates(update_id + 1))
        sleep(0.5)
    if text.lower() == commands[0]:
        message = taksit_info
        commands = ["kart sifarişi", "tariflər və qiymət"]
        reply_markup = bot.reply_markup_maker(commands)
        bot.send_message(chat_id, message, reply_markup)
        chat_id, text, update_id = bot.get_last_id_text(bot.get_updates(update_id + 1))
        if text.lower() == commands[0]:
            credit_calculator.ask_credit_details(chat_id, update_id)
        elif text.lower() == commands[1]:
            message = taksit_tarif
            bot.send_message(chat_id, message, reply_markup=None)
    elif text.lower() == commands[1]:
        message = cashback_info
        commands = ["kart sifarişi", "tariflər və qiymət"]
        reply_markup = bot.reply_markup_maker(commands)
        bot.send_message(chat_id, message, reply_markup)
        chat_id, text, update_id = bot.get_last_id_text(bot.get_updates(update_id + 1))
        if text.lower() == commands[0]:
            credit_calculator.ask_credit_details(chat_id, update_id)
        elif text.lower() == commands[1]:
            message = cashback_tarif
            bot.send_message(chat_id, message, reply_markup=None)
    elif text.lower() == commands[2]:
        message = miles_info
        commands = ["kart sifarişi", "tariflər və qiymət"]
        reply_markup = bot.reply_markup_maker(commands)
        bot.send_message(chat_id, message, reply_markup)
        chat_id, text, update_id = bot.get_last_id_text(bot.get_updates(update_id + 1))
        if text.lower() == commands[0]:
            credit_calculator.ask_credit_details(chat_id, update_id)
        elif text.lower() == commands[1]:
            message = miles_tarif
            bot.send_message(chat_id, message, reply_markup=None)
Пример #5
0
def requirements_menu(chat_id, update_id):
    sender = {'sender_id': chat_id, 'user_data': {}}
    commands = ['kimlər ala bilər', 'hansı sənədlər ', 'birkart ala bilərəm']
    text = "Xidmətlərdən birini seçin"
    reply_markup = bot.reply_markup_maker(commands)
    bot.send_message(chat_id, text, reply_markup)
    chat_id, text, update_id = bot.get_last_id_text(
        bot.get_updates(update_id + 1))
    bot.insert_sender(sender)
    while text.lower() == 'tələblər və sənədlər':
        chat_id, text, update_id = bot.get_last_id_text(
            bot.get_updates(update_id + 1))
        sleep(0.5)
    if text.lower() == commands[0]:
        message = who_are_eligible
        commands = ["kart sifarişi", "sənəd siyahısı"]
        reply_markup = bot.reply_markup_maker(commands)
        bot.send_message(chat_id, message, reply_markup)
        chat_id, text, update_id = bot.get_last_id_text(
            bot.get_updates(update_id + 1))
        if text.lower() == commands[0]:
            credit_calculator.ask_credit_details(chat_id, update_id)
        elif text.lower() == commands[1]:
            message = documents_list
            commands = ["kart sifarişi"]
            reply_markup = bot.reply_markup_maker(commands)
            bot.send_message(chat_id, message, reply_markup)
            chat_id, text, update_id = bot.get_last_id_text(
                bot.get_updates(update_id + 1))
            if text.lower() == commands[0]:
                credit_calculator.ask_credit_details(chat_id, update_id)
    if text.lower() == commands[1]:
        message = documents_list
        commands = ["kart sifarişi"]
        reply_markup = bot.reply_markup_maker(commands)
        bot.send_message(chat_id, message, reply_markup)
        chat_id, text, update_id = bot.get_last_id_text(
            bot.get_updates(update_id + 1))
        if text.lower() == commands[0]:
            credit_calculator.ask_credit_details(chat_id, update_id)
    if text.lower() == commands[2]:
        #needs edit
        credit_calculator.ask_credit_details(chat_id, update_id)
Пример #6
0
def rates_and_payments(chat_id, update_id):
    sender = {'sender_id': chat_id, 'user_data': {}}
    commands = ['ödənişlər', 'faizlər', 'limitlər', 'geriyə qayıt']
    text = "Xidmətlərdən birini seçin"
    reply_markup = bot.reply_markup_maker(commands)
    bot.send_message(chat_id, text, reply_markup)
    chat_id, text, update_id = bot.get_last_id_text(
        bot.get_updates(update_id + 1))
    bot.insert_sender(sender)
    while text.lower() == 'faizlər və ödəniş':
        chat_id, text, update_id = bot.get_last_id_text(
            bot.get_updates(update_id + 1))
        sleep(0.5)
    if text.lower() == commands[0]:
        payments(chat_id, update_id)
    elif text.lower() == commands[1]:
        interest_rates(chat_id, update_id)
    elif text.lower() == commands[2]:
        limits(chat_id, update_id)
    elif text.lower() == commands[3]:
        card_order(chat_id, update_id)
Пример #7
0
def payments(chat_id, update_id):
    sender = {'sender_id': chat_id, 'user_data': {}}
    commands = ['ödəniş hesablama', 'borc öyrənmə', 'borcun ödənişi', 'geriyə']
    text = "Xidmətlərdən birini seçin"
    reply_markup = bot.reply_markup_maker(commands)
    bot.send_message(chat_id, text, reply_markup)
    chat_id, text, update_id = bot.get_last_id_text(
        bot.get_updates(update_id + 1))
    bot.insert_sender(sender)
    if text.lower() == commands[0]:
        message = payment_calculate + cabinet_url
        bot.send_message(chat_id, message, reply_markup=None)
        chat_id, text, update_id = bot.get_last_id_text(
            bot.get_updates(update_id + 1))
    if text.lower() == commands[1]:
        commands = ['cif nədir', 'geriyə']
        message = "BirKart üzrə borcunuzu öyrənmək üçün şəxsi kabinetinizə daxil olun. CİF kodunuzu daxil edərək, borcunuzu öyrənə bilərsiniz. https://birkart.az/cabinet/&%20"
        reply_markup = bot.reply_markup_maker(commands)
        bot.send_message(chat_id, message, reply_markup)
        chat_id, text, update_id = bot.get_last_id_text(
            bot.get_updates(update_id + 1))
        if text.lower() == commands[0]:
            message = cif
            commands = ['geriyə']
            reply_markup = bot.reply_markup_maker(commands)
            bot.send_message(chat_id, message, reply_markup)
            chat_id, text, update_id = bot.get_last_id_text(
                bot.get_updates(update_id + 1))
            if text.lower() == commands[0]:
                payments(chat_id, update_id)
        if text.lower() == commands[1]:
            payments(chat_id, update_id)
    if text.lower() == commands[2]:
        message = "Linkə daxil olub borcu ödəyə bilərsiniz : https://pay.kapitalbank.az/"
        bot.send_message(chat_id, message, reply_markup=None)
    if text.lower() == commands[3]:
        card_order(chat_id, update_id)
Пример #8
0
def limits(chat_id, update_id):
    sender = {'sender_id': chat_id, 'user_data': {}}
    commands = [
        'maaşa uyğun limit', 'birkart limiti', 'limit artırmaq', 'geriyə'
    ]
    text = "Xidmətlərdən birini seçin"
    reply_markup = bot.reply_markup_maker(commands)
    bot.send_message(chat_id, text, reply_markup)
    chat_id, text, update_id = bot.get_last_id_text(
        bot.get_updates(update_id + 1))
    bot.insert_sender(sender)
    if text.lower() == commands[1]:
        message = "Birkart kredit kartı üzrə limit 100 AZN-dən - 10 000 AZN-ə kimi olur, hər müştərinin maliyyə durumuna uyğun kredit limiti ayrılır."
        commands = ["maaşa görə hesabla", "geriyə"]
        reply_markup = bot.reply_markup_maker(commands)
        bot.send_message(chat_id, message, reply_markup)
Пример #9
0
def interest_rates(chat_id, update_id):
    sender = {'sender_id': chat_id, 'user_data': {}}
    commands = ['nağdlaşma', 'partnyor mağazalar', 'digər mağazalar', 'geriyə']
    text = "Xidmətlərdən birini seçin"
    reply_markup = bot.reply_markup_maker(commands)
    bot.send_message(chat_id, text, reply_markup)
    chat_id, text, update_id = bot.get_last_id_text(
        bot.get_updates(update_id + 1))
    bot.insert_sender(sender)
    if text.lower() == commands[1]:
        message = "Partnyor mağazalar -  BirKartla partnyor olduğumuz mağazalarda əməliyyat aparıb, faizsiz taksitlə ödəniş edə bilərsiz. Partnyor mağazalar siyahısı ilə tanış ola bilərsiniz : https://birkart.az/harada-kecerlidir?search=&category=&taksit=0&taksit2=18/&%20"
        commands = ["geriyə"]
        reply_markup = bot.reply_markup_maker(commands)
        bot.send_message(chat_id, message, reply_markup)
    if text.lower() == commands[2]:
        message = other_shops
        commands = ["geriyə"]
        reply_markup = bot.reply_markup_maker(commands)
        bot.send_message(chat_id, message, reply_markup)
    if text.lower() == commands[3]:
        rates_and_payments(chat_id, update_id)
Пример #10
0
#!/usr/bin/env python3
import logging
import time

from bot import get_updates, process_new_message

logging.basicConfig(level=logging.INFO,
                    format='%(asctime)s-%(name)s-%(levelname)s-%(message)s')

logger = logging.getLogger()

if __name__ == '__main__':
    last_update = 0
    while True:
        try:
            updates = get_updates(last_update)
        except:
            logger.error("Couldn't check for updates.")
            continue
        if updates:
            for update in updates:
                last_update = max(last_update, update['update_id'] + 1)
                process_new_message(update)
Пример #11
0
help_text = '''"добавь меня в список"-подписывает вас на ежедневную рассылку расписания
"удали меня из списка" - отписывает вас от рассылки
"раписание" - печатает расписание на сегодня
"раписание на пн/понедельник/завтра" - печатает расписание на выбранный день (работаеет только в пределах данной недели)'''

bad = [
    'гей', 'пидор', 'пидр', 'урод', 'хуй', 'уебок', 'уёбок', 'похёл на хуй',
    'пошел на хуй'
]
id_list = []

today = datetime.datetime.now().day

while True:
    bot.get_updates(new_offset)
    last = bot.get_last_update()
    if len(id_list) and today == datetime.datetime.now(
    ).day and 1 <= datetime.datetime.now().hour <= 2:
        for chat_id in id_list:
            bot.send_message(chat_id, ti_ta.get_time_table())
        today += 1
    if last:
        last_chat_id = last['message']['chat']['id']
        last_text = last['message']['text']
        if last_text.lower()[:len('расписание')] == 'расписание':
            last_text = ti_ta.get_time_table(
                last_text.lower()[len('расписание'):])
            if last_text == '':
                last_text = 'Не нашёл расписание'
        elif last_text.lower() == 'help':
Пример #12
0
import bot
from bot import Bot
import phoneNumberParser
import json

with open("./token.txt") as t:
    token = t.readlines()

bot = Bot(token[0].strip())
offset = ""
while True:
    js = bot.get_updates(offset)
    try:
        for item in js["result"]:
            offset = item["update_id"]
            message = bot.message
            # print necessary attributes
            print(bot.name)
            print(bot.username)
            if message == "/start":
                msg = "Hi, This is a bot, The bot helps you to parse phone numbers"\
                " from messages that has numbers and texts."\
                " This can only detect mobile phone numbers, not landline. The bot is in early"\
                " development stage and might have bugs, if you find any bug or glitches"\
                " send a message to - https://www.instagram.com/mr.monsterkoala/"
                bot.send_message(msg, bot.id)
            else:
                nums = phoneNumberParser.get_num(message)
                for num in nums:
                    msg = "call - {}\n\nwhatsapp - http://api.whatsapp.com/send?phone={}".format(
                        "91" + num, "91" + num)
Пример #13
0
def ask_credit_calculator_details(chat_id, update_id, step=0):
    """Ask credit details (credit_assurance, credit_months, credit_amount)
    from user and calculate (final_amount)
    """
    new_values = {'$set': {}}
    sender = {'sender_id': chat_id, 'user_data': {}}
    # bot.back_to_menu(chat_id,update_id)
    message = "Kredit sifarişi blokuna daxil olmusunuz. Təminatlıdır?"
    commands = ["Təminatlıdır", "Təminatlı Deyil", "Geriyə qayıt"]
    reply_markup = bot.reply_markup_maker(commands)
    bot.send_message(chat_id, message, reply_markup)
    chat_id, text, update_id = bot.get_last_id_text(
        bot.get_updates(update_id + 1))
    bot.insert_sender(sender)
    while text.lower() == 'kredit':
        chat_id, text, update_id = bot.get_last_id_text(
            bot.get_updates(update_id + 1))
        sleep(0.5)
    if text == commands[0]:
        new_values['$set']['user_data.credit_assurance'] = True
        sender = bot.update_sender(sender, new_values)
        print('True')
    elif text == commands[1]:
        new_values['$set']['user_data.credit_assurance'] = False
        sender = bot.update_sender(sender, new_values)
        print('False')
    elif text == commands[2]:
        bot.menu(chat_id, text, update_id)
        return
    print(text)
    message = "Kredit müddəti neçə aydır?"
    commands = ['12', '24', '36', 'Geriyə qayıt']
    reply_markup = bot.reply_markup_maker(commands)
    bot.send_message(chat_id, message, reply_markup)
    chat_id, text, update_id = bot.get_last_id_text(
        bot.get_updates(update_id + 1))
    while text == "Təminatlıdır":
        chat_id, text, update_id = bot.get_last_id_text(
            bot.get_updates(update_id + 1))
        sleep(0.5)
    if text in commands:
        if text == commands[3]:
            bot.menu(chat_id, text, update_id)
        else:
            new_values['$set']['user_data.credit_months'] = text
            sender = bot.update_sender(sender, new_values)
            message = "Kredit məbləği nə qədərdir?"
            bot.send_message(chat_id, message, reply_markup=None)
            chat_id, text, update_id = bot.get_last_id_text(
                bot.get_updates(update_id + 1))
            while text == "Kredit məbləği nə qədərdir?":
                chat_id, text, update_id = bot.get_last_id_text(
                    bot.get_updates(update_id + 1))
                sleep(0.5)
            if text:
                new_values['$set']['user_data.credit_amount'] = text
                sender = bot.update_sender(sender, new_values)
                calculated_credit = credit_calculator(
                    sender['user_data']['credit_assurance'],
                    int(sender['user_data']['credit_months']), int(text))
                new_values['$set'][
                    'user_data.credit_monthly'] = calculated_credit['monthly']
                new_values['$set'][
                    'user_data.credit_final_amount'] = calculated_credit[
                        'final_amount']
                sender = bot.update_sender(sender, new_values)
                print(calculated_credit)
                monthly = calculated_credit['monthly']
                final_amount = str(calculated_credit['final_amount'])
                message = f'{final_amount} məbləğində sifarişiniz qeydə alındı. Rəsmiləşdirmək istəyirsiniz?'
                commands = ["Bəli", "Xeyr"]
                reply_markup = bot.reply_markup_maker(commands)
                bot.send_message(chat_id, message, reply_markup)
                chat_id, text, update_id = bot.get_last_id_text(
                    bot.get_updates(update_id + 1))
                if text == commands[0]:
                    print('beli')
                    ask_credit_details(chat_id, update_id)
                    return
                else:
                    bot.menu(chat_id, text, update_id)