Exemple #1
0
def start_conversation(bot, update):
    user_peer = update.get_effective_user()
    general_message = TextMessage(ReadyMessage.start_conversation)
    btn_list = [
        TemplateMessageButton(text=TMessage.send_tweet,
                              value=TMessage.send_tweet,
                              action=0),
        TemplateMessageButton(text=TMessage.get_home_time_line,
                              value=TMessage.get_home_time_line,
                              action=0),
        TemplateMessageButton(text=TMessage.search,
                              value=TMessage.search,
                              action=0),
        TemplateMessageButton(text=TMessage.info,
                              value=TMessage.info,
                              action=0)
    ]
    template_message = TemplateMessage(general_message=general_message,
                                       btn_list=btn_list)
    kwargs = {
        "message": template_message,
        "user_peer": user_peer,
        "try_times": 1
    }
    bot.send_message(template_message,
                     user_peer,
                     success_callback=success,
                     failure_callback=failure,
                     kwargs=kwargs)
    dispatcher.finish_conversation(update)
Exemple #2
0
    def initiate_search_officers(self, bot, update):
        self.handlers.extend(self.dispatcher.message_handlers)
        user = update.get_effective_user()
        message = TemplateMessage(
            TextMessage(ConstantMessage.officer_search_criterion), [
                TemplateMessageButton(ButtonMessage.all_officers),
                TemplateMessageButton(ButtonMessage.main_menu_message)
            ])
        self.send_message(bot, update, message, user,
                          sys._getframe().f_code.co_name)
        self.handlers.extend([
            MessageHandler(
                TemplateResponseFilter(keywords=[ButtonMessage.all_officers]),
                self.handle_customer_criterion_input),
            MessageHandler(
                TemplateResponseFilter(
                    keywords=[ButtonMessage.main_menu_message]),
                self.show_menu),
        ])

        # TODO: This seems odd to me to add two lists, find a better way if possible
        self.dispatcher.register_conversation_next_step_handler(
            update, self.handlers + [
                MessageHandler(TextFilter(),
                               self.handle_customer_criterion_input)
            ])
Exemple #3
0
Fichier : bot.py Projet : mmdaz/Bot
def start_bot(bot, update):
    user_peer = update.get_effective_user()
    input = update.get_effective_message()
    print(input.text)
    btn_list = [
        TemplateMessageButton("ساختن هشدار جدید ", "/create_alarm", 0),
        TemplateMessageButton("اضافه کردن بدهی ", "/add_debt", 0),
        TemplateMessageButton("گرفتن فایل اکسل صورتحساب ها  ", "/get_excel", 0)
    ]
    temlate_message = TemplateMessage(
        general_message=Message.START_BOT_MESSAGE, btn_list=btn_list)
    bot.send_message(temlate_message,
                     user_peer,
                     success_callback=success,
                     failure_callback=failure)
    dispatcher.register_conversation_next_step_handler(update, [
        MessageHandler(TemplateResponseFilter(keywords=["/create_alarm"]),
                       start_creating_alarm),
        MessageHandler(TemplateResponseFilter(keywords=["/add_debt"]),
                       start_get_debt_conversation),
        MessageHandler(TemplateResponseFilter(keywords=["/get_excel"]),
                       send_excel_report),
        MessageHandler(TextFilter(keywords=["/start"]), start_bot),
        MessageHandler(TemplateResponseFilter(keywords=["/start"]), start_bot)
    ])
Exemple #4
0
def get_tweet_text(bot, update):
    user_peer = update.get_effective_user()
    user_id = user_peer.peer_id
    user = get_user(user_id=user_id)
    if not check_user_registration(update, user_peer, user):
        return 0
    general_message = TextMessage(ReadyMessage.send_text_twitter)
    btn_list = [
        TemplateMessageButton(text=TMessage.cancel,
                              value=TMessage.cancel,
                              action=0)
    ]
    template_message = TemplateMessage(general_message=general_message,
                                       btn_list=btn_list)
    kwargs = {
        "message": template_message,
        "user_peer": user_peer,
        "try_times": 1
    }
    bot.send_message(template_message,
                     user_peer,
                     success_callback=success,
                     failure_callback=failure,
                     kwargs=kwargs)
    dispatcher.register_conversation_next_step_handler(update, [
        CommandHandler("info", info),
        MessageHandler(TextFilter(), send_tweet),
        MessageHandler(DefaultFilter(), start_conversation)
    ])
