2016-04-03 17:59:27 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-04-07 17:32:48 +00:00
|
|
|
"fmt"
|
2016-04-03 17:59:27 +00:00
|
|
|
"log"
|
2016-07-06 22:20:36 +00:00
|
|
|
"strings"
|
2016-04-07 17:32:48 +00:00
|
|
|
"syscall"
|
2016-04-03 17:59:27 +00:00
|
|
|
|
2019-02-23 13:14:37 +00:00
|
|
|
"zxq.co/ripple/agplwarning"
|
2019-02-25 21:04:55 +00:00
|
|
|
"github.com/osuyozora/api/app"
|
|
|
|
"github.com/osuyozora/api/beatmapget"
|
|
|
|
"github.com/osuyozora/api/common"
|
2019-02-23 13:11:47 +00:00
|
|
|
"zxq.co/ripple/schiavolib"
|
2016-04-03 17:59:27 +00:00
|
|
|
// Golint pls dont break balls
|
|
|
|
_ "github.com/go-sql-driver/mysql"
|
2016-08-15 11:37:03 +00:00
|
|
|
"github.com/jmoiron/sqlx"
|
2017-02-19 17:19:59 +00:00
|
|
|
"github.com/serenize/snaker"
|
2016-09-06 23:51:23 +00:00
|
|
|
"gopkg.in/thehowl/go-osuapi.v1"
|
2016-04-03 17:59:27 +00:00
|
|
|
)
|
|
|
|
|
2016-06-17 08:34:53 +00:00
|
|
|
// Version is the git hash of the application. Do not edit. This is
|
|
|
|
// automatically set using -ldflags during build time.
|
|
|
|
var Version string
|
|
|
|
|
2016-04-07 17:32:48 +00:00
|
|
|
func init() {
|
|
|
|
log.SetFlags(log.Ltime)
|
|
|
|
log.SetPrefix(fmt.Sprintf("%d|", syscall.Getpid()))
|
2016-06-17 08:34:53 +00:00
|
|
|
common.Version = Version
|
2016-04-07 17:32:48 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 11:37:03 +00:00
|
|
|
var db *sqlx.DB
|
2016-06-22 11:13:33 +00:00
|
|
|
|
2016-04-03 17:59:27 +00:00
|
|
|
func main() {
|
2018-02-04 10:54:35 +00:00
|
|
|
err := agplwarning.Warn("ripple", "Ripple API")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
|
2016-06-17 08:34:53 +00:00
|
|
|
fmt.Print("Ripple API")
|
|
|
|
if Version != "" {
|
|
|
|
fmt.Print("; git commit hash: ", Version)
|
|
|
|
}
|
|
|
|
fmt.Println()
|
|
|
|
|
2016-04-03 17:59:27 +00:00
|
|
|
conf, halt := common.Load()
|
|
|
|
if halt {
|
|
|
|
return
|
|
|
|
}
|
2016-05-22 15:11:07 +00:00
|
|
|
|
|
|
|
schiavo.Prefix = "Ripple API"
|
|
|
|
|
2016-07-06 22:20:36 +00:00
|
|
|
if !strings.Contains(conf.DSN, "parseTime=true") {
|
|
|
|
c := "?"
|
|
|
|
if strings.Contains(conf.DSN, "?") {
|
|
|
|
c = "&"
|
|
|
|
}
|
2016-11-20 12:46:44 +00:00
|
|
|
conf.DSN += c + "parseTime=true&charset=utf8mb4,utf8&collation=utf8mb4_general_ci"
|
2016-07-06 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 11:37:03 +00:00
|
|
|
db, err = sqlx.Open(conf.DatabaseType, conf.DSN)
|
2016-04-03 17:59:27 +00:00
|
|
|
if err != nil {
|
2016-05-22 15:11:07 +00:00
|
|
|
schiavo.Bunker.Send(err.Error())
|
|
|
|
log.Fatalln(err)
|
2016-04-03 17:59:27 +00:00
|
|
|
}
|
2016-09-06 23:51:23 +00:00
|
|
|
|
2017-02-19 17:19:59 +00:00
|
|
|
db.MapperFunc(func(s string) string {
|
|
|
|
if x, ok := commonClusterfucks[s]; ok {
|
|
|
|
return x
|
|
|
|
}
|
|
|
|
return snaker.CamelToSnake(s)
|
|
|
|
})
|
|
|
|
|
2016-09-06 23:51:23 +00:00
|
|
|
beatmapget.Client = osuapi.NewClient(conf.OsuAPIKey)
|
|
|
|
beatmapget.DB = db
|
|
|
|
|
2016-04-07 17:32:48 +00:00
|
|
|
engine := app.Start(conf, db)
|
|
|
|
|
2017-02-02 12:40:28 +00:00
|
|
|
startuato(engine.Handler)
|
2016-04-03 17:59:27 +00:00
|
|
|
}
|
2017-02-19 17:19:59 +00:00
|
|
|
|
|
|
|
var commonClusterfucks = map[string]string{
|
|
|
|
"RegisteredOn": "register_datetime",
|
|
|
|
"UsernameAKA": "username_aka",
|
|
|
|
"BeatmapMD5": "beatmap_md5",
|
|
|
|
"Count300": "300_count",
|
|
|
|
"Count100": "100_count",
|
|
|
|
"Count50": "50_count",
|
|
|
|
"CountGeki": "gekis_count",
|
|
|
|
"CountKatu": "katus_count",
|
|
|
|
"CountMiss": "misses_count",
|
|
|
|
"PP": "pp",
|
|
|
|
}
|