Docs/First plugin
First plugin
Add a settings button that shows a notification when tapped.
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.
__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
- Send the file as a document to Saved Messages and open it in the GitHub edition of NimarkoGram.
- 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.
- 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.