gcalbot

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: BSD-3-Clause, MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const AllDayDateFormat = "2006-01-02"

Variables

This section is empty.

Functions

func FormatEvent

func FormatEvent(
	event *calendar.Event,
	calendarSummary string,
	timezone *time.Location,
	format24HourTime bool,
) (string, error)

func FormatTimeRange

func FormatTimeRange(
	startDateTime, endDateTime *calendar.EventDateTime,
	timezone *time.Location,
	format24HourTime bool,
) (timeRange string, err error)

func GetCalendarService

func GetCalendarService(account *Account, config *oauth2.Config) (srv *calendar.Service, err error)

func GetConvHelpText

func GetConvHelpText(channel chat1.ChatChannel, isKeybaseMessage bool) string

func GetDurationFromMinutes

func GetDurationFromMinutes(minutes int) time.Duration

func GetMinutesFromDuration

func GetMinutesFromDuration(duration time.Duration) int

func GetUserFormat24HourTime

func GetUserFormat24HourTime(srv *calendar.Service) (format24HourTime bool, err error)

func GetUserTimezone

func GetUserTimezone(srv *calendar.Service) (timezone *time.Location, err error)

func MinutesBeforeString

func MinutesBeforeString(minutesBefore int) string

func ParseTime

func ParseTime(startDateTime, endDateTime *calendar.EventDateTime) (start, end time.Time, isAllDay bool, err error)

Types

type Account

type Account struct {
	KeybaseUsername string
	AccountNickname string
	Token           oauth2.Token
}

type AccountHelpPage

type AccountHelpPage struct {
	Title string
}

type Channel

type Channel struct {
	ChannelID     string
	CalendarID    string
	ResourceID    string
	Expiry        time.Time
	NextSyncToken string
}

type ChannelAndAccount

type ChannelAndAccount struct {
	Channel Channel
	Account Account
}

type ConfigPage

type ConfigPage struct {
	Title          string
	ConvID         chat1.ConvIDStr
	ConvHelpText   string
	ConvIsPrivate  bool
	Account        string
	Accounts       []*Account
	CalendarID     string
	Calendars      []*calendar.CalendarListEntry
	Reminder       string
	Reminders      []ReminderType
	Invite         bool
	Updated        bool
	PushNotAllowed bool
}

type DB

type DB struct {
	*base.GoogleOAuthDB
}

func NewDB

func NewDB(db *sql.DB) *DB

func (*DB) CompleteState

func (d *DB) CompleteState(state string) error

func (*DB) CountSubscriptionsByAccountAndCalender

func (d *DB) CountSubscriptionsByAccountAndCalender(account *Account, calendarID string) (count int, err error)

func (*DB) DeleteAccount

func (d *DB) DeleteAccount(keybaseUsername, accountNickname string) error

func (*DB) DeleteChannelByChannelID

func (d *DB) DeleteChannelByChannelID(channelID string) error

func (*DB) DeleteSubscription

func (d *DB) DeleteSubscription(account *Account, subscription Subscription) error

func (*DB) ExistsAccount

func (d *DB) ExistsAccount(keybaseUsername string, accountNickname string) (exists bool, err error)

func (*DB) ExistsChannelByAccountAndCalendar

func (d *DB) ExistsChannelByAccountAndCalendar(account *Account, calendarID string) (exists bool, err error)

func (*DB) ExistsInvite

func (d *DB) ExistsInvite(account *Account, calendarID, eventID string) (exists bool, err error)

func (*DB) ExistsSubscription

func (d *DB) ExistsSubscription(account *Account, subscription Subscription) (exists bool, err error)

func (*DB) GetAccount

func (d *DB) GetAccount(keybaseUsername, accountNickname string) (account *Account, err error)

func (*DB) GetAccountListForUsername

func (d *DB) GetAccountListForUsername(keybaseUsername string) (accounts []*Account, err error)

func (*DB) GetChannel

func (d *DB) GetChannel(account *Account, calendarID string) (channel *Channel, err error)

func (*DB) GetChannelAndAccountByID

func (d *DB) GetChannelAndAccountByID(channelID string) (channel *Channel, account *Account, err error)

func (*DB) GetChannelListByAccount

func (d *DB) GetChannelListByAccount(account *Account) (channels []*Channel, err error)

func (*DB) GetExpiringChannelAndAccountList

func (d *DB) GetExpiringChannelAndAccountList() (pairs []*ChannelAndAccount, err error)

func (*DB) GetInviteAndAccountByUserMessage

func (d *DB) GetInviteAndAccountByUserMessage(keybaseUsername string, messageID chat1.MessageID) (invite *Invite, account *Account, err error)

func (*DB) GetReminderSubscriptionAndAccountPairs

func (d *DB) GetReminderSubscriptionAndAccountPairs() (pairs []*SubscriptionAndAccount, err error)

func (*DB) GetReminderSubscriptionsByAccountAndCalendar

func (d *DB) GetReminderSubscriptionsByAccountAndCalendar(
	account *Account,
	calendarID string,
	subscriptionType SubscriptionType,
) (subscriptions []*Subscription, err error)

