Documentation ¶
Index ¶
- Constants
- Variables
- func AppendSearchResults(list ssauparser.SearchResults, groups []database.Group, ...) ([]database.Group, []database.Teacher)
- func CancelKey() tgbotapi.InlineKeyboardMarkup
- func CheckEnv() error
- func CreateCondition(shedule database.ShedulesInUser) string
- func DayStr(day time.Time) string
- func GeneralKeyboard(options bool) tgbotapi.ReplyKeyboardMarkup
- func GenerateButtonTail(sheduleID int64, dt int, isGroup bool) string
- func GenerateGroupsArray(groups []database.Group, isAdd bool) []tgbotapi.InlineKeyboardButton
- func GenerateKeyboard(array []tgbotapi.InlineKeyboardButton) tgbotapi.InlineKeyboardMarkup
- func GenerateName(t database.Teacher) string
- func GeneratePath(sh database.ShedulesInUser, isPersonal bool, userID int64) string
- func GenerateTeachersArray(teachers []database.Teacher, isAdd bool) []tgbotapi.InlineKeyboardButton
- func GroupPairs(lessons []database.Lesson) [][]database.Lesson
- func InitUser(db *xorm.Engine, user *tgbotapi.User) (*database.TgUser, error)
- func KeywordContains(str string, keywords []string) bool
- func LessonHTML(bot *Bot, l []database.Lesson, isGroup bool) string
- func OptMarkup(options database.ShedulesInUser) tgbotapi.InlineKeyboardMarkup
- func PairToStr(pair []database.Lesson, db *xorm.Engine, isGroup bool) (string, error)
- func SummaryKeyboard(clickedButton SummaryType, shedule database.ShedulesInUser, isPersonal bool, ...) tgbotapi.InlineKeyboardMarkup
- func Swap(sh ssauparser.WeekShedule) database.ShedulesInUser
- type Bot
- func (bot *Bot) ActShedule(isPersonal bool, user *database.TgUser, shedule *database.ShedulesInUser) error
- func (bot *Bot) AdminHandle(msg *tgbotapi.Message) (tgbotapi.Message, error)
- func (bot *Bot) AutoGenKeyboard(user *database.TgUser) tgbotapi.ReplyKeyboardMarkup
- func (bot *Bot) Cancel(user *database.TgUser, query *tgbotapi.CallbackQuery) error
- func (bot *Bot) CheckBlocked(err error, user database.TgUser)
- func (bot *Bot) CheckWeek(now time.Time, week *int, shedule database.ShedulesInUser) (bool, error)
- func (bot *Bot) CreateHTMLShedule(isGroup bool, header string, shedule [][6][]database.Lesson, dates []time.Time, ...) string
- func (bot *Bot) CreateICS(now time.Time, user *database.TgUser, shedule database.ShedulesInUser, ...) error
- func (bot *Bot) CreateWeekImg(now time.Time, user *database.TgUser, shedule database.ShedulesInUser, ...) error
- func (bot *Bot) DeleteGroup(user *database.TgUser, text string) (tgbotapi.Message, error)
- func (bot *Bot) DeleteUser(user database.TgUser) error
- func (bot *Bot) EditOrSend(id int64, str string, imageID string, markup tgbotapi.InlineKeyboardMarkup, ...) (tgbotapi.Message, error)
- func (bot *Bot) Etc(user *database.TgUser) (tgbotapi.Message, error)
- func (bot *Bot) Find(now time.Time, user *database.TgUser, query string) (tgbotapi.Message, error)
- func (bot *Bot) GenerateICS(lessons []database.Lesson, shedule database.ShedulesInUser) (string, error)
- func (bot *Bot) GetDaySummary(now time.Time, user *database.TgUser, shedule database.ShedulesInUser, dt int, ...) (tgbotapi.Message, error)
- func (bot *Bot) GetLessons(shedule database.ShedulesInUser, now time.Time, limit int) ([]database.Lesson, error)
- func (bot *Bot) GetOptions(user *database.TgUser) (tgbotapi.Message, error)
- func (bot *Bot) GetPersonal(now time.Time, user *database.TgUser, editMsg ...tgbotapi.Message) (tgbotapi.Message, error)
- func (bot *Bot) GetShedule(user *database.TgUser, query *tgbotapi.CallbackQuery, now ...time.Time) error
- func (bot *Bot) GetShortSummary(now time.Time, user *database.TgUser, shedule database.ShedulesInUser, ...) (tgbotapi.Message, error)
- func (bot *Bot) GetUpdates()
- func (bot *Bot) GetWeekLessons(shedule database.ShedulesInUser, week int) ([]database.Lesson, error)
- func (bot *Bot) GetWeekSummary(now time.Time, user *database.TgUser, shedule database.ShedulesInUser, ...) error
- func (bot *Bot) HandleCallback(query *tgbotapi.CallbackQuery, now time.Time) (tgbotapi.Message, error)
- func (bot *Bot) HandleMessage(msg *tgbotapi.Message, now time.Time) (tgbotapi.Message, error)
- func (bot *Bot) HandleOptions(user *database.TgUser, query *tgbotapi.CallbackQuery) error
- func (bot *Bot) HandleSummary(user *database.TgUser, query *tgbotapi.CallbackQuery, now ...time.Time) error
- func (bot *Bot) HandleUpdate(update tgbotapi.Update, now ...time.Time) (tgbotapi.Message, error)
- func (bot *Bot) LoadShedule(shedule ssauparser.WeekShedule, now time.Time, fast bool) ([]database.Lesson, []database.Lesson, error)
- func (bot *Bot) ReturnSummary(notExists bool, isAdd bool, user *database.TgUser, ...) (tgbotapi.Message, error)
- func (bot *Bot) Scream(msg *tgbotapi.Message) (tgbotapi.Message, error)
- func (bot *Bot) SendMsg(user *database.TgUser, text string, markup interface{}) (tgbotapi.Message, error)
- func (bot *Bot) SetFirstTime(msg *tgbotapi.Message, user *database.TgUser) (tgbotapi.Message, error)
- func (bot *Bot) Start(user *database.TgUser) (tgbotapi.Message, error)
- func (bot *Bot) Stat() (tgbotapi.Message, error)
- func (bot *Bot) StrDayShedule(lessons [][]database.Lesson, isGroup bool) (string, error)
- type LessonStr
- type Line
- type SheduleData
- type SummaryType
- type WeekHead
Constants ¶
const ( SummaryPrefix string = "sh_" Near SummaryType = "near" Day SummaryType = "day" Week SummaryType = "week" ICS SummaryType = "ics" )
Variables ¶
var AdminKey = []string{"scream", "stat"}
var Comm = map[database.Kind]string{ database.Lection: "Лекция", database.Practice: "Практика", database.Lab: "Лаба", database.Other: "Прочее", database.Military: "", database.Window: "", database.Exam: "Экзамен", database.Consult: "Консультация", database.CourseWork: "Курсовая", }
var Icons = map[database.Kind]string{ database.Lection: "📗", database.Practice: "📕", database.Lab: "📘", database.Other: "📙", database.Military: "🫡", database.Window: "🏝", database.Exam: "💀", database.Consult: "🗨", database.CourseWork: "🤯", }
var Month = []string{
"января",
"февраля",
"марта",
"апреля",
"мая",
"июня",
"июля",
"августа",
"сентября",
"октября",
"ноября",
"декабря",
}
var SumKey = []string{"near", "day", "week"}
Functions ¶
func AppendSearchResults ¶
func AppendSearchResults( list ssauparser.SearchResults, groups []database.Group, teachers []database.Teacher, ) ( []database.Group, []database.Teacher, )
func CreateCondition ¶
func CreateCondition(shedule database.ShedulesInUser) string
Создать условие поиска группы/преподавателя
func GeneralKeyboard ¶
func GeneralKeyboard(options bool) tgbotapi.ReplyKeyboardMarkup
Основные кнопки действий: "Моё расписание" и "Настройки" (опционально)
func GenerateGroupsArray ¶
func GenerateGroupsArray(groups []database.Group, isAdd bool) []tgbotapi.InlineKeyboardButton
Создание ряда кнопок из списка групп
func GenerateKeyboard ¶
func GenerateKeyboard(array []tgbotapi.InlineKeyboardButton) tgbotapi.InlineKeyboardMarkup
Создание полноценной клавиатуры выбора
func GenerateName ¶
Создать имя преподавателя формата Фамилия И.О.
func GeneratePath ¶
func GeneratePath(sh database.ShedulesInUser, isPersonal bool, userID int64) string
func GenerateTeachersArray ¶
func GenerateTeachersArray(teachers []database.Teacher, isAdd bool) []tgbotapi.InlineKeyboardButton
Создание ряда кнопок из списка преподавателей
func GroupPairs ¶
Группировка занятий по парам
func KeywordContains ¶
Проверить строку на наличие одного из ключевых слов
func LessonHTML ¶
Вёрстка пары в HTML
func OptMarkup ¶
func OptMarkup(options database.ShedulesInUser) tgbotapi.InlineKeyboardMarkup
func SummaryKeyboard ¶
func SummaryKeyboard( clickedButton SummaryType, shedule database.ShedulesInUser, isPersonal bool, dt int, ) tgbotapi.InlineKeyboardMarkup
Inline-клавиатура карточки с расписанием
Types ¶
type Bot ¶
type Bot struct { TG *tgbotapi.BotAPI DB *xorm.Engine TestUser int64 HelpTxt string Week int WkPath string Debug *log.Logger Updates *tgbotapi.UpdatesChannel Messages int64 Callbacks int64 Build string }
func (*Bot) ActShedule ¶
func (bot *Bot) ActShedule(isPersonal bool, user *database.TgUser, shedule *database.ShedulesInUser) error
Актуализация запроса на расписание для персональных расписаний
func (*Bot) AdminHandle ¶
func (*Bot) AutoGenKeyboard ¶
func (bot *Bot) AutoGenKeyboard(user *database.TgUser) tgbotapi.ReplyKeyboardMarkup
Основные кнопки действий с автоопределением необходимости кнопки "Настройки"
func (*Bot) CheckWeek ¶
Проверка, не закончились ли пары на этой неделе
При week == -1 неделя определяется автоматически
func (*Bot) CreateHTMLShedule ¶
func (bot *Bot) CreateHTMLShedule( isGroup bool, header string, shedule [][6][]database.Lesson, dates []time.Time, times []ssauparser.Pair, ) string
TODO: подумать о своём поведении и сделать эти процессы покрасивее
func (*Bot) CreateICS ¶
func (bot *Bot) CreateICS( now time.Time, user *database.TgUser, shedule database.ShedulesInUser, isPersonal bool, week int, query ...tgbotapi.CallbackQuery, ) error
Создание и отправка .ics файла с расписанием указанной недели для приложений календаря
При week == -1 неделя определяется автоматически
func (*Bot) CreateWeekImg ¶
func (*Bot) DeleteGroup ¶
func (*Bot) EditOrSend ¶
func (bot *Bot) EditOrSend( id int64, str string, imageID string, markup tgbotapi.InlineKeyboardMarkup, editMsg ...tgbotapi.Message, ) ( tgbotapi.Message, error, )
Отправка сообщения или его редактирование, если в editMsg указано сообщение TODO: Обрабатывать старые сообщения, которые уже нельзя редактировать (message can't be deleted for everyone)
func (*Bot) GenerateICS ¶
func (bot *Bot) GenerateICS( lessons []database.Lesson, shedule database.ShedulesInUser, ) ( string, error, )
Создание непосредственно ICS файла
func (*Bot) GetDaySummary ¶
func (bot *Bot) GetDaySummary( now time.Time, user *database.TgUser, shedule database.ShedulesInUser, dt int, isPersonal bool, editMsg ...tgbotapi.Message, ) ( tgbotapi.Message, error, )
Получить расписание на день
Если isPersonal == false, то обязательно заполнение объекта shedule
При isPersonal == true, объект shedule игнорируется
func (*Bot) GetLessons ¶
func (bot *Bot) GetLessons(shedule database.ShedulesInUser, now time.Time, limit int) ([]database.Lesson, error)
Получить список ближайших занятий (для краткой сводки или расписания на день)
func (*Bot) GetOptions ¶
func (*Bot) GetPersonal ¶
func (*Bot) GetShedule ¶
func (bot *Bot) GetShedule(user *database.TgUser, query *tgbotapi.CallbackQuery, now ...time.Time) error
Получить расписание из кнопки
func (*Bot) GetShortSummary ¶
func (bot *Bot) GetShortSummary( now time.Time, user *database.TgUser, shedule database.ShedulesInUser, isPersonal bool, editMsg ...tgbotapi.Message, ) ( tgbotapi.Message, error, )
Получить краткую сводку
Если isPersonal == false, то обязательно заполнение объекта shedule
При isPersonal == true, объект shedule игнорируется
func (*Bot) GetUpdates ¶
func (bot *Bot) GetUpdates()
func (*Bot) GetWeekLessons ¶
func (*Bot) GetWeekSummary ¶
func (bot *Bot) GetWeekSummary( now time.Time, user *database.TgUser, shedule database.ShedulesInUser, week int, isPersonal bool, caption string, editMsg ...tgbotapi.Message, ) error
Получить расписание на неделю При week == -1 неделя определяется автоматически
Если isPersonal == false, то обязательно заполнение объекта shedule
При isPersonal == true, объект shedule игнорируется
func (*Bot) HandleCallback ¶
func (*Bot) HandleMessage ¶
func (*Bot) HandleOptions ¶
func (*Bot) HandleSummary ¶
func (*Bot) HandleUpdate ¶
func (*Bot) LoadShedule ¶
func (bot *Bot) LoadShedule(shedule ssauparser.WeekShedule, now time.Time, fast bool) ( []database.Lesson, []database.Lesson, error, )
Загрузка расписания из ssau.ru/rasp
func (*Bot) ReturnSummary ¶
func (*Bot) SetFirstTime ¶
type SheduleData ¶
type SummaryType ¶
type SummaryType string
func ParseQuery ¶
func ParseQuery(data []string) (SummaryType, database.ShedulesInUser, int, error)
Расшифровывать содержимое кнопки из карточки с расписанием