diff --git a/go.mod b/go.mod index 9862fe7..963e0b9 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.21.5 require ( github.com/gotd/td v0.91.0 github.com/joho/godotenv v1.5.1 + github.com/lib/pq v1.10.9 github.com/redis/go-redis/v9 v9.3.1 gopkg.in/telebot.v3 v3.2.1 ) diff --git a/kreacher/client.go b/kreacher/client.go index 1cd8af5..4c47310 100755 --- a/kreacher/client.go +++ b/kreacher/client.go @@ -1,4 +1,4 @@ -package kreacher +package main import ( "log" diff --git a/kreacher/config.go b/kreacher/config.go index 4e38839..e1e0266 100755 --- a/kreacher/config.go +++ b/kreacher/config.go @@ -1,4 +1,4 @@ -package kreacher +package main import ( "fmt" diff --git a/kreacher/logger.go b/kreacher/logger.go index 7ba6620..6cf0c16 100644 --- a/kreacher/logger.go +++ b/kreacher/logger.go @@ -1,20 +1,23 @@ -package kreacher +package main import ( + "io" "log" "os" ) func NewLogger(name string, path string) (*log.Logger, error) { - var logger *log.Logger - file, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644) + file, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) if err != nil { return nil, err } defer file.Close() - logger.SetOutput(file) + logFile := io.MultiWriter(os.Stdout, file) + + logger := log.New(logFile, name+" ", log.Ldate|log.Ltime|log.Lshortfile) + logger.SetOutput(logFile) logger.SetFlags(0) return logger, nil diff --git a/kreacher/main.go b/kreacher/main.go index 75e03e7..acf9cf4 100755 --- a/kreacher/main.go +++ b/kreacher/main.go @@ -1,10 +1,12 @@ -package kreacher +package main import ( + "database/sql" "fmt" "time" td "github.com/gotd/td/telegram" + _ "github.com/lib/pq" redis "github.com/redis/go-redis/v9" tele "gopkg.in/telebot.v3" ) @@ -16,6 +18,14 @@ func main() { panic(err) } + postgresDB, err := sql.Open("postgres", "user=username password=password dbname=database sslmode=disable") + + if err != nil { + panic(err) + } + + defer postgresDB.Close() + redisDB := redis.NewClient(&redis.Options{ Addr: fmt.Sprintf("%s:%d", NewConfig().RedisHost, NewConfig().RedisPort), Password: NewConfig().RedisPassword, diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100755 index e27db8f..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,4 +0,0 @@ -black==23.7.0 -black[jupyter] -poetry==1.6.1 -pylint==2.17.5 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100755 index 311fb06..0000000 --- a/requirements.txt +++ /dev/null @@ -1,20 +0,0 @@ -EbookLib==0.18 -pillow==10.0.0 -piper-tts==1.2.0 -psycopg2_binary==2.9.9 -pyrogram==2.0.106 -pytgcalls==3.0.0.dev24 -python-dotenv==1.0.0 -PyPDF2==3.0.1 -redis==5.0.1 -requests==2.31.0 -selenium==4.11.2 -shutup==0.2.0 -speedtest-cli==2.1.3 -SQLAlchemy==2.0.21 -termcolor==1.1 -tgcalls==3.0.0.dev6 -tgcrypto==1.2.5 -translate==3.6.1 -youtube-search-python==1.6.6 -yt-dlp==2023.7.6 \ No newline at end of file diff --git a/runtime.txt b/runtime.txt index dfe813b..d8eb540 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.11.6 \ No newline at end of file +golang-1.21.5 \ No newline at end of file