예제 #1
0
def random_meme_handler(update: Update, context: CallbackContext):
    response = external_service.get_random_meme()
    telegram_util.send_message(
        update,
        cst.MEME_MESSAGE_TEMPLATE.format(response["caption"],
                                         response["category"],
                                         response["image"]))
예제 #2
0
def confirm_bro_handler(update: Update, context: CallbackContext):
    listMessages = file_service.get_message_from_file(cst.FN_CONFIRM_BRO)
    index = r.randint(0, len(listMessages) - 1)
    message = listMessages[index]
    if "@{}" in message:
        message = message.format(telegram_util.get_username(update))
    telegram_util.send_message(update, message)
예제 #3
0
def improve_confirm_bro_handler(update: Update, context: CallbackContext):
    if len(context.args) == 0:
        telegram_util.send_message(update, cst.IMPROVE_EXAMPLE_CONFIRM_BRO)
    else:
        improve_confirm_bro(context.args)
        from_user_username = telegram_util.get_username(update)
        telegram_util.send_message(
            update, cst.THANKS_FOR_IMPROVE.format(from_user_username))
예제 #4
0
 def wrapper(arg1,arg2):
     schedule.run_pending()
     username = telegram_util.get_username(arg1)
     count = util.spam_counter(username)
     print("{} : {}".format(username, count))
     if count > 10:
         telegram_util.send_message(arg1, SPAM_MESSAGE.format(username))
         util.spam_counter_reset(username)
     else:
         util.spam_add(username)
         result = func(arg1,arg2)
         return result
예제 #5
0
def improve_music_handler(update: Update, context: CallbackContext):
    if len(context.args) == 0:
        telegram_util.send_message(update, cst.IMPROVE_EXAMPLE_MUSIC)
    else:
        from_user_username = telegram_util.get_username(update)
        if improve_music(context.args):
            telegram_util.send_message(
                update, cst.THANKS_FOR_IMPROVE.format(from_user_username))
        else:
            telegram_util.send_message(
                update, cst.LINK_MUST_BE_UNIQUE.format(from_user_username))
예제 #6
0
def info_handler(update: Update, context: CallbackContext):
    listMessages = file_service.get_message_from_file(cst.FN_INFO)
    text: str = "\n".join(listMessages)
    telegram_util.send_message(update, text)
예제 #7
0
def music_handler(update: Update, context: CallbackContext):
    listLinks = file_service.get_message_from_file(cst.FN_MUSIC)
    index = r.randint(0, len(listLinks) - 1)
    telegram_util.send_message(update, listLinks[index])
예제 #8
0
def greeting_message_handler(update: Update, context: CallbackContext):
    # todo from_user_username = __get_username(update)
    listMessages = file_service.get_message_from_file(cst.FN_GREETING_MESSAGE)
    index = r.randint(0, len(listMessages) - 1)
    telegram_util.send_message(update, listMessages[index])
예제 #9
0
def error_handler(update: Update, context: CallbackContext):
    telegram_util.send_message(update, cst.ERROR_MESSAGE)
예제 #10
0
def tag_handler(update: Update, context: CallbackContext):
    telegram_util.send_message(
        update,
        "@hamidsultanzadeh @JustAydinn @Allahyarrr @NyzVortex @ram365 @knncortexx @Huseyn28"
    )