Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
malvere committed Sep 15, 2024
0 parents commit 76498b1
Show file tree
Hide file tree
Showing 26 changed files with 1,153 additions and 0 deletions.
Binary file added .github/0.webp
Binary file not shown.
Binary file added .github/1.webp
Binary file not shown.
Binary file added .github/2.webp
Binary file not shown.
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
build/
__*
.env
vids*
.vscode/settings.json
test.sql
*.json
*.txt

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Application name
APP_NAME = blumfield

# Directories and Files
BUILD_DIR = ./build

# Default target
.DEFAULT_GOAL := build

# Commands
.PHONY: build test db prod run clean sqlc

# Build the Go project
build:
go build -v -o $(BUILD_DIR)/$(APP_NAME) ./main.go

# Run tests
test:
go test -v -race -timeout 30s ./...

# Production build for different platforms
prod:
@if [ "$(filter windows,$(MAKECMDGOALS))" != "" ]; then \
GOOS=windows GOARCH=amd64 go build -o $(BUILD_DIR)/$(APP_NAME)-win-x86.exe -v ./main.go; \
elif [ "$(filter macos,$(MAKECMDGOALS))" != "" ]; then \
GOOS=darwin GOARCH=amd64 go build -o $(BUILD_DIR)/$(APP_NAME)-darwin-amd64 -v ./main.go; \
else \
GOOS=linux GOARCH=amd64 go build -o $(BUILD_DIR)/$(APP_NAME)-linux-amd64 -v ./main.go; \
fi

# Run the app
run:
go run ./main.go

# Clean build artifacts
clean:
rm -f $(BUILD_DIR)/$(APP_NAME)*
91 changes: 91 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<p align="center">
<img src=".github/1.webp" alt="Blum Automation Screenshot" width="300"/>
</p>

# Blum Automation Software

This software automates various activities in the Blum app, including tasks, gaming, and daily claims. The app interacts with the Blum platform and performs these actions automatically based on the configuration you set.

## Features

- **Task Automation**: Automatically complete daily tasks on Blum.
- **Gaming Automation**: Play games and claim rewards based on available play passes.
- **Daily Claims**: Automatically claim daily check-in rewards and farming rewards.

## Setup

### Prerequisites

- Go (version 1.18+)
- Telegram's Blum WebApp must be run with web inspection enabled.

### Installation

1. Clone the repository:
```bash
git clone https://github.com/malvere/Blumfield.git
cd Blumfield
```

2. Install Go dependencies:
```bash
go mod download
```

3. Configure your settings:
The configuration file `config.yaml` must be filled with your WebApp Init data and settings for automation. The init data is retrieved by running Blum in the Telegram web app with web inspection enabled.

### Obtaining WebApp Init Data

1. Open the Blum app in your **Telegram Web** app.
2. Enable web inspection (right-click the page and select **Inspect** or press `F12`).
3. In the console tab of the inspector, type:
```javascript
copy(Telegram.WebApp.initData)
```
4. Paste the copied output into the `configs/config.yaml` file under the `auth` section:
```yaml
auth:
WebAppInit: "your_copied_webapp_init_data"
```
### Configuration
In the `config.yaml` file, you can set various parameters for the automation process:

```yaml
auth:
WebAppInit: "your_copied_webapp_init_data"
tokenFile: "tokens.json"
folder: "config"
settings:
delay: 100 # Delay between tasks (in seconds)
tasks: true # Enable or disable task automation
farming: true # Enable or disable farming claims
gaming: true # Enable or disable gaming automation
```

### Running the Software

Once the configuration is set, you can run the software using:

```bash
./build/blumfield
```

### Logging

The software logs activity to the console and provides details on the actions being taken, such as claiming rewards, completing tasks, and farming.

## License

This project is licensed under the MIT License. See the `LICENSE` file for details.

## Contributions

Feel free to submit issues or pull requests if you have ideas for improvements!

---

This `README.md` provides all necessary setup instructions, including how to obtain and configure the `WebAppInit` data and run the project. You can modify it based on any additional project details.
82 changes: 82 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package config

import (
"encoding/json"
"errors"
"os"
"path/filepath"

"github.com/spf13/viper"
)

type Config struct {
Auth struct {
WebAppInit string `yaml:"WebAppInit"`
TokenFile string `yaml:"tokenFile"`
Folder string `yaml:"folder"`
} `yaml:"auth"`

Settings struct {
Delay int `yaml:"delay"`
Tasks int `yaml:"tasks"`
Farming bool `yaml:"farming"`
Gaming bool `yaml:"gaming"`
} `yaml:"settings"`
}

type Tokens struct {
Auth string `json:"auth"`
Refresh string `json:"refresh"`
}

func LoadConfig() (*Config, error) {
var cfg Config
viper.AddConfigPath(filepath.Join("config"))
viper.SetConfigName("config")
viper.SetConfigType("yaml")

if err := viper.ReadInConfig(); err != nil {
return nil, err
}

if err := viper.Unmarshal(&cfg); err != nil {
return nil, err
}

return &cfg, nil
}

func (c *Config) LoadTokens() (*Tokens, error) {
tokens := Tokens{}

tokenPath := filepath.Join(c.Auth.Folder, c.Auth.TokenFile)
if _, err := os.Stat(tokenPath); os.IsNotExist(err) {
return &tokens, errors.New("tokens.json does not exist")
}

file, err := os.ReadFile(tokenPath)
if err != nil {
return nil, err
}

if err := json.Unmarshal(file, &tokens); err != nil {
return nil, errors.New("failed unmarshalling tokens.json")
}

return &tokens, nil
}

func (c *Config) SaveTokens(tokens *Tokens) error {
tokensJson, err := json.Marshal(&tokens)
if err != nil {
return err
}

tokenPath := filepath.Join(c.Auth.Folder, c.Auth.TokenFile)

if err := os.WriteFile(tokenPath, tokensJson, 0644); err != nil {
return err
}

return nil
}
10 changes: 10 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
auth:
WebAppInit: ""
tokenFile: "tokens.json"
folder: "config"

settings:
delay: 3
tasks: true
farming: true
gaming: true
43 changes: 43 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module blumfield

go 1.23.1

require (
github.com/go-faker/faker/v4 v4.5.0
github.com/sirupsen/logrus v1.9.3
)

require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-resty/resty/v2 v2.14.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/httprc v1.0.6 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/jwx/v2 v2.1.1 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.19.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.18.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 76498b1

Please sign in to comment.