Example #1
0
def wait_line_upload_reactions(message):
    user_context = mem.UserContext(message.from_user.id)
    user_context.rm_status()
    _story = story.Story(user_context.get_context('story_id'))
    document = bot.get_file(message.document.file_id)
    _story.set_reaction(message.from_user.id,
                        bot.download_file(document.file_path))
Example #2
0
def rm_story(call):
    params = tools.get_call_back_params(call.data)
    user_context = mem.UserContext(call.from_user.id)
    _story = story.Story(int(user_context.get_context('story_id')))
    if params.get('is_sure'):
        _story.rm(call.from_user.id)
    else:
        _story.make_sure_rm(call.from_user.id)
Example #3
0
def wait_line_base_timeout(message):
    user_context = mem.UserContext(message.from_user.id)
    user_context.rm_status()
    _story = story.Story(user_context.get_context('story_id'))
    try:
        int(message.text)
    except:
        _story.show(message.from_user.id)
    else:
        _story.set_base_timeout(message.from_user.id, int(message.text))
Example #4
0
 def __init__(self, tg_id: int):
     user_resp = json.loads(
         requests.post(
             DB_URL.format(item='telegram_user', cmd='get'),
             json={
                 'tg_id': tg_id
             },
         ).text)
     self.id = int(user_resp['id'])
     self.telegram_id = int(user_resp['telegram_id'])
     self.stories = [
         story.Story(story_resp['id'])
         for story_resp in user_resp['stories']
     ]
Example #5
0
 def replace(self, new_num: int, tg_id: int):
     up_chapter_resp = json.loads(
         requests.post(
             DB_URL.format(item='chapter', cmd='replace'),
             json={
                 'story_id': self.story_id,
                 'tg_id': tg_id,
                 'chapter_id': self.id,
                 'new_num': new_num,
             },
         ).text)
     if up_chapter_resp.get('error'):
         msg = up_chapter_resp.get('error')
         tools.send_menu_msg(tg_id, msg)
     else:
         story.Story(self.story_id).show_chapters(tg_id)
Example #6
0
def wait_line_rename(message):
    user_context = mem.UserContext(message.from_user.id)
    user_context.rm_status()
    _story = story.Story(user_context.get_context('story_id'))
    _story.rename(message.from_user.id, message.text)
Example #7
0
def show_chapters(call):
    user_context = mem.UserContext(call.from_user.id)
    _story = story.Story(int(user_context.get_context('story_id')))
    _story.show_chapters(call.from_user.id)
Example #8
0
def show_story(call):
    params = tools.get_call_back_params(call.data)
    user_context = mem.UserContext(call.from_user.id)
    _story = story.Story(
        params.get('story_id') or int(user_context.get_context('story_id')))
    _story.show(call.from_user.id)
Example #9
0
def edit_k_timeout_story(call):
    user_context = mem.UserContext(call.from_user.id)
    _story = story.Story(int(user_context.get_context('story_id')))
    _story.get_timeout(call.from_user.id, story.SET_K_TIMEOUT)
Example #10
0
def rename_story(call):
    user_context = mem.UserContext(call.from_user.id)
    _story = story.Story(int(user_context.get_context('story_id')))
    _story.get_new_name(call.from_user.id)
Example #11
0
def download_reactions(call):
    user_context = mem.UserContext(call.from_user.id)
    _story = story.Story(int(user_context.get_context('story_id')))
    _story.get_reactions(call.from_user.id)