Basic memory function implemented
This commit is contained in:
@@ -2,7 +2,7 @@ import datetime
|
||||
import os
|
||||
from telegram.ext import ConversationHandler, CommandHandler, MessageHandler, filters, CallbackQueryHandler
|
||||
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
|
||||
ACTION_CHOICE, DATE_ENTRY, ADD_CONTENT, DELETE_ENTRY = range(4)
|
||||
ACTION_CHOICE, DATE_ENTRY, ADD_CONTENT = range(3)
|
||||
|
||||
from .basehandler import BaseHandler
|
||||
|
||||
@@ -23,10 +23,7 @@ class JournalHandler(BaseHandler):
|
||||
],
|
||||
ADD_CONTENT: [
|
||||
MessageHandler(filters.ALL, self.content_save),
|
||||
],
|
||||
DELETE_ENTRY: [
|
||||
MessageHandler(filters.ALL, self.delete_entry),
|
||||
]
|
||||
]
|
||||
},
|
||||
fallbacks=[],
|
||||
)
|
||||
@@ -71,7 +68,7 @@ class JournalHandler(BaseHandler):
|
||||
)
|
||||
if new:
|
||||
await query.edit_message_text(
|
||||
text=f"What is your entry for {self.current_model.date.strftime('%A, %-d. %B %Y')}?"
|
||||
text=f"What is your entry for {self.current_model.date_pretty}?"
|
||||
)
|
||||
else:
|
||||
await query.edit_message_text(text="An entry already exists for this date")
|
||||
@@ -102,11 +99,11 @@ class JournalHandler(BaseHandler):
|
||||
date = date
|
||||
)
|
||||
if self.current_model:
|
||||
return DELETE_ENTRY
|
||||
await self.delete_entry(update, context)
|
||||
else:
|
||||
await update.message.reply_text("No entry found for this date")
|
||||
context.chat_data["delete"] = False
|
||||
return ConversationHandler.END
|
||||
return ConversationHandler.END
|
||||
else:
|
||||
with self.models.db:
|
||||
self.current_model, new = self.models.JournalEntry.get_or_create(
|
||||
@@ -116,7 +113,7 @@ class JournalHandler(BaseHandler):
|
||||
await update.message.reply_text("An entry already exists for this date")
|
||||
return ConversationHandler.END
|
||||
else:
|
||||
await update.message.reply_text(f"What is your entry for {self.current_model.date.strftime('%A, %-d. %B %Y')}?")
|
||||
await update.message.reply_text(f"What is your entry for {self.current_model.date_pretty}?")
|
||||
return ADD_CONTENT
|
||||
|
||||
|
||||
@@ -156,5 +153,4 @@ class JournalHandler(BaseHandler):
|
||||
with self.models.db:
|
||||
self.current_model.delete_instance()
|
||||
context.chat_data["delete"] = False
|
||||
await update.callback_query.edit_message_text(text="Entry deleted ✅")
|
||||
return ConversationHandler.END
|
||||
await update.message.reply_text(text="Entry deleted ✅")
|
||||
Reference in New Issue
Block a user