示例#1
0
def main():
    read_config()
    dump_db()
    pack_files()
    upload_files()
    delete_backups()
    send_notif(config.get('telegram_user_id'),
               'Backup completed successfully!!!')
示例#2
0
def main():
    read_config()
    dump_db()
    pack_files()
    upload_files()
    delete_backups()
    send_notif(
        config.get('telegram_user_id'), 'Backup completed successfully for ' +
        config.get('app_name') + '.com' + '!')
示例#3
0
def setup_notifications():
    retries = 0

    while (retries < 3):
        print(
            "\nSend any message to Telegram bot @GhostBackupBot\n"
            "you can also use this link ",
            end="")
        display_msg("https://t.me/GhostBackupBot", "link", "")
        print("\nOnce done enter your Telegram username without '@'")

        user_input = input().lower().strip()
        print("\nWait for sometime to setup notifications..")
        time.sleep(2)

        resp = requests.get('https://api.telegram.org/bot484412347:'
                            'AAH0ZavyA0yiYx1MYDngPQMt1HJkhcqTpmc/getUpdates')

        for message_obj in resp.json()['result']:
            chat_obj = message_obj['message']['chat']

            if 'username' in chat_obj.keys(
            ) and chat_obj['username'] == user_input:
                backup_options['telegram_user_id'] = chat_obj['id']
                send_notif(
                    chat_obj['id'],
                    "Hi {0},\n\nStarting today you'll receive updates about "
                    "your Ghost blog backup on this chat. Have a nice day 😉"
                    .format(chat_obj['first_name']))
                break

        if backup_options.get('telegram_user_id', None) != None:
            display_msg("\nNotification setup successfully completed!!!",
                        'options')
            break
        else:
            print("\nAre you sure your username is correct and you "
                  "sent a msg @GhostBackupBot?")
            print("As the notification setup failed, retrying...")
            retries += 1

    if not backup_options.get('telegram_user_id'):
        display_msg("\nNotification setup failed", "error")