Skip to content

Commit

Permalink
first step migrating to golang
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Dec 19, 2023
1 parent 45c86aa commit 7400db1
Show file tree
Hide file tree
Showing 43 changed files with 94 additions and 155 deletions.
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
*.env
*.log
*.rdb
*.pyc
*.sum
*.lock
*.session
*.session-journal

.codesandbox
.devcontainer



.devcontainer
.devcontainer
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"recommendations": [
"golang.go"
"golang.go",
"ms-azuretools.vscode-docker"
]
}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM python:3.11.6
FROM golang:1.21.5
RUN apt-get update && apt-get upgrade -y
RUN apt-get install ffmpeg tree -y
RUN pip install --upgrade pip
RUN go mod tidy
COPY . /kreacher/
WORKDIR /kreacher/
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
Expand Down
115 changes: 0 additions & 115 deletions bot/__init__.py

This file was deleted.

31 changes: 0 additions & 31 deletions bot/config.py

This file was deleted.

11 changes: 11 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/SantiiRepair/kreacher-bot

go 1.21.5

require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/redis/go-redis/v9 v9.3.1 // indirect
gopkg.in/telebot.v3 v3.2.1 // indirect
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions kreacher/clients.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package kreacher

import (
"time"

"github.com/redis/go-redis/v9"
tele "gopkg.in/telebot.v3"
)

var rdb = redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "", // no password set
DB: 0, // use default DB
Protocol: 3, // specify 2 for RESP 2 or 3 for RESP 3
})

var kbot, _ = tele.NewBot(tele.Settings{
Token: NewConfig().BotToken,
Poller: &tele.LongPoller{Timeout: 10 * time.Second},
})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
57 changes: 57 additions & 0 deletions kreacher/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package kreacher

import (
"fmt"
"os"

"github.com/joho/godotenv"
)

type Config struct {
APIID string
APIHash string
BotToken string
BotUsername string
Channel string
ESMoviesChannel string
ESSeriesChannel string
ManagementMode string
Maintainer string
SessionString string
PostgresDB string
PostgresUser string
PostgresPassword string
PostgresHost string
PostgresPort string
RedisHost string
RedisPassword string
RedisPort string
}

func NewConfig() *Config {
err := godotenv.Load("../.env")
if err != nil {
fmt.Println("No .env file found")
}

return &Config{
APIID: os.Getenv("API_ID"),
APIHash: os.Getenv("API_HASH"),
BotToken: os.Getenv("BOT_TOKEN"),
BotUsername: os.Getenv("BOT_USERNAME"),
Channel: os.Getenv("CHANNEL"),
ESMoviesChannel: os.Getenv("ES_MOVIES_CHANNEL"),
ESSeriesChannel: os.Getenv("ES_SERIES_CHANNEL"),
ManagementMode: os.Getenv("MANAGEMENT_MODE"),
Maintainer: os.Getenv("MANTAINER"),
SessionString: os.Getenv("SESSION_STRING"),
PostgresDB: os.Getenv("POSTGRES_DB"),
PostgresUser: os.Getenv("POSTGRES_USER"),
PostgresPassword: os.Getenv("POSTGRES_PASSWORD"),
PostgresHost: os.Getenv("POSTGRES_HOST"),
PostgresPort: os.Getenv("POSTGRES_PORT"),
RedisHost: os.Getenv("REDIS_HOST"),
RedisPassword: os.Getenv("REDIS_PASSWORD"),
RedisPort: os.Getenv("REDIS_PORT"),
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 7400db1

Please sign in to comment.