diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..5bda83f --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,33 @@ +name: Lint + +on: + push: + workflow_dispatch: + +jobs: + Lint: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Install GO + uses: actions/setup-go@v3 + with: + go-version: 1.21 + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + args: --timeout 3m --verbose + + - name: staticcheck + uses: dominikh/staticcheck-action@v1.3.0 + with: + version: "2022.1.3" + + - name: gofmt + uses: Jerome1337/gofmt-action@v1.0.5 + with: + gofmt-flags: "-l -d" + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..487a864 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM golang:1.21-alpine as builder + +WORKDIR /src + +COPY . . + +RUN go mod tidy + +RUN go build -o statusbot main.go + + +FROM alpine + +WORKDIR /app + +COPY --from=builder /src/statusbot . + +CMD ./statusbot -t ${STATUSBOT_TOKEN} + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0c9fb47 --- /dev/null +++ b/Makefile @@ -0,0 +1,39 @@ +GOPATH := $(shell go env GOPATH) + +getverifiers: + @echo "Installing staticcheck" && go get -u honnef.co/go/tools/cmd/staticcheck && go install honnef.co/go/tools/cmd/staticcheck + @echo "Installing gocyclo" && go get -u github.com/fzipp/gocyclo/cmd/gocyclo && go install github.com/fzipp/gocyclo/cmd/gocyclo + @echo "Installing deadcode" && go get -u github.com/remyoudompheng/go-misc/deadcode && go install github.com/remyoudompheng/go-misc/deadcode + @echo "Installing misspell" && go get -u github.com/client9/misspell/cmd/misspell && go install github.com/client9/misspell/cmd/misspell + @echo "Installing golangci-lint" && go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2 + go mod tidy + +verifiers: fmt lint cyclo deadcode spelling staticcheck + +fmt: + @echo "Running $@" + @gofmt -d . + +lint: + @echo "Running $@" + @${GOPATH}/bin/golangci-lint run + +cyclo: + @echo "Running $@" + @${GOPATH}/bin/gocyclo -over 100 . + +deadcode: + @echo "Running $@" + @${GOPATH}/bin/deadcode -test $(shell go list ./...) || true + +spelling: + @echo "Running $@" + @${GOPATH}/bin/misspell -i monitord -error `find .` + +staticcheck: + @echo "Running $@" + @${GOPATH}/bin/staticcheck -- ./... + +build: + @echo "Running $@" + @go build -o statusbot main.go diff --git a/README.md b/README.md index 6704907..361adb8 100644 --- a/README.md +++ b/README.md @@ -1 +1,60 @@ -# statusbot \ No newline at end of file +# Statusbot + +## Overview + +The Status Bot is a tool designed to send a reminder at 5 O'clock + +## Getting Started + +### Prerequisites + +Ensure that you have installed: + +- Go programming language (version 1.21 or higher if not using docker) +- Git + +### How to start + +1. Clone this repository to your local machine: + + ```bash + git clone https://github.com/codescalers/statusbot + cd statusbot + ``` + +2. Setup your telegram bot and your env + +- Create a new [telegram bot](README.md#create-a-bot) if you don't have. + +3. Run the bot: + +- Using go + + ```bash + go run main.go -t + ``` + +- Using Docker + + ```bash + docker build -t statusbot . + docker run -e -it statusbot + ``` + +## Create a bot + +- Open telegram app +- Create a new bot + + ```ordered + 1. Find telegram bot named "@botfarther" + 2. Type /newbot + ``` + +- Get the bot token + + ```ordered + 1. In the same bot named "@botfarther" + 2. Type /token + 3. Choose your bot + ``` diff --git a/go.mod b/go.mod index a04e0ab..2b598aa 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/codescalers/statusbot -go 1.21.3 +go 1.21 require ( github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 diff --git a/main.go b/main.go index 1d47ffc..35b8f2c 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,3 @@ -/* -Copyright © 2023 NAME HERE - -*/ package main import "github.com/codescalers/statusbot/cmd"