Skip to content

Commit

Permalink
notify doduapi
Browse files Browse the repository at this point in the history
  • Loading branch information
stelzo committed Jan 9, 2025
1 parent e0704a6 commit d2a778e
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
alm-prev*
alm-dates

version
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# alm-dates

A little tool to populate the Almanax from the data repository with dates from the Krosmoz Website.

> [!NOTE]
> This tool is probably of no use to you. It is a part of the dofusdude update pipeline. You are still welcome to use it if you find a use case.
Environment parameters for the `.env` file:
```sh
DODUAPI_UPDATE_TOKEN=""
POLLING_INTERVAL="1m"
END_DURATION="1y"
GH_AUTH_KEY="" # mandatory
```

## License
[MIT](https://choosealicense.com/licenses/mit/)
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/PuerkitoBio/goquery v1.10.1
github.com/charmbracelet/log v0.4.0
github.com/dofusdude/dodugo v1.0.0-rc.8
github.com/dofusdude/dodumap v0.6.0
github.com/dofusdude/dodumap v0.6.1
github.com/google/go-github/v67 v67.0.0
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ 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/dofusdude/dodugo v1.0.0-rc.8 h1:C3LCiBag8BaFzMEJ7xnwur0aXAVGMwPH78T3eqt88TQ=
github.com/dofusdude/dodugo v1.0.0-rc.8/go.mod h1:R/MZWCsB/+GpFctfckhOWmqpCMgmGkB+YC3N3TS3n6Y=
github.com/dofusdude/dodumap v0.6.0 h1:MUhyT5DEsuJnb1UDkgI1SuqKqIB3I3b0oNkjY/a8dBU=
github.com/dofusdude/dodumap v0.6.0/go.mod h1:51KG2eMd02UJnXErOubAukVftYuJproDHqJcbIHSzIE=
github.com/dofusdude/dodumap v0.6.1 h1:8zaTv6pMfkvN8OY3g2wupcjF3NgQo/KaOFI0gH++ljY=
github.com/dofusdude/dodumap v0.6.1/go.mod h1:51KG2eMd02UJnXErOubAukVftYuJproDHqJcbIHSzIE=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
Expand Down
30 changes: 23 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ func isDate(date string) bool {
}

const (
AlmanaxUrl = "https://www.krosmoz.com/en/almanax"
CreateUpdateEndpointUrl = "https://alm.dofusdu.de/dofus2/almanax"
AlmanaxSourceRepo = "dofusdude/dofus3-main"
UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:2.0b7) Gecko/20100101 Firefox/4.0b7"
DataRepoOwner = "dofusdude"
DataRepoName = "dofus3-main"
MappedAlmanaxFileName = "MAPPED_ALMANAX.json"
AlmanaxUrl = "https://www.krosmoz.com/en/almanax"
DoduapiUpdateEndpointUrl = "https://api.dofusdu.de/dofus3/v1/update"
UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:2.0b7) Gecko/20100101 Firefox/4.0b7"
DataRepoOwner = "dofusdude"
DataRepoName = "dofus3-main"
MappedAlmanaxFileName = "MAPPED_ALMANAX.json"
)

var DoduapiUpdateToken string

// ParseDuration parses a duration string.
// examples: "10d", "-1.5w" or "3Y4M5d".
// Add time units are "d"="D", "w"="W", "M", "y"="Y".
Expand Down Expand Up @@ -209,6 +210,19 @@ func updateAlmanaxRelease(almData []mapping.MappedMultilangNPCAlmanaxUnity, vers
return err
}

if DoduapiUpdateToken != "" {
body := fmt.Sprintf(`{"version":"%s"}`, version)
req, err := http.NewRequest("POST", fmt.Sprintf("%s/%s", DoduapiUpdateEndpointUrl, DoduapiUpdateToken), strings.NewReader(body))
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
_, err = http.DefaultClient.Do(req)
if err != nil {
return err
}
}

return err
}

Expand Down Expand Up @@ -424,6 +438,8 @@ func main() {
log.Fatal("no github auth key found")
}

DoduapiUpdateToken = os.Getenv("DODUAPI_UPDATE_TOKEN")

pollIntervalStr := os.Getenv("POLLING_INTERVAL")
if pollIntervalStr == "" {
pollIntervalStr = "1m"
Expand Down

0 comments on commit d2a778e

Please sign in to comment.