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))
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)
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))
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'] ]
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)
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)
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)
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)
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)
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)
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)