50 lines
878 B
Go
Raw Normal View History

2018-07-03 03:27:34 +00:00
package main
import (
"flag"
2019-04-23 05:45:17 +00:00
"github.com/akyoto/color"
2019-06-03 09:32:43 +00:00
"github.com/animenotifier/notify.moe/arn"
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()
}