Exemple #5
0
def search_tweets(bot, update):
    query = update.get_effective_message().text
    user = dispatcher.get_conversation_data(update, "user")
    statuses = search_api(user=user, query=query)

    statuses = statuses.get("statuses")
    if statuses:
        loop = asyncio.get_event_loop()
        loop.call_soon(send_status_message, 0, loop, statuses, bot, update)
        dispatcher.finish_conversation(update)
    else:
        btn_list = [
            TemplateMessageButton(text=ButtonText.back,
                                  value=ButtonText.back,
                                  action=0)
        ]
        general_message = TextMessage(ReadyText.no_search_result)
        template_message = TemplateMessage(general_message=general_message,
                                           btn_list=btn_list)
        kwargs = {
            "message": template_message,
            "update": update,
            "bot": bot,
            "try_times": 1
        }
        bot.respond(update,
                    template_message,
                    success_callback=success_send_message,
                    failure_callback=failure_send_message,
                    kwargs=kwargs)
        dispatcher.finish_conversation(update)
Exemple #6
0
def send_tweet(bot, update):
    user_peer = update.get_effective_user()
    tweet_text = update.get_effective_message().text
    user = dispatcher.get_conversation_data(update, "user")
    if send_tweet_api(user=user, tweet_text=tweet_text):
        general_message = TextMessage(ReadyText.success_tweet)
    else:
        general_message = TextMessage(ReadyText.fail_tweet)
    btn_list = [
        TemplateMessageButton(text=ButtonText.back,
                              value=ButtonText.back,
                              action=0)
    ]
    template_message = TemplateMessage(general_message=general_message,
                                       btn_list=btn_list)
    kwargs = {
        "message": template_message,
        "update": update,
        "bot": bot,
        "try_times": 1
    }
    bot.send_message(template_message,
                     user_peer,
                     success_callback=success_send_message,
                     failure_callback=failure_send_message,
                     kwargs=kwargs)
    dispatcher.finish_conversation(update)
Exemple #7
0
def get_tweet_text(bot, update):
    user_peer = update.get_effective_user()
    user = get_registered_user(bot, update)
    if user:
        dispatcher.set_conversation_data(update, "user", user)
        general_message = TextMessage(ReadyText.send_text_twitter)
        btn_list = [
            TemplateMessageButton(text=ButtonText.cancel,
                                  value=ButtonText.cancel,
                                  action=0)
        ]
        template_message = TemplateMessage(general_message=general_message,
                                           btn_list=btn_list)
        kwargs = {
            "message": template_message,
            "update": update,
            "bot": bot,
            "try_times": 1
        }
        bot.send_message(template_message,
                         user_peer,
                         success_callback=success_send_message,
                         failure_callback=failure_send_message,
                         kwargs=kwargs)
        dispatcher.register_conversation_next_step_handler(
            update, common_handlers + [
                MessageHandler(TextFilter(), send_tweet),
                MessageHandler(DefaultFilter(), start_conversation)
            ])
Exemple #8
0
    def show_menu(self, bot, update, response=None, user_data=None):
        self.dispatcher.clear_conversation_data(update=update)

        user_peer = update.get_effective_user()
        if not User.exists(user_peer.peer_id):
            session.add(
                User(peer_id=user_peer.peer_id,
                     access_hash=user_peer.access_hash))
            session.commit()

        categories = session.query(Category).all()
        category_list = [
            TemplateMessageButton(category.description)
            for category in categories
        ]
        message = TemplateMessage(TextMessage(ConstantMessage.menu_message),
                                  category_list)
        kwargs = {
            'update': update,
            'user_id': user_peer.peer_id,
            'step': sys._getframe().f_code.co_name
        }
        bot.send_message(message,
                         user_peer,
                         success_callback=self.success_sending_message,
                         failure_callback=self.failure_send_message,
                         **kwargs)
