2018-07-03 03:27:34 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
|
|
|
|
"github.com/animenotifier/arn"
|
2019-03-30 06:39:40 +00:00
|
|
|
"github.com/blitzprog/color"
|
2018-07-03 03:27:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Shell parameters
|
|
|
|
var nick string
|
|
|
|
var service string
|
|
|
|
var serviceID string
|
|
|
|
|
|
|
|
// Shell flags
|
|
|
|
func init() {
|
|
|
|
flag.StringVar(&nick, "nick", "", "Nick of the user")
|
|
|
|
flag.StringVar(&service, "service", "", "Service name (Google or Facebook)")
|
|
|
|
flag.StringVar(&serviceID, "serviceID", "", "ID of the user on the given service")
|
|
|
|
flag.Parse()
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
if nick == "" || service == "" || serviceID == "" {
|
|
|
|
flag.Usage()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
color.Yellow("Updating user service ID")
|
|
|
|
|
|
|
|
defer color.Green("Finished.")
|
|
|
|
defer arn.Node.Close()
|
|
|
|
|
|
|
|
user, err := arn.GetUserByNick(nick)
|
|
|
|
arn.PanicOnError(err)
|
|
|
|
|
|
|
|
switch service {
|
|
|
|
case "Google":
|
|
|
|
user.ConnectGoogle(serviceID)
|
|
|
|
|
|
|
|
case "Facebook":
|
|
|
|
user.ConnectFacebook(serviceID)
|
|
|
|
|
|
|
|
default:
|
|
|
|
panic("Unknown service")
|
|
|
|
}
|
|
|
|
|
|
|
|
user.Save()
|
|
|
|
}
|