go-telegram-flow

command module
v0.0.0-...-92e709b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2019 License: MIT Imports: 1 Imported by: 0

README

Go Report Card

go-telegram-flow

Flow is a small framework for Telegram that is based on this telegram bot package and this locale package

go get -u github.com/kisulken/go-telegram-flow

With this library you can create dynamic menus & logical chains in Telegram just by defining the flow! Wow!

To see the full example check _examples directory

    // menu
	flow, err := menu.NewMenuFlow("flow1", b, "_examples/menu/lang", defaultLocale)
	if err != nil {
		panic(err)
	} 
	flow.GetRoot().
		Add("greetings", userPressGreeting).
		AddWith("order", userPress,
			flow.NewNode("pizza", userPress).
				Add("margarita", userOrderPizza).
				Add("pepperoni", userOrderPizza).
				Add("back", userPressBack), // traditional way of making back buttons
			flow.NewNode("sushi", userPress).
				Add("temaki", userOrderSushi).
				Add("nigiri", userOrderSushi).
				Add("sasazushi", userOrderSushi).
				Add("back", userPressBack),
			flow.NewBackNode("back"), // a short hand for making back buttons
		).
		Add("invoice", userPressInvoice).
		Add("language", userPressLanguage).GetFlow().Build("en").Build("ru")
    // chain
	flow, err = chain.NewChainFlow("flow1", b)
	if err != nil {
		panic(err)
	}

	flow.DefaultHandler(defaultResponse).GetRoot().
		Then("name", stageName, tb.OnText).
		Then("phone", stagePhone, tb.OnContact).
		Then("share_location", stageShareLocation, tb.OnText).
		Then("location", stageLocation, tb.OnLocation)

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL