Compare commits

..

3 Commits

Author SHA1 Message Date
Jeff Carr 00d9cbf64f setup rwhois (?) 2025-09-16 09:32:21 -05:00
Jeff Carr 3e8e5fba8f a telegram example 2025-08-16 18:59:08 -05:00
Jeff Carr f5a8c9b672 dumb files that don't build 2025-05-23 03:28:13 -05:00
6 changed files with 132 additions and 0 deletions

24
git-bug-proto/Makefile Normal file
View File

@ -0,0 +1,24 @@
VERSION = $(shell git describe --tags)
GUIVERSION = $(shell git describe --tags)
BUILDTIME = $(shell date +%s)
all: vet build
build: goimports
GO111MODULE=off go build \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
vet:
GO111MODULE=off go vet
goimports:
goimports -w *.go
# // to globally reset paths:
# // gofmt -w -r '"go.wit.com/gui/gadgets" -> "go.wit.com/lib/gadgets"' *.go
install: goimports
GO111MODULE=off go install \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
force: build
./go-clone-test --force

12
git-bug-proto/main.go Normal file
View File

@ -0,0 +1,12 @@
//go:generate go run doc/generate.go
//go:generate go run misc/completion/generate.go
package main
import (
"github.com/git-bug/git-bug/commands"
)
func main() {
commands.Execute()
}

53
rwhois/main.go Normal file
View File

@ -0,0 +1,53 @@
package main
import (
"bufio"
"fmt"
"log"
"net"
"strings"
)
const RWhoisPort = "4321"
func handleConnection(conn net.Conn) {
defer conn.Close()
reader := bufio.NewReader(conn)
query, err := reader.ReadString('\n')
if err != nil {
log.Printf("Error reading query: %v", err)
return
}
query = strings.TrimSpace(query)
log.Printf("Received query: %s", query)
// In a real RWhois server, you would parse the query,
// look up data, and potentially issue referrals.
// For this example, we'll send a simple response.
response := fmt.Sprintf("RWhois response for: %s\n", query)
_, err = conn.Write([]byte(response))
if err != nil {
log.Printf("Error writing response: %v", err)
return
}
}
func main() {
listener, err := net.Listen("tcp", ":"+RWhoisPort)
if err != nil {
log.Fatalf("Error listening: %v", err)
}
defer listener.Close()
log.Printf("RWhois server listening on port %s", RWhoisPort)
for {
conn, err := listener.Accept()
if err != nil {
log.Printf("Error accepting connection: %v", err)
continue
}
go handleConnection(conn)
}
}

1
telegram/.env Normal file
View File

@ -0,0 +1 @@
TOKEN=5292519055:AAGJPrxYs70PoIWEvLcS3oV3XZ2ldko-M4k

5
telegram/Makefile Normal file
View File

@ -0,0 +1,5 @@
run:
go run -v -x send_after.go
test:
curl https://api.telegram.org/bot5292519055:AAGJPrxYs70PoIWEvLcS3oV3XZ2ldko-M4k/getMe

37
telegram/send_after.go Normal file
View File

@ -0,0 +1,37 @@
package main
import (
"time"
"fmt"
. "github.com/enetx/g"
"github.com/enetx/tg/bot"
"github.com/enetx/tg/ctx"
)
func main() {
fmt.Println("started...")
// Read the bot token from the .env file
token := NewFile(".env").Read().Ok().Trim().Split("=").Collect().Last().Some()
b := bot.New(token).Build().Unwrap()
// Register a command handler for /start
b.Command("start", func(ctx *ctx.Context) error {
// Send an immediate message so Telegram considers the update as "handled"
ctx.SendMessage("Preparing self-destruct...").Send()
// Schedule a second message to be sent after 3 seconds,
// and automatically delete it 5 seconds after it is sent
ctx.SendMessage("This message will self-destruct in 5 seconds.").
After(3 * time.Second). // Delay sending by 3 seconds
DeleteAfter(5 * time.Second). // Delete 5 seconds after it is sent
Send()
// Delete the original /start message (from the user)
// This should be done after responding to avoid Telegram resending the update
return ctx.DeleteMessage().Send().Err()
})
// Start polling for updates and drop any pending ones from before startup
b.Polling().DropPendingUpdates().Start()
}