core

package
v0.0.0-...-fe336e1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CHAT_TYPE_PRIVATE    = "private"
	CHAT_TYPE_GROUP      = "group"
	CHAT_TYPE_SUPERGROUP = "supergroup"

	COMMAND_SET_BIRTHDAY   = "/setbirthday"
	COMMAND_UNSET_BIRTHDAY = "/unsetbirthday"
	COMMAND_GET_BIRTHDAY   = "/getbirthday"
	COMMAND_MY_BIRTHDAY    = "/mybirthday"
	COMMAND_NEXT_BIRTHDAY  = "/nextbirthday"
	COMMAND_START          = "/start"
	COMMAND_HELP           = "/help"
	COMMAND_PRIVACY        = "/privacy"
	COMMAND_SOURCE         = "/source"
	COMMAND_CLEAR          = "/clear"
	COMMAND_CLEAR_FULL     = "/clear all data"
	REACTION_THUMBS_UP     = "👍"

	DEFAULT_YEAR       = 2000
	INPUT_DATE_LAYOUT  = "2.1"
	OUTPUT_DATE_LAYOUT = "January 2"
)
View Source
const (
	MESSAGE_WRONG_FORMAT        = "" /* 237-byte string literal not displayed */
	MESSAGE_SAVE_FAILURE        = "" /* 298-byte string literal not displayed */
	MESSAGE_GET_FAILURE         = "" /* 307-byte string literal not displayed */
	MESSAGE_GET_OWN_BIRTHDAY    = "" /* 231-byte string literal not displayed */
	MESSAGE_GET_BIRTHDAY        = "" /* 276-byte string literal not displayed */
	MESSAGE_NO_OWN_BIRTHDAY_SET = "" /* 248-byte string literal not displayed */
	MESSAGE_NO_BIRTHDAY_SET     = "" /* 238-byte string literal not displayed */
	MESSAGE_UNSET_FAILURE       = "" /* 275-byte string literal not displayed */
	MESSAGE_NEXT_BIRTHDAY       = "" /* 232-byte string literal not displayed */
	MESSAGE_NEXT_BIRTHDAYS      = "" /* 258-byte string literal not displayed */
	MESSAGE_NO_BIRTHDAYS        = "" /* 241-byte string literal not displayed */
	MESSAGE_GET_BOT_BIRTHDAY    = "" /* 218-byte string literal not displayed */
	MESSAGE_SHORT_HELP          = "Oh, senpai! (⁄ ⁄>⁄ ▽ ⁄<⁄)\nIf you need help, just type /help, okay? (˶˃ ᵕ ˂˶)♡"
	MESSAGE_GROUP_COMMAND       = "Nyaa~ (≧◡≦) Sorry, senpai!\nI can only do that in group chats! (≧ω≦)ᡣ𐭩"
	MESSAGE_FULL_HELP           = "ヾ(。・ω・。) H-Hi there!\nI'm a birthday bot, here to make sure you never forget anyone's special day! Add me to your group, and I'll remind everyone about birthdays! (´▽`ʃ♡ƪ)\n" +
		"Birthday messages are sent at 7 AM UTC (。-ω-)ᶻ𝗓𐰁\n" +
		"Group commands:\n" +
		"\t/setbirthday 31.01 - sets your birthday\n" +
		"\t/mybirthday - returns your birthday\n" +
		"\t/getbirthday - returns your birthday or a birthday of the person you're replying to\n" +
		"\t/nextbirthday - returns the next birthday in the chat\n" +
		"\t/unsetbirthday - unsets your birthday\n\n" +
		"Commands that work here in a private chat:\n" +
		"\t/help - returns this message\n" +
		"\t/privacy - returns the information on privacy\n" +
		"\t/source - returns a link to the source code\n" +
		"\t/clear all data - removes all your data stored by this bot (every birthday you've set in every group)\n"
	MESSAGE_PRIVACY = "This bot stores your user id, username, first name, last name and a birthday date for every chat where you have set it. " +
		"To delete the data for a specific chat, use the /unsetbirthday command in that chat. " +
		"Your data is also deleted when you leave a given chat. All data stored for a chat is deleted when the bot is removed from a group. " +
		"If you wish to delete your data for every chat, use the <code>/clear all data</code> command."
	MESSAGE_SOURCE                   = "The source code for the bot is available on <a href=\"https://github.com/4Kaze/birthdaybot\">GitHub</a> (・ω・)"
	MESSAGE_DATA_CLEARED             = "" /* 144-byte string literal not displayed */
	MESSAGE_WRONG_CLEAR_DATA_COMMAND = "Type <code>/clear all data</code> if you want to delete all your data stored by this bot."
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Birthday

type Birthday struct {
	Date          time.Time
	ChatId        int64
	UserId        int64
	Username      string
	UserFirstName string
	UserLastName  string
}

type BirthdayManager

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

func NewBirthdayManager

func NewBirthdayManager(repository Repository, telegram Telegram, botId int64) *BirthdayManager

func (*BirthdayManager) GetBirthdays

func (birthdayBot *BirthdayManager) GetBirthdays(ctx context.Context, date time.Time) ([]BirthdayPerson, error)

func (*BirthdayManager) HandleUpdate

func (birthdayBot *BirthdayManager) HandleUpdate(ctx context.Context, update *models.Update) error

type BirthdayPerson

type BirthdayPerson struct {
	ChatId int64
	UserId int64
	Name   string
}

type Repository

type Repository interface {
	SaveBirthday(ctx context.Context, birthday Birthday) error
	GetBirthdayDate(ctx context.Context, chatId int64, userId int64) (*time.Time, error)
	GetNextBirthdays(ctx context.Context, chatId int64) ([]Birthday, error)
	GetBirthdaysForDate(ctx context.Context, date time.Time) ([]Birthday, error)
	DeleteBirthday(ctx context.Context, chatId int64, userId int64) error
	DeleteAllChatBirthdays(ctx context.Context, chatId int64) error
	DeleteAllUserBirthdays(ctx context.Context, userId int64) error
}

type Telegram

type Telegram interface {
	SendMessage(ctx context.Context, chatId int64, text string) error
	SendReply(ctx context.Context, chatId int64, messageId int, text string) error
	SendReaction(ctx context.Context, chatId int64, messageId int, reaction string) error
}

Jump to

Keyboard shortcuts

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