def addEntry(update, context): if(not isBotAuthorized(update.effective_chat.id)): context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['UNAUTHORIZED_MESSAGE'].format(update.effective_chat.id)) else: updateJournal(update.message.text) context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['JOURNALENTRY_MESSAGE'].format(update.message.text))
def hypothesis(update, context): if (not isBotAuthorized(update.effective_chat.id)): context.bot.send_message( chat_id=update.effective_chat.id, text=bot_messages['UNAUTHORIZED_MESSAGE'].format( update.effective_chat.id)) else: if (isManageHypothesis()): path = getAnnotationPath(context.args[0]) #print(path) pageAlias = getWebPageTitle(context.args[0]) updateJournal(getHypothesisAnnotations(context.args[0]), False, path, True, pageAlias) if (isHypothesisEmbedded()): updateJournal(entry='{{embed [[' + getPageTitle(path) + ']]}}') else: updateJournal(entry="Annotations of [" + pageAlias + "](" + getPageTitle(path) + ")") else: updateJournal(getHypothesisAnnotations(context.args[0]), False) context.bot.send_message( chat_id=update.effective_chat.id, text=bot_messages['HYPOTHESIS_MESSAGE'].format(context.args[0]))
def TimeSpacedRepetition(update, context, uid=""): if(not isBotAuthorized(update.effective_chat.id)): context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['UNAUTHORIZED_MESSAGE']) else: try: arg = context.args[0] except: arg = "" if arg == "import": importFlashCards(update, context) else: if(uid): roundCount = int(context.user_data[uid][1]) roundGoal = int(context.user_data[uid][2]) else: uid = str(uuid4()) roundCount = 1 try: roundGoal = int(arg) except: roundGoal = getflashcardDailyGoal() flashcard = flashcards.getFlashcardFromPool() if(flashcard): message = "Card " + str(roundCount) + " out of " + str(roundGoal) + "\n" context.bot.send_message(chat_id=update.effective_chat.id, text=message) context.user_data[uid] = [flashcard, roundCount, roundGoal] return ShowSkipCancelMenu(update, context, uid) else: context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['NOPENDIGCARDS_MESSAGE'])
def pullnow(update, context): if(not isBotAuthorized(update.effective_chat.id)): context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['UNAUTHORIZED_MESSAGE']) else: print("Unscheduled Housekeeping ...") context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['PULL_MESSAGE']) Git2Json() context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['PULLDONE_MESSAGE'])
def importFlashCards(update, context): if(not isBotAuthorized(update.effective_chat.id)): context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['UNAUTHORIZED_MESSAGE'].format(update.effective_chat.id)) else: context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['IMPORTINGFC_MESSAGE']) importResults = updateFlashCards() message = bot_messages['IMPORTEDFC_MESSAGE'].format(importResults[0],importResults[1]) context.bot.send_message(chat_id=update.effective_chat.id, text=message)
def version(update, context): if (not isBotAuthorized(update.effective_chat.id)): context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['UNAUTHORIZED_MESSAGE']) else: context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['VER_MESSAGE'].format( BotName, getBotVersion()))
def tsrRetired(update, context): if (not isBotAuthorized(update.effective_chat.id)): context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['UNAUTHORIZED_MESSAGE']) else: message = "command /tsr is being replace by /srs please use the latter from now on" context.bot.send_message(chat_id=update.effective_chat.id, text=message)
def help(update, context): if(not isBotAuthorized(update.effective_chat.id)): context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['UNAUTHORIZED_MESSAGE']) else: commands = ["/help","/start","/uptime","/ver","/anno"] message = bot_messages['HELP_MESSAGE'] for command in commands: message += command + "\n" context.bot.send_message(chat_id=update.effective_chat.id, text=message)
def start(update, context): if (not isBotAuthorized(update.effective_chat.id)): context.bot.send_message( chat_id=update.effective_chat.id, text=bot_messages['UNAUTHORIZED_MESSAGE'].format( update.effective_chat.id)) else: context.bot.send_message( chat_id=update.effective_chat.id, text=bot_messages['WELCOME_MESSAGE'].format(BotName))
def decryptall(update, context): if (not isBotAuthorized(update.effective_chat.id)): context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['UNAUTHORIZED_MESSAGE']) else: context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['DECRYPTINGRAPH_MESSAGE']) decryptGraph() context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['DECRYPTDONE_MESSAGE'])
def image_handler(update, context): if(not isBotAuthorized(update.effective_chat.id)): context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['UNAUTHORIZED_MESSAGE'].format(update.effective_chat.id)) else: # print ( context.bot.getFile(update.message.photo[-1])) file = context.bot.getFile(update.message.photo[-1].file_id) f = BytesIO(file.download_as_bytearray()) path = updateAsset(f.getvalue(),"jpg") updateJournal(path, ignoreURL=True) context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['IMAGEUPLOAD_MESSAGE'].format(BotName,getBotVersion()))
def uptime(update, context): if (not isBotAuthorized(update.effective_chat.id)): context.bot.send_message( chat_id=update.effective_chat.id, text=bot_messages['UNAUTHORIZED_MESSAGE'].format( update.effective_chat.id)) else: message = "I've been up for %d days, %d hours, %d minutes, %d seconds" % getUptime( ) context.bot.send_message(chat_id=update.effective_chat.id, text=message)
def generateMinmapHTML(update, context): if(not isBotAuthorized(update.effective_chat.id)): context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['UNAUTHORIZED_MESSAGE'].format(update.effective_chat.id)) else: context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['FILEREQ_MESSAGE']) PageName = str(' '.join(context.args)) MindMap = convert2Mindmap(PageName) if(MindMap): HTMLOut = """ <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>""" + PageName + """ Mindmap</title> <style> * { margin: 0; padding: 0; } #mindmap { display: block; width: 100vw; height: 100vh; } </style> </head> <body> <svg id="mindmap"></svg> <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> <script>((e,t,r)=>{const{Markmap:n}=e();window.mm=n.create("svg#mindmap",null==t?void 0:t(),r)})(()=>window.markmap,t=>{return t=t||window.d3,{color:(n=t.scaleOrdinal(t.schemeCategory10),t=>n(t.p.i))};var n}, """ + convert2Mindmap(PageName) + """)</script> </body> </html>""" s = StringIO() s.write(HTMLOut) s.seek(0) buf = BytesIO() buf.write(s.getvalue().encode()) buf.seek(0) fileName = "mm_" + PageName.replace(' ','_').strip() buf.name = f'{fileName}.html' context.bot.send_document(chat_id=update.message.chat_id, document=buf) else: context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['FILENOTFOUND_MESSAGE'].format(PageName))
def generateMD(update, context): if(not isBotAuthorized(update.effective_chat.id)): context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['UNAUTHORIZED_MESSAGE'].format(update.effective_chat.id)) else: context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['FILEREQ_MESSAGE']) PageName = str(' '.join(context.args)) s = StringIO() s.write(convert2MD(PageName)) s.seek(0) buf = BytesIO() buf.write(s.getvalue().encode()) buf.seek(0) #buf.name = f'PageName.md' buf.name = f'{PageName}.md' context.bot.send_document(chat_id=update.message.chat_id, document=buf)
def listAllThemes(update, context): if (not isBotAuthorized(update.effective_chat.id)): context.bot.send_message( chat_id=update.effective_chat.id, text=bot_messages['UNAUTHORIZED_MESSAGE'].format( update.effective_chat.id)) else: AllThemes = getAllThemes() button_list = [] i = 0 for theme in AllThemes: button_list.append([ InlineKeyboardButton(theme[0], callback_data="ThemeSwitcher_" + str(i)) ]) i += 1 button_list.append([ InlineKeyboardButton(btns['CANCEL'], callback_data=btns['CANCEL']) ]) reply_markup = InlineKeyboardMarkup(button_list) context.bot.send_message(chat_id=update.effective_chat.id, text=bot_messages['PICKTHEME_MESSAGE'], reply_markup=reply_markup)