discord

package
v0.0.2-rc2 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package discord provides a discord bot to poll NDX contracts

Index

Constants

This section is empty.

Variables

View Source
var (
	// ExampleConfig is primarily used to provide a template for generating the config file
	ExampleConfig = &Config{
		MainDiscordToken: "CHANGEME-MAIN",
		InfuraAPIKey:     "INFURA-KEY",
		InfuraWSEnabled:  false,
		ETHRPCEndpoint:   "http://localhost:8545",
		Watchers: []Watcher{
			{DiscordToken: "CHANGEME-TOKEN", Currency: "CHANGEME-CURRENCY"},
		},
	}
)

Functions

func BaseEmbed

func BaseEmbed() *discordgo.MessageEmbed

BaseEmbed returns a base message embed type to be customized

func NewConfig

func NewConfig(path string) error

NewConfig generates a new config and stores at path

Types

type Client

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

Client wraps bclient and discordgo to provide a discord bot for indexed finance

func NewClient

func NewClient(ctx context.Context, cfg *Config, bc *bclient.Client) (*Client, error)

NewClient provides a wrapper around discordgo

func (*Client) Close

func (c *Client) Close() error

Close terminates the discordgo session

type Config

type Config struct {
	// the token used by the main bot (NDXBot)
	MainDiscordToken string `yaml:"main_discord_token"`
	// if nil we dont use infura and connect directly to the rpc node below
	InfuraAPIKey    string    `yaml:"infura_api_key"`
	InfuraWSEnabled bool      `yaml:"infura_ws_enabled"`
	ETHRPCEndpoint  string    `yaml:"eth_rpc_endpoint"`
	Watchers        []Watcher `yaml:"watchers"`
}

Config bundles together discord configuration information

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig loads the configuration

type Watcher

type Watcher struct {
	DiscordToken string `yaml:"discord_token"`
	Currency     string `yaml:"currency"`
}

Watcher is used to start a process that watches the price of a token and posts its value as a name

Jump to

Keyboard shortcuts

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