Exemple #9
0
def send_tweet(bot, update):
    user_peer = update.get_effective_user()
    user_id = user_peer.peer_id
    tweet_text = update.get_effective_message().text
    user = get_user(user_id=user_id)
    if send_tweet_api(final_oauth_token=user.final_oauth_token,
                      final_oauth_token_secret=user.final_oauth_token_secret,
                      tweet_text=tweet_text):
        general_message = TextMessage(ReadyMessage.success_tweet)
    else:
        general_message = TextMessage(ReadyMessage.fail_tweet)
    btn_list = [
        TemplateMessageButton(text=TMessage.back,
                              value=TMessage.back,
                              action=0)
    ]
    template_message = TemplateMessage(general_message=general_message,
                                       btn_list=btn_list)
    kwargs = {
        "message": template_message,
        "user_peer": user_peer,
        "try_times": 1
    }
    bot.send_message(template_message,
                     user_peer,
                     success_callback=success,
                     failure_callback=failure,
                     kwargs=kwargs)
    dispatcher.finish_conversation(update)
    def handle_report_begin_date(self, bot, update):
        user = update.get_effective_user()
        message = arabic_to_eng_number(update.get_effective_message().text)
        if re.match(RegexPattern.interval_pattern, message):
            split_message = message.split('-')
            self.dispatcher.set_conversation_data(
                update=update,
                key='start_time_delta',
                value=split_message[0]
            )
            self.dispatcher.set_conversation_data(
                update=update,
                key='end_time_delta',
                value=split_message[1]
            )
            self.create_and_send_final_report(update, bot)

        else:
            row_date = re.match(RegexPattern.jalali_input_pattern, message)
            if row_date:
                message = TemplateMessage(
                    TextMessage(ConstantMessage.service_report_end_date),
                    [TemplateMessageButton(ButtonMessage.main_menu_message)]
                )
                self.dispatcher.set_conversation_data(
                    update=update,
                    key='begin_date',
                    value=row_date
                )
                self.send_message(
                    bot,
                    update,
                    message,
                    user,
                    sys._getframe().f_code.co_name
                )
                self.dispatcher.register_conversation_next_step_handler(
                    update,
                    self.handlers +
                    [
                        MessageHandler(
                            TextFilter(),
                            self.handle_report_end_date
                        ),
                    ]
                )

            else:
                message = TextMessage(ConstantMessage.bad_format)
                self.send_message(
                    bot,
                    update,
                    message,
                    user,
                    sys._getframe().f_code.co_name
                )
Exemple #11
0
def start(bot, update):
    message = TextMessage("سلام. به فروشگاه ما خوش اومدید!")
    message2 = TextMessage("برو ببین اومد یا نه")
    user_peer = update.get_effective_user()
    buttons = [
        TemplateMessageButton(text="خرید", value="test", action=1),
        TemplateMessageButton(text="درباره ما", value="test", action=1)
    ]
    template = TemplateMessage(general_message=message, btn_list=buttons)
    testing = Transaction(total_price=1111, number=100, shopper='haji')
    testing.save()
    bot.send_message(template,
                     user_peer,
                     success_callback=success,
                     failure_callback=failure)
    bot.send_message(message2,
                     user_peer,
                     success_callback=success,
                     failure_callback=failure)
def get_template_buttons_from_branches(branches):
    btn_list = []
    keywords = []
    for branch in branches:
        if isinstance(branch, MoneyChangerBranch):
            keywords.append(str(branch.id))
            btn_list.append(
                TemplateMessageButton(text=branch.address[:60],
                                      value=branch.id,
                                      action=0))
    return btn_list, keywords
