Skip to content

Commit

Permalink
fix: pkg name err
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoo committed Apr 30, 2023
1 parent 3c4ca52 commit 6938f05
Show file tree
Hide file tree
Showing 20 changed files with 304 additions and 55 deletions.
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
module Yui
module github.com/opq-osc/Yui

go 1.19

require (
github.com/charmbracelet/log v0.2.1
github.com/ethereum/go-ethereum v1.11.6
github.com/go-toolsmith/astcopy v1.1.0
github.com/google/uuid v1.3.0
github.com/imroc/req/v3 v3.33.2
github.com/knqyf263/go-plugin v0.7.1-0.20230420183704-82cf9090ca1e
github.com/mailru/easyjson v0.7.7
github.com/manifoldco/promptui v0.9.0
github.com/mcoo/OPQBot v0.2.2-0.20230415115049-02b00e2cf9e1
github.com/opq-osc/OPQBot/v2 v2.0.0-20230427091225-f73faded2e3b
github.com/robfig/cron/v3 v3.0.1
Expand All @@ -26,6 +28,7 @@ require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/charmbracelet/lipgloss v0.7.1 // indirect
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
Expand Down Expand Up @@ -72,6 +75,7 @@ require (
github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/crypto v0.4.0 // indirect
golang.org/x/exp v0.0.0-20230206171751-46f607a40771 // indirect
golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sys v0.7.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package main

import (
_ "Yui/config"
"Yui/cron"
"Yui/opq"
"Yui/plugin"
"context"
"github.com/charmbracelet/log"
_ "github.com/opq-osc/Yui/config"
"github.com/opq-osc/Yui/cron"
"github.com/opq-osc/Yui/opq"
"github.com/opq-osc/Yui/plugin"
"github.com/spf13/viper"
)

Expand Down
2 changes: 1 addition & 1 deletion plugin/S/S.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
package S

import (
"Yui/proto"
"context"
"github.com/opq-osc/OPQBot/v2/events"
"github.com/opq-osc/Yui/proto"
)

func LogInfo(ctx context.Context, msg string) {
Expand Down
2 changes: 1 addition & 1 deletion plugin/S/S_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
package S

import (
"Yui/opq"
"github.com/opq-osc/OPQBot/v2/apiBuilder"
"github.com/opq-osc/OPQBot/v2/events"
"github.com/opq-osc/Yui/opq"
)

func GetApi(event events.IEvent) apiBuilder.IMainFunc {
Expand Down
8 changes: 4 additions & 4 deletions plugin/admin.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package plugin

import (
"Yui/plugin/S"
"Yui/plugin/meta"
"Yui/plugin/repository"
"Yui/session"
"context"
"fmt"
"github.com/opq-osc/OPQBot/v2/events"
"github.com/opq-osc/Yui/plugin/S"
"github.com/opq-osc/Yui/plugin/meta"
"github.com/opq-osc/Yui/plugin/repository"
"github.com/opq-osc/Yui/session"
"github.com/spf13/cast"
"github.com/spf13/viper"
"strings"
Expand Down
2 changes: 1 addition & 1 deletion plugin/builder/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Copyright © 2023 NAME HERE <EMAIL ADDRESS>
package cmd

import (
"Yui/plugin/meta"
"bytes"
"crypto/ecdsa"
"crypto/rand"
Expand All @@ -14,6 +13,7 @@ import (
"encoding/hex"
"encoding/json"
"github.com/ethereum/go-ethereum/crypto"
"github.com/opq-osc/Yui/plugin/meta"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"io"
Expand Down
144 changes: 144 additions & 0 deletions plugin/builder/cmd/new.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
"encoding/json"
"github.com/manifoldco/promptui"
"github.com/opq-osc/Yui/plugin/meta"
"github.com/spf13/cobra"
"os"
"os/exec"
"path/filepath"
"strings"
)

// newCmd represents the new command
var newCmd = &cobra.Command{
Use: "new",
Short: "创建一个新的插件",
Long: `创建一个新的插件`,
RunE: func(cmd *cobra.Command, args []string) error {
prompt := promptui.Prompt{
Label: "plugin name",
}
var err error
pluginInfo := &meta.PluginMeta{}
pluginInfo.PluginName, err = prompt.Run()
if err != nil {
return err
}
prompt = promptui.Prompt{Label: "plugin description"}
pluginInfo.Description, err = prompt.Run()
if err != nil {
return err
}
prompt = promptui.Prompt{Label: "author"}
pluginInfo.Author, err = prompt.Run()
if err != nil {
return err
}
prompt = promptui.Prompt{Label: "author url"}
pluginInfo.Url, err = prompt.Run()
if err != nil {
return err
}
err = os.MkdirAll(pluginInfo.PluginName, 0777)
if err != nil {
return err
}
goFile = strings.ReplaceAll(goFile, "{{.pluginName}}", pluginInfo.PluginName)
err = os.WriteFile(filepath.Join(pluginInfo.PluginName, pluginInfo.PluginName+".go"), []byte(goFile), 0777)
if err != nil {
return err
}
GoCmd := exec.Command("go", "mod", "init", pluginInfo.PluginName)
GoCmd.Dir = "./" + pluginInfo.PluginName
GoCmd.Stderr = os.Stderr
err = GoCmd.Run()
if err != nil {
return err
}
GoCmd = exec.Command("go", "mod", "tidy")
GoCmd.Dir = "./" + pluginInfo.PluginName
GoCmd.Stderr = os.Stderr
err = GoCmd.Run()
if err != nil {
return err
}
metaInfo, err := json.Marshal(pluginInfo)
if err != nil {
return err
}
err = os.WriteFile(filepath.Join(pluginInfo.PluginName, "meta.json"), []byte(metaInfo), 0777)
if err != nil {
return err
}
return nil
},
}

func init() {
rootCmd.AddCommand(newCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// newCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// newCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

var goFile = `//go:build tinygo.wasm
package main
import (
"github.com/opq-osc/Yui/plugin/meta"
"github.com/opq-osc/Yui/proto"
"context"
"github.com/knqyf263/go-plugin/types/known/emptypb"
)
type {{.pluginName}} struct {
}
func (p {{.pluginName}}) OnRemoteCallEvent(ctx context.Context, req *proto.RemoteCallReq) (*proto.RemoteCallReply, error) {
//TODO implement me
panic("implement me")
}
func (p {{.pluginName}}) OnCronEvent(ctx context.Context, req *proto.CronEventReq) (*emptypb.Empty, error) {
return &emptypb.Empty{}, nil
}
func (p {{.pluginName}}) OnFriendMsg(ctx context.Context, msg *proto.CommonMsg) (*emptypb.Empty, error) {
return &emptypb.Empty{}, nil
}
func (p {{.pluginName}}) OnPrivateMsg(ctx context.Context, msg *proto.CommonMsg) (*emptypb.Empty, error) {
return &emptypb.Empty{}, nil
}
func (p {{.pluginName}}) OnGroupMsg(ctx context.Context, msg *proto.CommonMsg) (*emptypb.Empty, error) {
return &emptypb.Empty{}, nil
}
func (p {{.pluginName}}) Unload(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error) {
return &emptypb.Empty{}, nil
}
func (p {{.pluginName}}) Init(ctx context.Context, _ *emptypb.Empty) (*proto.InitReply, error) {
return &proto.InitReply{
Ok: true,
Message: "Success",
}, nil
}
func main() {
proto.RegisterEvent({{.pluginName}}{})
}
`
3 changes: 1 addition & 2 deletions plugin/builder/main.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package main

import "Yui/plugin/builder/cmd"
import "github.com/opq-osc/Yui/plugin/builder/cmd"

func main() {
cmd.Execute()
Expand Down
6 changes: 3 additions & 3 deletions plugin/callOPQApi.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package plugin

import (
"Yui/opq"
"Yui/plugin/meta"
"Yui/proto"
"context"
"fmt"
"github.com/opq-osc/OPQBot/v2/apiBuilder"
"github.com/opq-osc/Yui/opq"
"github.com/opq-osc/Yui/plugin/meta"
"github.com/opq-osc/Yui/proto"
)

func (p *Plugin) SendFriendMsg(ctx context.Context, request *proto.MsgReq) (*proto.SendReply, error) {
Expand Down
4 changes: 2 additions & 2 deletions plugin/httpApi.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package plugin

import (
"Yui/plugin/meta"
"Yui/proto"
"context"
"fmt"
"github.com/charmbracelet/log"
"github.com/imroc/req/v3"
"github.com/opq-osc/Yui/plugin/meta"
"github.com/opq-osc/Yui/proto"
"github.com/spf13/viper"
)

Expand Down
12 changes: 6 additions & 6 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package plugin

import (
"Yui/cron"
"Yui/opq"
"Yui/plugin/meta"
"Yui/proto"
"Yui/proto/library/systemInfo"
systemInfoExport "Yui/proto/library/systemInfo/export"
"bytes"
"context"
"crypto/ecdsa"
Expand All @@ -19,6 +13,12 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/knqyf263/go-plugin/types/known/emptypb"
"github.com/opq-osc/OPQBot/v2/events"
"github.com/opq-osc/Yui/cron"
"github.com/opq-osc/Yui/opq"
"github.com/opq-osc/Yui/plugin/meta"
"github.com/opq-osc/Yui/proto"
"github.com/opq-osc/Yui/proto/library/systemInfo"
systemInfoExport "github.com/opq-osc/Yui/proto/library/systemInfo/export"
cron2 "github.com/robfig/cron/v3"
"github.com/spf13/viper"
"github.com/tetratelabs/wazero"
Expand Down
2 changes: 1 addition & 1 deletion plugin/repository/repository.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package repository

import (
"Yui/plugin/meta"
"context"
"encoding/json"
"fmt"
"github.com/imroc/req/v3"
"github.com/opq-osc/Yui/plugin/meta"
"github.com/spf13/viper"
)

Expand Down
6 changes: 3 additions & 3 deletions plugins/animeCharacter/animeCharacter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
package main

import (
"Yui/plugin/S"
"Yui/plugins/animeCharacter/config"
"Yui/proto"
"context"
"fmt"
"github.com/knqyf263/go-plugin/types/known/emptypb"
"github.com/opq-osc/Yui/plugin/S"
"github.com/opq-osc/Yui/plugins/animeCharacter/config"
"github.com/opq-osc/Yui/proto"
"github.com/tidwall/gjson"
"math/rand"
"time"
Expand Down
4 changes: 2 additions & 2 deletions plugins/example/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
package main

import (
"Yui/plugin/meta"
"Yui/proto"
"context"
"encoding/base64"
"github.com/google/uuid"
"github.com/knqyf263/go-plugin/types/known/emptypb"
"github.com/opq-osc/Yui/plugin/meta"
"github.com/opq-osc/Yui/proto"
"os"
)

Expand Down
8 changes: 4 additions & 4 deletions plugins/signPlugin/signPlugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
package main

import (
"Yui/plugin/S"
anime "Yui/plugins/animeCharacter/config"
"Yui/plugins/signPlugin/config"
"Yui/proto"
"context"
"fmt"
"github.com/knqyf263/go-plugin/types/known/emptypb"
"github.com/opq-osc/Yui/plugin/S"
anime "github.com/opq-osc/Yui/plugins/animeCharacter/config"
"github.com/opq-osc/Yui/plugins/signPlugin/config"
"github.com/opq-osc/Yui/proto"
"strconv"
"strings"
"time"
Expand Down
6 changes: 3 additions & 3 deletions plugins/systemInfo/systemInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
package main

import (
"Yui/plugin/S"
"Yui/proto"
"Yui/proto/library/systemInfo/export"
"context"
"fmt"
"github.com/opq-osc/Yui/plugin/S"
"github.com/opq-osc/Yui/proto"
"github.com/opq-osc/Yui/proto/library/systemInfo/export"

"github.com/knqyf263/go-plugin/types/known/emptypb"
)
Expand Down
Loading

0 comments on commit 6938f05

Please sign in to comment.