// mmc -- Mattermost client // Copyright (C) 2023-2024 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" "net/url" "github.com/mattermost/mattermost-server/v6/model" "go.cypherpunks.ru/netrc" "go.stargrave.org/mmc/internal" ) func main() { entrypoint := flag.String("entrypoint", mmc.GetEntrypoint(), "Entrypoint") flag.Parse() log.SetFlags(log.Lshortfile) chId := flag.Arg(0) entrypointURL, err := url.Parse(*entrypoint) if err != nil { log.Fatalln(err) } login, password := netrc.Find(entrypointURL.Hostname()) if login == "" || password == "" { log.Fatalln("no credentials found for:", entrypointURL.Hostname()) } c := model.NewAPIv4Client(*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() }