Exemple #13
0
def main_menu(bot, update):
    user_peer = update.get_effective_user()
    btn_list = [
        TemplateMessageButton(text="a", value="a", action=0),
        TemplateMessageButton(text="b", value="b", action=0),
        TemplateMessageButton(text="c", value="c", action=0)
    ]
    general_message = TextMessage("hahahahahah")
    template_message = TemplateMessage(general_message=general_message,
                                       btn_list=btn_list)
    second_kwargs = {
        "message": template_message,
        "update": update,
        "bot": bot,
        "try_times": 1
    }
    bot.send_message(template_message,
                     user_peer,
                     success_callback=success_send_message,
                     failure_callback=failure_send_message,
                     kwargs=second_kwargs)
Exemple #14
0
def send_status_message(id_index, loop, statuses, bot, update):
    user_peer = update.get_effective_user()
    if id_index == len(statuses) - 1:
        btn_list = [
            TemplateMessageButton(text=ButtonText.show_more,
                                  value=ButtonText.show_more,
                                  action=0),
            TemplateMessageButton(text=ButtonText.back,
                                  value=ButtonText.back,
                                  action=0)
        ]
        status = statuses[id_index]
        status_text = get_status_message(status)
        message = TextMessage(status_text)
        template_message = TemplateMessage(general_message=message,
                                           btn_list=btn_list)
        kwargs = {
            "message": template_message,
            "update": update,
            "bot": bot,
            "try_times": 1
        }
        bot.send_message(template_message,
                         user_peer,
                         success_callback=success_send_message,
                         failure_callback=failure_send_message,
                         kwargs=kwargs)
        return 0
    status = statuses[id_index]
    status_text = get_status_message(status)
    message = TextMessage(status_text)
    kwargs = {"message": message, "update": update, "bot": bot, "try_times": 1}
    bot.send_message(message,
                     user_peer,
                     success_callback=success_send_message,
                     failure_callback=failure_send_message,
                     kwargs=kwargs)
    id_index += 1
    loop.call_later(BotConfig.send_delay, send_status_message, id_index, loop,
                    statuses, bot, update)
    def show_menu(self, bot, update, response=None, user_data=None):
        self.dispatcher.clear_conversation_data(update=update)

        user_peer = update.get_effective_user()
        message = TemplateMessage(
            TextMessage(ConstantMessage.menu_message),
            [
                TemplateMessageButton(ButtonMessage.officer_score_message),
                TemplateMessageButton(ButtonMessage.customer_search_message),
                TemplateMessageButton(ButtonMessage.officer_search_message),
            ]
        )
        kwargs = {
            'update': update,
            'user_id': user_peer.peer_id,
            'step': sys._getframe().f_code.co_name
        }
        bot.send_message(
            message,
            user_peer, success_callback=self.success_sending_message,
            failure_callback=self.failure_send_message,
            **kwargs
        )
Exemple #16
0
def verify(bot, update):
    user_peer = update.get_effective_user()
    user_id = user_peer.peer_id
    auth = dispatcher.get_conversation_data(update, "auth")
    oauth_verifier = update.get_effective_message().text
    access_hash = user_peer.access_hash
    final_dict = final_verify(oauth_verifier=oauth_verifier,
                              oauth_token=auth['oauth_token'],
                              oauth_token_secret=auth['oauth_token_secret'])
    result = insert_user(
        user_id=user_id,
        access_hash=access_hash,
        final_oauth_token=final_dict.get("final_oauth_token"),
        final_oauth_token_secret=final_dict.get("final_oauth_token_secret"))
    if not result or not final_dict:
        text_message = TextMessage(ReadyMessage.fail_insert_user)
        kwargs = {
            "message": text_message,
            "user_peer": user_peer,
            "try_times": 1
        }
        bot.send_message(text_message,
                         user_peer,
                         success_callback=success,
                         failure_callback=failure,
                         kwargs=kwargs)
        dispatcher.finish_conversation(update)
        return 0
    general_message = TextMessage(ReadyMessage.success_insert_user)
    btn_list = [
        TemplateMessageButton(text=TMessage.send_tweet,
                              value=TMessage.send_tweet,
                              action=0)
    ]
    template_message = TemplateMessage(general_message=general_message,
                                       btn_list=btn_list)
    kwargs = {
        "message": template_message,
        "user_peer": user_peer,
        "try_times": 1
    }
    bot.send_message(template_message,
                     user_peer,
                     success_callback=success,
                     failure_callback=failure,
                     kwargs=kwargs)
    dispatcher.finish_conversation(update)