func (*DB) GetState

func (d *DB) GetState(state string) (*OAuthRequest, error)

OAuth state

func (*DB) GetSubscriptions

func (d *DB) GetSubscriptions(account *Account, calendarID string, keybaseConvID chat1.ConvIDStr) (subscriptions []*Subscription, err error)

func (*DB) InsertAccount

func (d *DB) InsertAccount(account Account) error

Account

func (*DB) InsertChannel

func (d *DB) InsertChannel(account *Account, channel Channel) error

Channel

func (*DB) InsertInvite

func (d *DB) InsertInvite(account *Account, invite Invite) error

Invite

func (*DB) InsertSubscription

func (d *DB) InsertSubscription(account *Account, subscription Subscription) error

Subscription

func (*DB) PutState

func (d *DB) PutState(state string, oauthState OAuthRequest) error

func (*DB) UpdateChannel

func (d *DB) UpdateChannel(oldChannelID, newChannelID string, expiry time.Time) error

func (*DB) UpdateChannelNextSyncToken

func (d *DB) UpdateChannelNextSyncToken(channelID, nextSyncToken string) error

type ErrorPage

type ErrorPage struct {
	Title string
}

type EventStatus

type EventStatus string
const (
	EventStatusConfirmed EventStatus = "confirmed"
	EventStatusTentative EventStatus = "tentative"
	EventStatusCancelled EventStatus = "cancelled"
)

type HTTPSrv

type HTTPSrv struct {
	*base.HTTPSrv
	// contains filtered or unexported fields
}

func NewHTTPSrv

func NewHTTPSrv(
	stats *base.StatsRegistry,
	kbc *kbchat.API,
	debugConfig *base.ChatDebugOutputConfig,
	db *DB,
	oauthConfig *oauth2.Config,
	reminderScheduler ReminderScheduler,
	handler *Handler,
) *HTTPSrv

type Handler

type Handler struct {
	*base.DebugOutput
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(
	stats *base.StatsRegistry,
	kbc *kbchat.API,
	debugConfig *base.ChatDebugOutputConfig,
	db *DB,
	oauth *oauth2.Config,
	reminderScheduler ReminderScheduler,
	tokenSecret string,
	httpPrefix string,
) *Handler

func (*Handler) HandleCommand

func (h *Handler) HandleCommand(msg chat1.MsgSummary) error

func (*Handler) HandleNewConv

func (h *Handler) HandleNewConv(conv chat1.ConvSummary) error

func (*Handler) LoginToken

func (h *Handler) LoginToken(username string) string

type Invite

type Invite struct {
	CalendarID string
	EventID    string
	MessageID  chat1.MessageID
}

type InviteReaction

type InviteReaction string
const (
	InviteReactionYes   InviteReaction = "Yes 👍"
	InviteReactionNo    InviteReaction = "No 👎"
	InviteReactionMaybe InviteReaction = "Maybe 🤷"
)

type LoginPage

type LoginPage struct {
	Title string
}

type OAuthRequest

type OAuthRequest struct {
	KeybaseUsername string
	AccountNickname string
	KeybaseConvID   chat1.ConvIDStr
	IsComplete      bool
}

type ReminderScheduler

type ReminderScheduler interface {
	UpdateOrCreateReminderEvent(
		account *Account,
		subscription *Subscription,
		event *calendar.Event,
	) error
	AddSubscription(account *Account, subscription Subscription)
	RemoveSubscription(account *Account, subscription Subscription)
}

type ReminderType

type ReminderType struct {
	Minute  string
	Summary string
}

type RenewChannelScheduler

type RenewChannelScheduler struct {
	*base.DebugOutput
	sync.Mutex
	// contains filtered or unexported fields
}

func NewRenewChannelScheduler

func NewRenewChannelScheduler(
	stats *base.StatsRegistry,
	debugConfig *base.ChatDebugOutputConfig,
	db *DB,
	config *oauth2.Config,
	httpPrefix string,
) *RenewChannelScheduler

func (*RenewChannelScheduler) Run

func (r *RenewChannelScheduler) Run() error

func (*RenewChannelScheduler) Shutdown

func (r *RenewChannelScheduler) Shutdown() error

type ResponseStatus

type ResponseStatus string
const (
	ResponseStatusNeedsAction ResponseStatus = "needsAction"
	ResponseStatusDeclined    ResponseStatus = "declined"
	ResponseStatusTentative   ResponseStatus = "tentative"
	ResponseStatusAccepted    ResponseStatus = "accepted"
)

type Subscription

type Subscription struct {
	CalendarID     string
	KeybaseConvID  chat1.ConvIDStr
	DurationBefore time.Duration
	Type           SubscriptionType
}

type SubscriptionAndAccount

type SubscriptionAndAccount struct {
	Subscription Subscription
	Account      Account
}

type SubscriptionType

type SubscriptionType string
const (
	SubscriptionTypeInvite   SubscriptionType = "invite"
	SubscriptionTypeReminder SubscriptionType = "reminder"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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