BOT URL: https://t.me/MyLeetCodeDailybot
I've found it useful for me to see actual daily task in Telegram. Also want to have notificator about daily task =)
Currently status:
Since there is generous free tier and it's stable enough.
Expect following tables structure:
CREATE TABLE `dailyQuestion`
(
`id` Uint64,
`content` String,
`difficulty` Uint8,
`hints` String,
`questionId` Uint64,
`title` String,
`titleSlug` String,
PRIMARY KEY (`id`)
);
CREATE TABLE `users`
(
`id` Uint64,
`chat_id` Uint64,
`firstName` String,
`lastName` String,
`sendingHour` Uint8,
`subscribed` Bool,
`username` String,
PRIMARY KEY (`id`)
);
Awaits YDB_DATABASE
and YDB_ENDPOINT
environment variables.
If database connection will fail or variables will not set, bot will connect LeetCode API for question data.
- Can reply with today task.
- Can send task hints if they are set.
- Can send task difficulty.
- Subscribe/Unsubscribe user buttons/commands.
- Once per hour reminder serverless function send new task to all users who subscribed for this hour. Reminder require
SENDING_TOKEN
environment variable with Telegram API token. And it's all on the current stage.
Plan to add:
- Possibly get authorization token from subscriber, to show progress, may be show suggestions =).
Most likely it's a proof of concept. Only recieving of tasks if coded for now. Example:
package main
import (
"context"
"fmt"
"time"
"github.com/dartkron/leetcodeBot/v3/pkg/leetcodeclient"
)
func main() {
leetcodeClient := leetcodeclient.NewLeetCodeGraphQlClient()
loc, _ := time.LoadLocation("UTC")
now := time.Date(2021, time.September, 26, 0, 0, 0, 0, loc)
ctx, cancelFunc := context.WithTimeout(context.Background(), time.Second*time.Duration(5))
defer cancelFunc()
task, err := leetcodeClient.GetDailyTask(ctx, now)
if err != nil {
fmt.Println("Got error from LeetcodeClient", err)
}
fmt.Println(task)
}
Here you can see very basic example of continuous delivery to two Yandex.Cloud functions.
See .github/workflows/deploy.yml
for details.
Version 1.0 was made with Python, you can find it in versions history.