Exemple #17
0
 def officer_score_initial_state(self, bot, update):
     self.handlers.extend(self.dispatcher.message_handlers)
     user = update.get_effective_user()
     message = TemplateMessage(
         TextMessage(ConstantMessage.report_begin_date_message),
         [TemplateMessageButton(ButtonMessage.main_menu_message)])
     self.send_message(bot, update, message, user,
                       sys._getframe().f_code.co_name)
     self.handlers.extend([
         MessageHandler(
             TemplateResponseFilter(
                 keywords=[ButtonMessage.main_menu_message]),
             self.show_menu),
     ])
     self.dispatcher.register_conversation_next_step_handler(
         update, self.handlers +
         [MessageHandler(TextFilter(), self.handle_report_begin_date)])
def get_buttons_from_money_changers(money_changers):
    btn_list = []
    keywords = []
    for changer in money_changers:
        if isinstance(changer, MoneyChanger):
            dollar_rial = float(changer.dollar_rial)
            dollar_afghani = float(changer.dollar_afghani)
            afghani = change_rial_to_afghan_currency(
                rial=int(10000000),
                dollar_rial=dollar_rial,
                dollar_afghani=dollar_afghani,
                remittance_fee_percent=changer.remittance_fee_percent)
            afghan_currency_amount = eng_to_arabic_number(
                thousand_separator(int(afghani)))
            text = changer.name + "/ " + BotTexts.wage.format(
                afghan_currency_amount)
            btn_list.append(
                TemplateMessageButton(text=text, value=changer.id, action=0))
            keywords.append(str(changer.id))

    return btn_list, keywords
Exemple #19
0
def info(bot, update):
    btn_list = [
        TemplateMessageButton(text=ButtonText.back,
                              value=ButtonText.back,
                              action=0)
    ]
    general_message = TextMessage(ReadyText.information)
    template_message = TemplateMessage(general_message=general_message,
                                       btn_list=btn_list)
    kwargs = {
        "message": template_message,
        "update": update,
        "bot": bot,
        "try_times": 1
    }
    bot.respond(update,
                template_message,
                success_callback=success_send_message,
                failure_callback=failure_send_message,
                kwargs=kwargs)
    dispatcher.finish_conversation(update)
Exemple #20
0
def help_me(bot, update):
    user_peer = update.get_effective_user()
    btn_list = [
        TemplateMessageButton(text=TMessage.back,
                              value=TMessage.back,
                              action=0)
    ]
    general_message = TextMessage(ReadyMessage.help)
    template_message = TemplateMessage(general_message=general_message,
                                       btn_list=btn_list)
    kwargs = {
        "message": template_message,
        "user_peer": user_peer,
        "try_times": 1
    }
    bot.send_message(template_message,
                     user_peer,
                     success_callback=success_send_message,
                     failure_callback=failure_send_message,
                     kwargs=kwargs)
    dispatcher.finish_conversation(update)
Exemple #21
0
def get_registered_user(bot, update):
    user_peer = update.get_effective_user()
    user = User.get_user_by_peer_id(user_peer.peer_id)
    if user:
        return user
    else:
        general_message = TextMessage(ReadyText.need_registration)
        btn_list = [TemplateMessageButton(text=ButtonText.register)]
        template_message = TemplateMessage(general_message=general_message,
                                           btn_list=btn_list)
        kwargs = {
            "message": template_message,
            "update": update,
            "bot": bot,
            "try_times": 1
        }
        bot.send_message(template_message,
                         user_peer,
                         success_callback=success_send_message,
                         failure_callback=failure_send_message,
                         kwargs=kwargs)
        dispatcher.finish_conversation(update)
        return False
