// mmc -- Mattermost client // Copyright (C) 2023 Sergey Matveev // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . package main import ( "flag" "log" "github.com/mattermost/mattermost-server/v6/model" "go.stargrave.org/mmc" ) func main() { entrypoint := flag.String("entrypoint", "mm.rnd.stcnet.ru", "Entrypoint") flag.Parse() log.SetFlags(log.Lshortfile) chId := flag.Arg(0) login, password := mmc.FindInNetrc(*entrypoint) if login == "" || password == "" { log.Fatalln("no credentials found for:", *entrypoint) } c := model.NewAPIv4Client("https://" + *entrypoint) c.Login(login, password) me, _, err := c.GetMe("") if err != nil { log.Fatalln(err) } if _, err = c.RemoveUserFromChannel(chId, me.Id); err != nil { log.Println("RemoveUserFromChannel:", err) } c.Logout() }