def respond_in_three(user_id, channel_id, message): reply_channel = ReplyChannel(channel_id) time.sleep(1) reply_channel.send('respond_in_three', message) time.sleep(3) reply_channel.send('respond_in_three', message) reply_channel.send('respond_in_three', message)
def fetch_blog_status(user_id, channel_id, message): """ returns blog status """ reply_channel = ReplyChannel(channel_id) user = User.objects.get(id=user_id) googleuser = GoogleUser.objects.get(user=user) reply_channel.send('blog_status_fetched', {"generated": googleuser.is_site_generated})
def generate_blog(user_id, channel_id, message): """ 1. get files from the user's 'blog' drive folder 2. convert those files to markdown and collect them under .../conversions/email/md/ """ reply_channel = ReplyChannel(channel_id) user = User.objects.get(id=user_id) googleuser = GoogleUser.objects.get(user=user) drive_service = get_drive_service(googleuser) reply_channel.send('blog_generation_initiated', {}) try: # matching folder may not be present. throw info in such case folder_id = get_folder(drive_service) # get all google docs files from the folder files = get_files_from_folder(drive_service, folder_id) md_files = get_md_files_from_folder(drive_service, folder_id) reply_channel.send('blog_generation_progress', {"progress": 40}) response = files clean_conversion_dir(user) download_docx_files(user, drive_service, files['files']) download_md_files(user, drive_service, md_files['files']) reply_channel.send('blog_generation_progress', {"progress": 60}) copy2octopress(reply_channel, googleuser) except client.AccessTokenCredentialsError: reply_channel.send('access_token_expired', {})