Exemple #22
0
def check_user_registration(update, user_peer, user):
    if user:
        return user
    else:
        general_message = TextMessage(ReadyMessage.not_register)
        btn_list = [
            TemplateMessageButton(text=TMessage.register,
                                  value=TMessage.register,
                                  action=0)
        ]
        template_message = TemplateMessage(general_message=general_message,
                                           btn_list=btn_list)
        kwargs = {
            "message": template_message,
            "user_peer": user_peer,
            "try_times": 1
        }
        bot.send_message(template_message,
                         user_peer,
                         success_callback=success,
                         failure_callback=failure,
                         kwargs=kwargs)
        dispatcher.finish_conversation(update)
        return False
Exemple #23
0
def get_home_time_line(bot, update):
    user_peer = update.get_effective_user()
    user_id = user_peer.peer_id
    user = get_user(user_id=user_id)
    if not check_user_registration(update, user_peer, user):
        return 0
    time_line = get_home_time_line(
        final_oauth_token=user.final_oauth_token,
        final_oauth_token_secret=user.final_oauth_token_secret)
    a = 1
    for tweet in time_line:
        media_dict = tweet.get("media_dict")
        if media_dict:
            print("meddddddddddddiiiiiiiiiiiiiaaaaaaaaaaa")
            media_url = media_dict.get("media_url")
            print(media_url)
            # import ast
            # media_url = ast.literal_eval(media_url)
            print(media_url)
            height = media_url.get("height")
            width = media_url.get("width")

            def file_upload_success(result, user_data):
                print("upload was successful : ", result)
                print(user_data)
                file_id = str(user_data.get("file_id", None))
                access_hash = str(user_data.get("user_id", None))
                file_size = str(user_data.get("file_size", None))

                photo_message = PhotoMessage(
                    file_id=file_id,
                    access_hash=access_hash,
                    name="Bale",
                    file_size='11337',
                    mime_type="image/jpeg",
                    caption_text=TextMessage(text="Bale"),
                    file_storage_version=1,
                    thumb=None)

                bot.send_message(photo_message,
                                 user_peer,
                                 success_callback=success,
                                 failure_callback=failure)

            bot.upload_file(file="media_url",
                            file_type="file",
                            success_callback=file_upload_success,
                            failure_callback=failure)

        message = TextMessage(
            ReadyMessage.tweet_message.format(
                tweet.get("text"), tweet.get("tweet_link"), tweet.get("name"),
                tweet.get("screen_name"),
                eng_to_arabic_number(tweet.get("favorite_count")),
                eng_to_arabic_number(tweet.get("retweet_count")),
                eng_to_arabic_number(tweet.get("datetime"))))
        if a == len(time_line):
            btn_list = [
                TemplateMessageButton(text=TMessage.show_more,
                                      value=TMessage.show_more,
                                      action=0)
            ]
            template_message = TemplateMessage(general_message=message,
                                               btn_list=btn_list)
            kwargs = {
                "message": template_message,
                "user_peer": user_peer,
                "try_times": 1
            }
            bot.send_message(template_message,
                             user_peer,
                             success_callback=success,
                             failure_callback=failure,
                             kwargs=kwargs)
            break
        kwargs = {"message": message, "user_peer": user_peer, "try_times": 1}
        bot.send_message(message,
                         user_peer,
                         success_callback=success,
                         failure_callback=failure,
                         kwargs=kwargs)
        a += 1
    dispatcher.finish_conversation(update)
Exemple #24
0
class TMB:
    info = TemplateMessageButton("راهنما")
    register = TemplateMessageButton("ثبت نام کاربری")
    update_auth = TemplateMessageButton("احراز هویت مجدد")
def get_template_buttons_from_list(input_list):
    btn_list = []
    for i in input_list:
        btn_list.append(TemplateMessageButton(text=i))
    return btn_list
Exemple #26
0
def success_send_message_and_start_again(response, user_data):
    kwargs = user_data['kwargs']
    update = kwargs["update"]
    bot = kwargs["bot"]
    user_peer = update.get_effective_user()
    logger.info(LogMessage.success_send_message,
                extra={
                    "user_id": user_peer.peer_id,
                    "tag": "info"
                })
    start_conversation(bot, update)


