Skip to content

Commit

Permalink
Merge pull request #1 from amidatelion/url-fix
Browse files Browse the repository at this point in the history
basic rewrite and priming for multi-user dev
  • Loading branch information
bloodydoves authored Jan 25, 2023
2 parents 4d2080f + de2bd90 commit 95983c9
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 10 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# bta-wiki-import

A cli tool to dump various HBS BT "defs" to wikitext.

## Usage

First you need to convert the defs to wikitext or "export" them:
`bta-wiki-import export ./mod-directory ./path-to-wikitext`

Then you can upload them to the wiki or "import" them:
`bta-wiki-import import -u Username@botname -l https://WEBSITE/api.php --passfile ./file-with-password ./path-to-wikitext`
Binary file modified bta-wiki-import.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"path/filepath"
"strings"

"github.com/dperny/bta-wiki-import/export"
"github.com/bloodydoves/bta-wiki-import/export"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand Down
10 changes: 8 additions & 2 deletions cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"strings"

"github.com/dperny/bta-wiki-import/importer"
"github.com/bloodydoves/bta-wiki-import/importer"

"github.com/spf13/cobra"
)
Expand All @@ -20,6 +20,7 @@ var (
flagDryRun bool
flagWikiUsername string
flagWikiPassFile string
flagWikiURL string
)

var ImportCmd = &cobra.Command{
Expand All @@ -29,6 +30,7 @@ var ImportCmd = &cobra.Command{
// first, check the flags for a username. Prefer this over the
// environment variable.
username := flagWikiUsername
url := flagWikiURL

// if there is no username flag set, then check the environment
if flagWikiUsername == "" {
Expand Down Expand Up @@ -61,7 +63,7 @@ var ImportCmd = &cobra.Command{
return fmt.Errorf("no wiki password provided")
}

return importer.Import(args[0], flagDryRun, username, password)
return importer.Import(args[0], flagDryRun, username, password, url)
},
}

Expand All @@ -74,6 +76,10 @@ func init() {
&flagWikiUsername, "username", "u", "",
"the username to use when logging into the wiki",
)
ImportCmd.Flags().StringVarP(
&flagWikiURL, "url", "l", "",
"the wiki URL to log in against. Expects https://WEBSITE/api.php",
)
ImportCmd.Flags().StringVar(
&flagWikiPassFile, "passfile", "",
"a file to read the wiki password from",
Expand Down
2 changes: 1 addition & 1 deletion cmd/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"os"

"github.com/dperny/bta-wiki-import/export"
"github.com/bloodydoves/bta-wiki-import/export"

"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/spf13/cobra"

"github.com/dperny/bta-wiki-import/export"
"github.com/bloodydoves/bta-wiki-import/export"
)

var WalkCommand = &cobra.Command{
Expand Down
20 changes: 20 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module bta-wiki-import

go 1.19

require (
cgt.name/pkg/go-mwclient v1.2.0
github.com/bloodydoves/bta-wiki-import v0.0.0-20211025154455-4d2080f1980b
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cobra v1.6.1
)

require (
github.com/antonholmquist/jason v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
)

// replace github.com/bloodydoves/bta-wiki-import => /replace/with/your/path/to/bta-wiki-import
30 changes: 30 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cgt.name/pkg/go-mwclient v1.2.0 h1:/ZMVH+wF62ITK0Uj1KnM1tPtE/AXYQabXe2cTA6JGSQ=
cgt.name/pkg/go-mwclient v1.2.0/go.mod h1:sxgLqpaVbtOhM1KiAUPkkRdsE6au+E64Bq9a2GyAQdU=
github.com/antonholmquist/jason v1.0.0 h1:Ytg94Bcf1Bfi965K2q0s22mig/n4eGqEij/atENBhA0=
github.com/antonholmquist/jason v1.0.0/go.mod h1:+GxMEKI0Va2U8h3os6oiUAetHAlGMvxjdpAH/9uvUMA=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450 h1:j2kD3MT1z4PXCiUllUJF9mWUESr9TWKS7iEKsQ/IipM=
github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450/go.mod h1:skjdDftzkFALcuGzYSklqYd8gvat6F1gZJ4YPVbkZpM=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
6 changes: 2 additions & 4 deletions importer/mediawiki.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ import (
"github.com/sirupsen/logrus"
)

const URL = "https://www.bta3062.com/api.php"

// BATCH_SIZE is the number of wiki pages to retrieve at one time.
const BATCH_SIZE = 20

func Import(wikidata string, dryrun bool, username, password string) error {
w, err := mwclient.New(URL, "")
func Import(wikidata string, dryrun bool, username, password, url string) error {
w, err := mwclient.New(url, "")
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/dperny/bta-wiki-import/cmd"
"github.com/bloodydoves/bta-wiki-import/cmd"
)

func main() {
Expand Down

0 comments on commit 95983c9

Please sign in to comment.