Compare commits
No commits in common. "master" and "v0.0.49" have entirely different histories.
|
@ -1,12 +0,0 @@
|
||||||
testgo: goimports
|
|
||||||
# GO111MODULE=off go run aistudio.go
|
|
||||||
go run -v aistudio.go
|
|
||||||
|
|
||||||
real:
|
|
||||||
GO111MODULE=off go run aistudio.go
|
|
||||||
|
|
||||||
vet:
|
|
||||||
GO111MODULE=off go vet
|
|
||||||
|
|
||||||
goimports:
|
|
||||||
goimports -w *.go
|
|
|
@ -1,54 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
// "github.com/google/generative-ai-go/genai"
|
|
||||||
"cloud.google.com/go/ai/vertexai/genai"
|
|
||||||
"google.golang.org/api/option"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
ctx := context.Background()
|
|
||||||
|
|
||||||
apiKey := os.Getenv("GEMINI_API_KEY")
|
|
||||||
if apiKey == "" {
|
|
||||||
log.Fatal("GEMINI_API_KEY environment variable not set")
|
|
||||||
}
|
|
||||||
|
|
||||||
client, err := genai.NewClient(ctx, option.WithAPIKey(apiKey))
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Failed to create genai client: %v", err)
|
|
||||||
}
|
|
||||||
defer client.Close()
|
|
||||||
|
|
||||||
model := client.GenerativeModel("gemini-2.5-pro-preview-03-25")
|
|
||||||
|
|
||||||
// Set system instruction
|
|
||||||
model.SystemInstruction = &genai.Content{
|
|
||||||
Parts: []genai.Part{
|
|
||||||
genai.Text("This is for working with the GO language files at http://go.wit.com/"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stream content generation
|
|
||||||
iter := model.GenerateContentStream(ctx, genai.Text("what is the current version of forge on the webpage?"))
|
|
||||||
for {
|
|
||||||
resp, err := iter.Next()
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
for _, part := range resp.Candidates {
|
|
||||||
if part.Content != nil {
|
|
||||||
for _, p := range part.Content.Parts {
|
|
||||||
if text, ok := p.(genai.Text); ok {
|
|
||||||
fmt.Print(string(text))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
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
|
|
|
@ -1,12 +0,0 @@
|
||||||
//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()
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
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 +0,0 @@
|
||||||
TOKEN=5292519055:AAGJPrxYs70PoIWEvLcS3oV3XZ2ldko-M4k
|
|
|
@ -1,5 +0,0 @@
|
||||||
run:
|
|
||||||
go run -v -x send_after.go
|
|
||||||
|
|
||||||
test:
|
|
||||||
curl https://api.telegram.org/bot5292519055:AAGJPrxYs70PoIWEvLcS3oV3XZ2ldko-M4k/getMe
|
|
|
@ -1,37 +0,0 @@
|
||||||
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()
|
|
||||||
}
|
|
Loading…
Reference in New Issue