Documentation ¶
Index ¶
- Constants
- Variables
- func DownloadGCSFile(url string) (string, error)
- func FluctuationPostTime(t time.Time) time.Time
- func GetAccounts(ctx context.Context, store *firestore.Client) ([]models.Account, error)
- func GetGroups(ctx context.Context, store *firestore.Client, account models.Account) ([]models.Group, error)
- func GetInfoForAccount(ctx context.Context, store *firestore.Client, account models.Account) (*models.Rule, []models.Schedule, error)
- func GetPost(ctx context.Context, store *firestore.Client, postId string) (*models.Post, error)
- func GetPosts(ctx context.Context, store *firestore.Client, account models.Account) ([]models.Post, error)
- func GetPostsIsSchedule(ctx context.Context, store *firestore.Client, account models.Account, ...) ([]models.Post, error)
- func GetRule(ctx context.Context, store *firestore.Client, accountId string) (*models.Rule, error)
- func IsBlue(s string) bool
- func IsLastCheck(post models.Post) bool
- func IsPosting(termhours int, post models.Post) bool
- func IsTime(now time.Time, timings []string) bool
- func NewError(fn string, err any) error
- func NewGotwiClient(accesstoken, accesssecret string) (*gotwi.Client, error)
- func SelectPosts() (int, error)
- func TimeToKey(t time.Time) string
- func UploadImage(api *anaconda.TwitterApi, filename string) (string, error)
- func UploadMedias(accessToken, accessSecret string, filenames ...string) ([]string, error)
- func UploadVideo(api *anaconda.TwitterApi, filename string) (string, error)
- type Client
- type Post
- type Selector
- type TaskForSchedule
- func (task *TaskForSchedule) DoForRule() error
- func (task *TaskForSchedule) DoForSchedule(t time.Time) error
- func (task *TaskForSchedule) Done(post *models.Post) error
- func (task *TaskForSchedule) Post(post *models.Post) error
- func (task *TaskForSchedule) Update(ctx context.Context, store *firestore.Client, post *models.Post) error
Constants ¶
const ( ISTEST = false ISSAVETODATABASE = true ISHEADLESSMODE = true )
const LIMITXPOSTCHAR = 141
Variables ¶
var (
PASSWORDCONTROLLER []byte
)
var ( // TOMORROW 起動時の次の日 // why: 起動時明日の予約投稿を取得する TOMORROW = time.Now().AddDate(0, 0, 1) )
Functions ¶
func DownloadGCSFile ¶
DownloadGCSFile はGCS URLからファイルをダウンロードし、一時ファイルを作成してパスを返す
func FluctuationPostTime ¶
FluctuationPostTime 投稿時間の変更 設定投稿時間に分単位の前後ゆらぎを持たせる Ruleが即時投稿の場合は、即時投稿
func GetAccounts ¶
GetAccounts 購読設定なしを除いたアカウント情報を取得
func GetInfoForAccount ¶
func GetInfoForAccount(ctx context.Context, store *firestore.Client, account models.Account) (*models.Rule, []models.Schedule, error)
GetInfoForAccount 購読設定なしを除いたアカウント情報(Rule, Schedules)を取得 Scheduleは起動日の次の日予定された投稿を取得(owner_id) 日時指定取得は行わない
func GetPost ¶
GetPost 投稿情報を取得 本日の予定された投稿を取得 if checked, is_deleted, post_id is not match, return error
func GetPostsIsSchedule ¶
func GetPostsIsSchedule(ctx context.Context, store *firestore.Client, account models.Account, rule models.Rule) ([]models.Post, error)
GetPostsIsSchedule 投稿情報を取得
func IsLastCheck ¶
func SelectPosts ¶
SelectPosts 明日の投稿を選別し、Tasksに登録 Taskはユーザーごとに登録される、そのユーザーの当日の予約投稿を登録 Taskには当日の予約投稿のPostIDsを登録、当日の予約投稿のタイミングを登録し、当日PostIDによってデータベース参照、Postを実行
func UploadImage ¶
func UploadImage(api *anaconda.TwitterApi, filename string) (string, error)
func UploadMedias ¶
func UploadVideo ¶
func UploadVideo(api *anaconda.TwitterApi, filename string) (string, error)
Types ¶
type Client ¶
type Client struct { Firestore *models.ClientForFirestore PasswordController []byte }
type Selector ¶
type Selector struct { Account models.Account Rule models.Rule // アカウントが保持する情報を全部取得 Schedules []models.Schedule Group []models.Group Posts []models.Post }
Selector 本日の投稿を選別するための構造体 まずは全ての情報を取得する
func GetSelectors ¶
# database - GetSelectors: アカウントと付帯情報を取得 - GetAccounts: アカウント情報を取得 - GetInfoForAccount: アカウント情報(Rule, Schedules)を取得 - GetPostsIsSchedule: 投稿情報を取得 - GetPosts: 投稿情報を取得 - GetGroups: グループ情報を取得 - GetPost: 投稿情報を取得
func (*Selector) ToTask ¶
func (s *Selector) ToTask() (*TaskForSchedule, error)
ToTask 明日の予約投稿の準備を行う Selectorには、ユーザーごとの情報が格納されている TODO: Rule指定の当日ランダム投稿はどうするか 指定ルール、指定スケジュール、指定投稿を選別し、TaskForScheduleに格納
type TaskForSchedule ¶
type TaskForSchedule struct { IsSchedule bool `firestore:"is_schedule,omitempty" json:"is_schedule,omitempty"` Account models.Account `firestore:"account,omitempty" json:"account,omitempty"` Rule models.Rule `firestore:"rule,omitempty" json:"rule,omitempty"` // 当日予定された投稿 Schedules []models.Schedule `firestore:"schedules,omitempty" json:"schedules,omitempty"` Group []models.Group `firestore:"group,omitempty" json:"group,omitempty"` Posts []models.Post `firestore:"posts,omitempty" json:"posts,omitempty"` TimingForSchedules []string `firestore:"timing_for_schedules,omitempty" json:"timing_for_schedules,omitempty"` TimingForRules []string `firestore:"timing_for_rules,omitempty" json:"timing_for_rules,omitempty"` TimingForSearch []string `firestore:"timing_for_search,omitempty" json:"timing_for_search,omitempty"` }
firestore collection, document nameをどう定義するか 当データをどう定義するか、どのようなデータを取得するか 希望としては、ユーザーごとの処理を記述し、 そのユーザーのスケジュール、ルール、投稿を取得する ユーザが与薬した投稿があるかどうかに絞る Keyはユーザー名とする 投稿時は、当コレクションを取得すれば、全ユーザーの情報が手に入る where: account.id == account.id, in_array(timing_for_schedules, timing_for_rules)
func (*TaskForSchedule) DoForRule ¶
func (task *TaskForSchedule) DoForRule() error
DoForRule Ruleの投稿処理 当該時刻の投稿は1つのみ IsSchedule == falseの投稿のみ抽出し、その中から一つ選択する
func (*TaskForSchedule) DoForSchedule ¶
func (task *TaskForSchedule) DoForSchedule(t time.Time) error
DoForSchedule 予約投稿の処理 複数個ある場合を含むSchedulesに対する投稿を行う
func (*TaskForSchedule) Done ¶
func (task *TaskForSchedule) Done(post *models.Post) error
Done 投稿完了後の処理 投稿完了後、taskのPostを除外し、task及びpost.Count/LastPostedAtを更新する