Skip to content

Commit

Permalink
feat: register reminder on main program
Browse files Browse the repository at this point in the history
  • Loading branch information
aldy505 committed Dec 26, 2023
1 parent c3850c9 commit b458b86
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
20 changes: 15 additions & 5 deletions cmd/captcha/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,17 @@ import (
"strings"
"time"

"github.com/teknologi-umum/captcha/analytics"
"github.com/teknologi-umum/captcha/analytics/server"
"github.com/teknologi-umum/captcha/ascii"
"github.com/teknologi-umum/captcha/badwords"
"github.com/teknologi-umum/captcha/captcha"
"github.com/teknologi-umum/captcha/reminder"
"github.com/teknologi-umum/captcha/setir"
"github.com/teknologi-umum/captcha/shared"
"github.com/teknologi-umum/captcha/underattack"
"github.com/teknologi-umum/captcha/underattack/datastore"

// Internals
"github.com/teknologi-umum/captcha/analytics"
"github.com/teknologi-umum/captcha/analytics/server"
"github.com/teknologi-umum/captcha/shared"

// Database and cache
"github.com/allegro/bigcache/v3"
"github.com/jmoiron/sqlx"
Expand Down Expand Up @@ -281,6 +280,16 @@ func main() {
return
}

var reminderDependency *reminder.Dependency
if configuration.FeatureFlag.Reminder {
reminderDependency, err = reminder.New(cache)
if err != nil {
sentry.CaptureException(err)
log.Fatal(err)
return
}
}

program, err := New(Dependency{
FeatureFlag: configuration.FeatureFlag,
Captcha: &captcha.Dependencies{
Expand All @@ -293,6 +302,7 @@ func main() {
Badwords: badwordsDependency,
UnderAttack: underAttackDependency,
Setir: setirDependency,
Reminder: reminderDependency,
})
if err != nil {
sentry.CaptureException(err)
Expand Down
4 changes: 2 additions & 2 deletions reminder/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (d *Dependency) Handler(ctx context.Context, c tb.Context) error {
input := strings.TrimPrefix(c.Text(), "/remind")
if input == "" {
err := c.Reply(
"To use /reminder properly, you should add with the remaining text including the normal human grammatical that I can understand.\n\n"+
"To use /remind properly, you should add with the remaining text including the normal human grammatical that I can understand.\n\n"+
"For English, see this <a href=\"https://www.grammarly.com/blog/sentence-structure/\">Grammarly article about sentence structure</a>.\n"+
"Untuk Indonesia, pakai SPO + Keterangan Waktu yang baik dan benar, <a href=\"https://tambahpinter.com/bentuk-kalimat-spok/\">belajar lagi biar tambah pinter</a>.",
&tb.SendOptions{ParseMode: tb.ModeHTML, AllowWithoutReply: true},
Expand Down Expand Up @@ -110,7 +110,7 @@ func (d *Dependency) Handler(ctx context.Context, c tb.Context) error {

if reminder.Time.IsZero() || len(reminder.Subject) == 0 || reminder.Object == "" {
err := c.Reply(
"Sorry, I'm unable to parse the reminder text that you just sent. Send /reminder and see the guide for this command.",
"Sorry, I'm unable to parse the reminder text that you just sent. Send /remind and see the guide for this command.",
&tb.SendOptions{ParseMode: tb.ModeHTML, AllowWithoutReply: true},
)
if err != nil {
Expand Down

0 comments on commit b458b86

Please sign in to comment.