main_menu = [
    TemplateMessageButton(text=ButtonText.send_tweet,
                          value=ButtonText.send_tweet,
                          action=0),
    TemplateMessageButton(text=ButtonText.get_home_time_line,
                          value=ButtonText.get_home_time_line,
                          action=0),
    TemplateMessageButton(text=ButtonText.search,
                          value=ButtonText.search,
                          action=0),
    TemplateMessageButton(text=ButtonText.info,
                          value=ButtonText.info,
                          action=0)
]

register = [
    TemplateMessageButton(text=ButtonText.register,
                          value=ButtonText.register,
Exemple #27
0
                       "user_id": user_peer.peer_id,
                       "tag": "info"
                   })
    start_conversation(bot, update)


def is_admin(user_id):
    user_id = str(user_id)
    for admin_user_id in Config.admin_user_id_list:
        if user_id == admin_user_id:
            return True
    return False


main_menu = [
    TemplateMessageButton(text=TMessage.inbox, value=TMessage.inbox, action=0),
    TemplateMessageButton(text=TMessage.get_my_link,
                          value=TMessage.get_my_link,
                          action=0),
    TemplateMessageButton(text=TMessage.send_direct,
                          value=TMessage.send_direct,
                          action=0),
    TemplateMessageButton(text=TMessage.help, value=TMessage.help, action=0)
]


# =================================== Start Conversation ===========================================
@dispatcher.message_handler(filters=[DefaultFilter()])
def start_conversation(bot, update):
    user_peer = update.get_effective_user()
    general_message = TextMessage(ReadyMessage.initiate)
Exemple #28
0
Fichier : bot.py Projet : mmdaz/Bot
from balebot.updater import Updater
from Bot.alarm import Alarm
from Bot.debt import Debt
from Bot.template_messages import Message
from balebot.models.base_models import Peer
import jdatetime
from DataBase.database_operations import save_alarm, search_alarm_for_send, update_alarm_time, search_stop_message, \
    update_alarm_activation, check_stop_message_repetition, search_debt_for_send, save_photo, get_photo_id, \
    get_photo_by_id, update_user_excel_file

# global variables :

loop = asyncio.get_event_loop()
updater = Updater(token="63d52735b75ff858191152a038d746b956ef950e", loop=loop)
dispatcher = updater.dispatcher
button_list = [TemplateMessageButton("بازگشت به منوی اصلی", "/start", 0)]

users_dict = {}
user = None


def success(result):
    print("success : ", result)


def failure(result):
    print("failure : ", result)


def file_upload_success(result, user_data):
    print("u success : ", result)
Exemple #29
0
class BotButtons:
    remove_branch = TemplateMessageButton("حذف یک شعبه")
    update_dollar_afghani = TemplateMessageButton("تغییر نسبت افغانی به دلار")
    update_card_number = TemplateMessageButton("تغییر شماره کارت")
    update_dollar_rial = TemplateMessageButton("تغییر نسبت دلار به ریال")
    update_remittance_fee_percent = TemplateMessageButton(
        "تغییر درصد حق الزحمه انتقال پول")
    register_branch = TemplateMessageButton("ثبت شعبه جدید")
    back_to_main_menu = TemplateMessageButton("بازگشت به منوی اصلی")
    help = TemplateMessageButton("راهنمایی")
    register = TemplateMessageButton("ثبت نام")
    remittance = TemplateMessageButton("انتقال پول")
    money_changer_panel = TemplateMessageButton("منو صرافی")
    user_panel = TemplateMessageButton("منو کاربر")

    cities = [
        TemplateMessageButton("کابل"),
        TemplateMessageButton("هرات"),
        TemplateMessageButton("مزار شریف")
    ]
    money_changer_branches = [
        TemplateMessageButton("کابل"),
        TemplateMessageButton("هرات"),
        TemplateMessageButton("مزار شریف")
    ]