Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

navmenu

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

navmenu

A library to create multilevel menus for chatbots

  • 0.3.0
  • PyPI
  • Socket score

Maintainers
1

navmenu

A library to create multilevel menus for chatbots.

PyPI Version Python Versions Documentation Status Tests

Installation

navmenu can be installed with pip:

pip3 install navmenu

Introduction

First, import everything you will need:

from navmenu import MenuManager
from navmenu.actions import MessageAction, SubmenuAction, GoBackAction
from navmenu.contents import Content
from navmenu.io import ConsoleIO
from navmenu.item_contents import TextItemContent
from navmenu.items import Item
from navmenu.menus import Menu
from navmenu.state import MemoryStateHandler

Then, create a menu with one item:

menu = Menu(Content('Welcome!'), [
    Item('print', TextItemContent('print text'), MessageAction('Text message'))
])

'print' is the internal menu item name. It can be any string but must be unique within menu.

Also, you can add items to menus later:

new_item = Item('hello', TextItemContent('say hello'), MessageAction('Hello!'))
menu.add_item(new_item)

Every menu should be wrapped in a MenuManager:

menu_manager = MenuManager({
    'main_menu': menu
}, MemoryStateHandler('main_menu'))

MemoryStateHandler('main_menu') means that the user state will be saved in memory. It will not persist between app restarts. 'main_menu' is the name of the first menu to show.

Finally, show the menu to a user:

io = ConsoleIO(menu_manager)
io.start_loop()

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc