NimarkoGram Docs
RU
Docs/First plugin

First plugin

Add a settings button that shows a notification when tapped.

On this pageWhat you will buildRead the sourceInstall and try itChange the result

What you will build

A plugin named SDK Check adds one settings row, Check SDK. Tapping the row displays “Plugin is running”. This example needs no additional libraries or access to messages.

Read the source

Download hello-en.plugin. The full source appears below. To make the file yourself, save this code as a UTF-8 file ending in .plugin.

Python
__id__ = "sdk_hello"
__name__ = "SDK Check"
__description__ = "Shows a notification from the plugin settings."
__author__ = "NimarkoGram"
__version__ = "1.0"
__host__ = "NimarkoGram"
__sdk_version__ = ">=1.0"

from base_plugin import BasePlugin
from ui.bulletin import BulletinHelper
from ui.settings import Text


class HelloPlugin(BasePlugin):
    def create_settings(self):
        return [Text(text="Check SDK", on_click=self.show_status)]

    def show_status(self, view):
        BulletinHelper.show_info("Plugin is running")

Install and try it

  1. Send the file as a document to Saved Messages and open it in the GitHub edition of NimarkoGram.
  2. Check the name and author on the installation card. Choose Install. Select the option to enable after installation, or enable the plugin in the list yourself.
  3. Open NimarkoGram settings → Plugins → SDK Check and tap Check SDK.

Change the result

Edit the message passed to show_info and change __version__ to "1.1". Keep the same __id__ so the client recognizes the installed plugin. Send the edited file, open its update card and try the button again.