__id__ = "sdk_chat_note"
__name__ = "Chat note"
__description__ = "Shows a saved note from the chat menu."
__author__ = "NimarkoGram"
__version__ = "1.0"
__host__ = "NimarkoGram"
__sdk_version__ = ">=1.0"
__required_apis__ = ["add_menu_item", "get_setting"]

from base_plugin import BasePlugin, MenuItemData, MenuItemType
from ui.bulletin import BulletinHelper
from ui.settings import Input

DEFAULT_NOTE = "Check the list"


class ChatNote(BasePlugin):
    def create_settings(self):
        return [Input(key="note", text="Note text", default=DEFAULT_NOTE)]

    def on_plugin_load(self):
        self.add_menu_item(MenuItemData(
            menu_type=MenuItemType.CHAT_ACTION_MENU,
            text="My note",
            on_click=self.show_note,
        ))

    def show_note(self, context):
        note = self.get_setting("note", DEFAULT_NOTE)
        BulletinHelper.show_info(note.strip() or DEFAULT_NOTE)
