telegram

package
v0.0.0-...-f69f2d5 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: MIT Imports: 9 Imported by: 0

README

Telegram Connector

The telegram connector plugin enables the management of the Automator via the Telegram messaging systems

The plugin is enabled by including a [telegram] section in your configuration toml file.

[telegram]

## speakers for which messages should be logged. If empty, all 
speakers = ["Office", "Kitchen"]

## ignore_messages describes the message types to be ignored
## one or more of "ConnectionStateUpdated", "NowPlaying", "Volume"
## all if empty
ignore_messages = ["ConnectionStateUpdated"] 

## Telegram API Key
apiKey ="1292466187:AAG3O6QyfNSpEgNq5JrlpINz4w5z6bQIrk8"
authorizedSenders = ["999999", "888888"]
authKey = "ThisIsAVerySecretKey34abf77&"

In order to use the telegram plugin usefully you have registered your "bot" with Telegram. For this, you will need an apiKey which you have to provide in the respective field in the config-toml.

It is up to you to name and make the bot accessible to you and your authorized contacts.

While everybody can see the bot in the Telegram world, only authorizedSenders will receive insights into your Soundtouch systems.

You become an authorized user by either adding your ID in the field authorizedSenders. In addition, a Telegram member can add himself to the list of authorized users by sending the message (command)

/authorize $authKey$ to the bot.

authKey$ is the key specified in the authKeyfield of the configuration toml.

Please note that the authorization is not persistent and you have to reauthorize if you restart the Automator.

The following commands have been implemented so far

/hello - You will receive your name and your userId back
/authorize [authKey] - You authorize yourself to the system
/stats [speakerName] - Get the status of your soundtouch system or from a specific speaker

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	Config
	Plugin soundtouch.PluginFunc
	// contains filtered or unexported fields
}

Bot describes the plugin. It has a Config to store the configuration Plugin the plugin function

func NewTelegramLogger

func NewTelegramLogger(config Config) (d *Bot)

NewTelegramLogger creates a new Logger plugin with the configuration

func (*Bot) Description

func (d *Bot) Description() string

Description returns a string explaining the purpose of this plugin

func (*Bot) Disable

func (d *Bot) Disable()

Disable temporarely the execution of the plugin

func (*Bot) Enable

func (d *Bot) Enable()

Enable temporarely the execution of the plugin

func (*Bot) Execute

func (d *Bot) Execute(pluginName string, update soundtouch.Update, speaker soundtouch.Speaker)

Execute runs the plugin with the given parameter

func (*Bot) IsEnabled

func (d *Bot) IsEnabled() bool

IsEnabled returns true if the plugin is not suspened

func (*Bot) Name

func (d *Bot) Name() string

Name returns the plugin name

func (*Bot) SampleConfig

func (d *Bot) SampleConfig() string

SampleConfig returns text explaining how plugin should be configured

func (*Bot) Terminate

func (d *Bot) Terminate() bool

Terminate indicates that no further plugin will be executed on this speaker

type Config

type Config struct {
	Speakers         []string `toml:"speakers"`
	IgnoreMessages   []string `toml:"ignore_messages"`
	APIKey           string   `toml:"apiKey"`
	AuthorizedSender []string `toml:"authorizedSenders"`
	AuthKey          string   `toml:"authKey"`
}

Config contains the configuration of the plugin Speakers list of SpeakerNames the handler is added. All if empty IgnoreMessages a list of message types to be ignored APIKey for the telegram bot

Jump to

Keyboard shortcuts

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