onlineconfbot

package module
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 23 Imported by: 0

README

onlineconf-bot

onlineconf-bot is used to send OnlineConf configuration changes notifications to subscribed users using Myteam, Mattermost, or Yandex Messenger messengers.

Requirements

OnlineConf (onlineconf-admin) >= v3.5.0

Installation

onlineconf-bot uses MySQL database to store user subscriptions and intermediate information. The database must be created and then populated with tables using schema.sql. An address and credentials of the database must be stored in the /database parameters (see below).

The only one instance of onlineconf-bot daemon should be run simultaneously.

Separate binaries will be built for each messenger supported, see Dockerfile for an example.

Configuration

onlineconf-bot uses OnlineConf BotAPI to retrieve notifications from OnlineConf. To add BotAPI user for onlineconf-bot the following configuration is required:

  • /onlineconf/botapi/bot/onlineconf-bot - the parameter name is the username, a value is SHA256 of a password (required)
  • /onlineconf/botapi/bot/onlineconf-bot/scopes = notifications (list, required)

onlineconf-bot is configured using OnlineConf itself, it reads onlineconf-bot module (/usr/local/etc/onlineconf-bot.cdb file). The module must be configured to contain the following /-separated parameters:

  • database
    • base - database name (default: onlineconf_bot)
    • host - database host (required)
    • pass - database password (required)
    • user - database username (default: onlineconf_bot)
  • mattermost (only used by onlineconf-mattermost-bot)
    • api-url - Mattermost API base URL (i.e. scheme and hostname)
    • ws-url - Mattermost Websocket base URL
    • token - Mattermost bot token
  • myteam (only used by onlineconf-myteam-bot)
    • token - a bot token retrieved from Metabot (required)
    • url - URL of an alternative Myteam installation
  • yamessenger (only used by onlineconf-yamessenger-bot)
    • token - OAuth bot token from Yandex 360 Bot Platform (required)
    • api-url - Yandex Messenger Bot API URL (default: https://botapi.messenger.yandex.net)
  • onlineconf
    • botapi
      • password - password (required)
      • url - URL of OnlineConf BotAPI (required)
      • username - username (default: onlineconf-myteam-bot)
      • wait - long polling wait time (default: 60)
    • link-url - URL of OnlineConf UI (required)
  • user
    • domain - domain name appended to OnlineConf username to match the messenger account
    • map - YAML/JSON-mapping of non-standard usernames from OnlineConf to the messenger account (without domain name)
  • probe
    • addr - Address where to listen web-server for probes (default: 0.0.0.0:8000)
    • uri - Http uri where to listen on web-server (default: /probe)
    • enabled - Enable or disable probe-server (default: disabled)

This configuration must be placed in OnlineConf under /onlineconf/module/onlineconf-bot.

The best way to achieve the described configuration on a server (or a container) where only onlineconf-bot is run is to create the following parameters:

Path Type Value
/onlineconf/botapi/bot/onlineconf-bot Text SHA256 of a password used by onlineconf-bot to connect to OnlineConf BotAPI
/onlineconf/botapi/bot/onlineconf-bot/scopes List notifications
/onlineconf/service/onlineconf-bot Text SHA256 of a password used by onlineconf-updater/onlineconf-csi-driver
/onlineconf/module Case key: service = onlineconf-bot
value: symlink to /onlineconf/chroot/onlineconf-bot
/onlineconf/chroot/onlineconf-bot YAML delimiter: /
/onlineconf/chroot/onlineconf-bot/onlineconf-bot Symlink /onlineconf/bot
/onlineconf/bot Null value is Null, children must contain the module structure described above

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStatusNotOK = errors.New("response status code is not 200")

Functions

func BotMain

func BotMain[botType Bot](newBot func(*onlineconf.Module, SubscriptionStorage) (botType, error))

func IsAdmin

func IsAdmin(user string) bool

Types

type Bot

type Bot interface {
	UpdatesProcessor(context.Context)
	Notify(ctx context.Context, user, link, text string) error
	MentionLink(string) string
	ParamLink(param, link string) string
}

type Notification

type Notification struct {
	ID          int        `json:"id"`
	Path        string     `json:"path"`
	Version     int        `json:"version"`
	ContentType string     `json:"type"`
	Value       NullString `json:"value"`
	MTime       string     `json:"mtime"`
	Author      string     `json:"author"`

	Comment      string            `json:"comment"`
	Action       string            `json:"action"`
	Notification string            `json:"notification"`
	Users        map[string]string `json:"users"`
	// contains filtered or unexported fields
}

func (*Notification) Text

func (notification *Notification) Text() string

type NotificationsResponse

type NotificationsResponse struct {
	Notifications []Notification `json:"notifications"`
	LastID        int            `json:"lastID"`
}

type Notifier

type Notifier struct {
	// contains filtered or unexported fields
}

type NullString

type NullString struct {
	sql.NullString
}

func (NullString) MarshalJSON

func (ns NullString) MarshalJSON() ([]byte, error)

func (*NullString) UnmarshalJSON

func (ns *NullString) UnmarshalJSON(data []byte) error

type ProbeServer added in v0.2.2

type ProbeServer interface {
	Run(ctx context.Context) error
}

func ProbeServerIfEnabled added in v0.2.2

func ProbeServerIfEnabled() ProbeServer

type Subscription

type Subscription struct {
	User string
	WO   bool
}

type SubscriptionStorage

type SubscriptionStorage interface {
	Subscribe(context.Context, string, bool) error
	Unsubscribe(context.Context, string) error
	Subscribers(context.Context) ([]Subscription, error)
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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