sms

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Overview

diyi sms (http://www.1xinxi.cn/) Admin (http://sms.1xinxi.cn/)

Index

Constants

View Source
const (
	DEFAULT_GROUP_NAME = "default" // default config group name
)
View Source
const (
	DIYI_SMS_SERVICE_URL = "http://sms.1xinxi.cn/asmx/smsservice.aspx?"
)

Variables

This section is empty.

Functions

func AddConfigNode

func AddConfigNode(group string, node ConfigNode)

AddConfigNode adds one node configuration to configuration of given group.

func AddDefaultConfigGroup

func AddDefaultConfigGroup(nodes ConfigGroup)

AddDefaultConfigGroup adds multiple node configurations to configuration of default group.

func AddDefaultConfigNode

func AddDefaultConfigNode(node ConfigNode)

AddDefaultConfigNode adds one node configuration to configuration of default group.

func GetDefaultGroup

func GetDefaultGroup() string

GetDefaultGroup returns the { name of default configuration.

func Register

func Register(name string, driver Driver) error

Register registers custom sms driver to sms

func SetConfig

func SetConfig(config Config)

SetConfig sets the global configuration for sms. It will overwrite the old configuration of sms config

func SetConfigGroup

func SetConfigGroup(group string, nodes ConfigGroup)

SetConfigGroup sets the configuration for given group.

func SetDefaultGroup

func SetDefaultGroup(name string)

SetDefaultGroup sets the group name for default configuration.

Types

type Config

type Config map[string]ConfigGroup

Config is the configuration management object.

type ConfigAliyun

type ConfigAliyun struct {
	AccessKeyId  string // accesskey id
	AccessSecret string // access secret
	Sign         string //signname
}

ConfigAliyun aliyun sms config

type ConfigDiyi

type ConfigDiyi struct {
	Name string //用户名
	Pass string //密码
	Sign string //签名
}

ConfigDiyi diyi config

type ConfigGroup

type ConfigGroup []ConfigNode

ConfigGroup is a alice of configuration node for specifile named group.

func GetConfig

func GetConfig(group string) ConfigGroup

GetConfig retrieves and returns the configuration of given group.

type ConfigNode

type ConfigNode struct {
	// mu     sync.RWMutex
	Driver string          // sms driver
	Weight int             // weight for load balance
	Path   string          // template toml files storage path
	Config *gmap.StrAnyMap // dirver config
	Data   *gmap.StrStrMap // template data
}

ConfigNode is configuration for one node.

type Core

type Core struct {
	SMS SMS // SMS interface object.
	// contains filtered or unexported fields
}

Core is the base struct for sms management

func (*Core) GetDebug

func (c *Core) GetDebug() bool

GetDebug returns the debug value.

func (*Core) GetLogger

func (c *Core) GetLogger() *glog.Logger

GetLogger returns the logger of the orm.

func (*Core) LoadTemplateFileToData

func (c *Core) LoadTemplateFileToData(node *ConfigNode) error

LoadTemplateFileToData is only load once.

func (*Core) Send

func (c *Core) Send(mobile string, template string, params map[string]string) error

Send

func (*Core) SetDebug

func (c *Core) SetDebug(debug bool)

SetDebug enables/disables the debug mode.

func (*Core) SetLogger

func (c *Core) SetLogger(logger *glog.Logger)

SetLogger sets the logger for orm.

type Driver

type Driver interface {
	New(core *Core, node *ConfigNode) (SMS, error)
	Send(mobile string, template string, params map[string]string) error
}

Driver is the interface for sms drivers

type DriverAliyun

type DriverAliyun struct {
	*Core
	Config *ConfigAliyun
	// contains filtered or unexported fields
}

DriverAliyun is the driver for sms

func (*DriverAliyun) New

func (d *DriverAliyun) New(core *Core, node *ConfigNode) (SMS, error)

New create new driver object and return

func (*DriverAliyun) Send

func (d *DriverAliyun) Send(mobile string, template string, params map[string]string) error

Send send content to giving mobile

type DriverDiyi

type DriverDiyi struct {
	*Core
	Config *ConfigDiyi
	// contains filtered or unexported fields
}

DriverDiyi is the driver for sms.

func (*DriverDiyi) New

func (d *DriverDiyi) New(core *Core, node *ConfigNode) (SMS, error)

New create and return a sms object

func (*DriverDiyi) Send

func (d *DriverDiyi) Send(mobile string, template string, params map[string]string) error

Send send content to the given mobile

type SMS

type SMS interface {
	Send(mobile string, template string, params map[string]string) error
	SetLogger(logger *glog.Logger)
	GetLogger() *glog.Logger
}

SMS defines the interfaces for SMS operations.

func Instance

func Instance(name ...string) (sms SMS, err error)

Instance get a sms instance

func New

func New(name ...string) (sms SMS, err error)

New creates and returns a SMS object with global configuration The parameter <name> specifiels the configuration group name

Jump to

Keyboard shortcuts

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