Version: v1.0.4 Latest Latest

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

Go to latest
Published: Jan 12, 2021 License: GPL-3.0 Imports: 8 Imported by: 0




This section is empty.


This section is empty.


func GetRandomFact

func GetRandomFact(db *gorm.DB, category string) string

GetRandomFact provides a random fact from the given category

func GetRandomThanks

func GetRandomThanks(db *gorm.DB, category string) string

GetRandomThanks provides a random passive-aggressive thanks message

func Init

func Init(host, user, pass, name, port string) (*gorm.DB, error)

Init establishes a postgresql database connection

func MakeFactMessage

func MakeFactMessage(category string, db *gorm.DB) string

MakeFactMessage generates a fact for the given category

func MakeReplyMessage

func MakeReplyMessage(category string, db *gorm.DB) string

MakeReplyMessage generates a reply message for the given category

func Populate added in v0.1.5

func Populate(db *gorm.DB, categoryName, factCSV string) error

Populate populates them with default data about cats, you must provide your own csv

func Reset added in v0.1.5

func Reset(db *gorm.DB)

Reset drops all tables and then creates them


type CatEnthusiast

type CatEnthusiast struct {
	Name             string `gorm:"unique"`
	PhoneNumber      string `gorm:"unique"` // Format +1XXXXXXXXXX
	Active           bool   // Send facts to active user
	FactCategory     string
	SubscriptionID   uint
	TotalSentSession int // Total messages sent to user during current subscription
	TotalSent        int // Total messages sent to user over all time

CatEnthusiast represents users of CatFacts

type Category

type Category struct {
	Name           string `gorm:"unique"`
	SubscribeMsg   string
	UnsubscribeMsg string

Category is a category of fact, such as cat

type Fact

type Fact struct {
	Body     string
	Category string

Fact is a simple fact on any category, such as "cat"

type Greeting

type Greeting struct {
	Category string
	Body     string

Greeting is prepended to facts sent to the user

type ReplyMessage

type ReplyMessage struct {
	Category string
	Body     string

ReplyMessage is prepended to a fact any time the user trieds to reply to the text message The only time this will not trigger is if the user sends the correct unsubscribe keyword

type Subscription

type Subscription struct {
	Frequency       string `gorm:"unique"` // Descriptive name such as "daily" or "every fifteen minutes"
	Description     string `gorm:"unique"` // Short description of the subscription
	Cron            string `gorm:"unique"` // cron string, only ints and special characters *,- accepted
	ThanksThreshold int    // Number of messages sent prior to beginning of say thanks hints

Subscription describes the frequency with which text messages are sent, and how soon unsubscribe hints begin

type ThanksMessage

type ThanksMessage struct {
	Category string
	Body     string

ThanksMessage passive-aggressively urges the user to say thanks, the secret unsubscribe word

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL