123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 |
- package main
- import (
- "fmt"
- "runtime"
- "sort"
- "strconv"
- "github.com/bashery/botline/oop"
- )
- //
- func InfoGroup(client *oop.Account, gid string) string {
- list := ""
- GetSquad(client, gid)
- Room := oop.GetRoom(gid)
- _, mem, pending := client.GetChatList(gid)
- creator := []string{}
- buyer := []string{}
- owner := []string{}
- master := []string{}
- admin := []string{}
- gowner := []string{}
- gadmin := []string{}
- squad := []string{}
- bot := []string{}
- ban := []string{}
- fuck := []string{}
- mute := []string{}
- Gban := []string{}
- Glist := []string{}
- Maker := []string{}
- Seller := []string{}
- mGlist := []string{}
- for _, from := range mem {
- if MemUser(gid, from) && !MemBan2(gid, from) {
- if !InArray2(Glist, from) {
- Glist = append(Glist, from)
- }
- } else if UserBot.GetCreator(from) {
- creator = append(creator, from)
- } else if UserBot.GetSeller(from) {
- Seller = append(Seller, from)
- } else if InArray2(MAKERS, from) {
- Maker = append(Maker, from)
- } else if UserBot.GetBuyer(from) {
- buyer = append(buyer, from)
- } else if UserBot.GetOwner(from) {
- owner = append(owner, from)
- } else if UserBot.GetMaster(from) {
- master = append(master, from)
- } else if UserBot.GetAdmin(from) {
- admin = append(admin, from)
- } else if InArray2(Room.Gowner, from) {
- gowner = append(gowner, from)
- } else if InArray2(Room.Gadmin, from) {
- gadmin = append(gadmin, from)
- } else if UserBot.GetBot(from) {
- bot = append(bot, from)
- } else if Banned.GetFuck(from) {
- fuck = append(fuck, from)
- } else if Banned.GetBan(from) {
- ban = append(ban, from)
- } else if Banned.GetMute(from) {
- mute = append(mute, from)
- } else if InArray2(Room.Gban, from) {
- Gban = append(Gban, from)
- } else if InArray2(Squadlist, from) {
- squad = append(squad, from)
- }
- }
- for _, from := range pending {
- if MemUser(gid, from) && !MemBan2(gid, from) {
- if !InArray2(mGlist, from) {
- mGlist = append(mGlist, from)
- }
- } else if UserBot.GetCreator(from) {
- creator = append(creator, from)
- } else if UserBot.GetSeller(from) {
- Seller = append(Seller, from)
- } else if InArray2(MAKERS, from) {
- Maker = append(Maker, from)
- } else if UserBot.GetBuyer(from) {
- buyer = append(buyer, from)
- } else if UserBot.GetOwner(from) {
- owner = append(owner, from)
- } else if UserBot.GetMaster(from) {
- master = append(master, from)
- } else if UserBot.GetAdmin(from) {
- admin = append(admin, from)
- } else if InArray2(Room.Gowner, from) {
- gowner = append(gowner, from)
- } else if InArray2(Room.Gadmin, from) {
- gadmin = append(gadmin, from)
- } else if UserBot.GetBot(from) {
- bot = append(bot, from)
- } else if Banned.GetFuck(from) {
- fuck = append(fuck, from)
- } else if Banned.GetBan(from) {
- ban = append(ban, from)
- } else if Banned.GetMute(from) {
- mute = append(mute, from)
- } else if InArray2(Room.Gban, from) {
- Gban = append(Gban, from)
- } else if InArray2(Squadlist, from) {
- squad = append(squad, from)
- }
- }
- list += fmt.Sprintf("Group Info: %s", Room.Name)
- if len(Glist) != 0 {
- list += "\n\nMember: \n"
- cuh, _ := client.GetContacts(Glist)
- for _, prs := range cuh {
- name := prs.DisplayName
- list += fmt.Sprintf("\n %s", name)
- }
- }
- if len(mGlist) != 0 {
- chp, _ := client.GetContacts(mGlist)
- list += "\n\n Pending: \n"
- for _, prs := range chp {
- name := prs.DisplayName
- list += fmt.Sprintf("\n %s", name)
- }
- }
- if len(Glist)+len(mGlist) != len(pending)+len(mem) {
- list += "\n\nUsers have access:\n"
- if len(creator) != 0 {
- list += "\n𝗘𝘅𝗶𝘀𝘁 𝗶𝗻 𝘁𝗲𝗮𝗺:\n"
- for n, xx := range creator {
- rengs := strconv.Itoa(n + 1)
- new := client.Getcontactuser(xx)
- if new != nil {
- list += rengs + ". Closed Account \n"
- } else {
- x, _ := client.GetContact(xx)
- list += rengs + ". " + x.DisplayName + "\n"
- }
- }
- }
- if len(Seller) != 0 {
- list += "\n𝗘𝘅𝗶𝘀𝘁 𝗶𝗻 𝗦𝗲𝗹𝗹𝗲𝗿:\n"
- for n, xx := range Seller {
- rengs := strconv.Itoa(n + 1)
- new := client.Getcontactuser(xx)
- if new != nil {
- list += rengs + ". Closed Account \n"
- } else {
- x, _ := client.GetContact(xx)
- list += rengs + ". " + x.DisplayName + "\n"
- }
- }
- }
- if len(Maker) != 0 {
- list += "\n𝗘𝘅𝗶𝘀𝘁 𝗶𝗻 𝘁𝗲𝗮𝗺:\n"
- for n, xx := range Maker {
- rengs := strconv.Itoa(n + 1)
- new := client.Getcontactuser(xx)
- if new != nil {
- list += rengs + ". Closed Account \n"
- } else {
- x, _ := client.GetContact(xx)
- list += rengs + ". " + x.DisplayName + "\n"
- }
- }
- }
- if len(buyer) != 0 {
- list += "\n𝗘𝘅𝗶𝘀𝘁 𝗶𝗻 𝗯𝘂𝘆𝗲𝗿𝘀:\n"
- for n, xx := range buyer {
- rengs := strconv.Itoa(n + 1)
- new := client.Getcontactuser(xx)
- if new != nil {
- list += rengs + ". Closed Account \n"
- } else {
- x, _ := client.GetContact(xx)
- list += rengs + ". " + x.DisplayName + "\n"
- }
- }
- }
- if len(owner) != 0 {
- list += "\n𝗘𝘅𝗶𝘀𝘁 𝗶𝗻 𝗼𝘄𝗻𝗲𝗿𝘀:\n"
- for n, xx := range owner {
- rengs := strconv.Itoa(n + 1)
- new := client.Getcontactuser(xx)
- if new != nil {
- list += rengs + ". Closed Account \n"
- } else {
- x, _ := client.GetContact(xx)
- list += rengs + ". " + x.DisplayName + "\n"
- }
- }
- }
- if len(master) != 0 {
- list += "\n𝗘𝘅𝗶𝘀𝘁 𝗶𝗻 𝗺𝗮𝘀𝘁𝗲𝗿𝘀:\n"
- for n, xx := range master {
- rengs := strconv.Itoa(n + 1)
- new := client.Getcontactuser(xx)
- if new != nil {
- list += rengs + ". Closed Account \n"
- } else {
- x, _ := client.GetContact(xx)
- list += rengs + ". " + x.DisplayName + "\n"
- }
- }
- }
- if len(admin) != 0 {
- list += "\n𝗘𝘅𝗶𝘀𝘁 𝗶𝗻 𝗮𝗱𝗺𝗶𝗻𝘀:\n"
- for n, xx := range admin {
- rengs := strconv.Itoa(n + 1)
- new := client.Getcontactuser(xx)
- if new != nil {
- list += rengs + ". Closed Account \n"
- } else {
- x, _ := client.GetContact(xx)
- list += rengs + ". " + x.DisplayName + "\n"
- }
- }
- }
- if len(gowner) != 0 {
- list += "\n𝗘𝘅𝗶𝘀𝘁 𝗶𝗻 𝗴𝗼𝘄𝗻𝗲𝗿𝘀:\n"
- for n, xx := range gowner {
- rengs := strconv.Itoa(n + 1)
- new := client.Getcontactuser(xx)
- if new != nil {
- list += rengs + ". Closed Account \n"
- } else {
- x, _ := client.GetContact(xx)
- list += rengs + ". " + x.DisplayName + "\n"
- }
- }
- }
- if len(gadmin) != 0 {
- list += "\n𝗘𝘅𝗶𝘀𝘁 𝗶𝗻 𝗴𝗮𝗱𝗺𝗶𝗻𝘀:\n"
- for n, xx := range gadmin {
- rengs := strconv.Itoa(n + 1)
- new := client.Getcontactuser(xx)
- if new != nil {
- list += rengs + ". Closed Account \n"
- } else {
- x, _ := client.GetContact(xx)
- list += rengs + ". " + x.DisplayName + "\n"
- }
- }
- }
- if len(bot) != 0 {
- list += "\n𝗘𝘅𝗶𝘀𝘁 𝗶𝗻 𝗯𝗼𝘁𝗹𝗶𝘀𝘁\n"
- for n, xx := range bot {
- rengs := strconv.Itoa(n + 1)
- new := client.Getcontactuser(xx)
- if new != nil {
- list += rengs + ". Closed Account \n"
- } else {
- x, _ := client.GetContact(xx)
- list += rengs + ". " + x.DisplayName + "\n"
- }
- }
- }
- if len(squad) != 0 {
- list += "\n𝗘𝘅𝗶𝘀𝘁 𝗶𝗻 𝘀𝗾𝘂𝗮𝗱:\n"
- for n, xx := range squad {
- rengs := strconv.Itoa(n + 1)
- new := client.Getcontactuser(xx)
- if new != nil {
- list += rengs + ". Closed Account \n"
- } else {
- x, _ := client.GetContact(xx)
- list += rengs + ". " + x.DisplayName + "\n"
- }
- }
- }
- if len(ban) != 0 {
- list += "𝗘𝘅𝗶𝘀𝘁.𝗶𝗻 𝗯𝗮𝗻𝗹𝗶𝘀𝘁:\n"
- for n, xx := range ban {
- rengs := strconv.Itoa(n + 1)
- new := client.Getcontactuser(xx)
- if new != nil {
- list += rengs + ". Closed Account \n"
- } else {
- x, _ := client.GetContact(xx)
- list += rengs + ". " + x.DisplayName + "\n"
- }
- }
- }
- if len(fuck) != 0 {
- list += "\n𝗘𝘅𝗶𝘀𝘁 𝗶𝗻 𝗳𝘂𝗰𝗸𝗹𝗶𝘀𝘁:\n"
- for n, xx := range fuck {
- rengs := strconv.Itoa(n + 1)
- new := client.Getcontactuser(xx)
- if new != nil {
- list += rengs + ". Closed Account \n"
- } else {
- x, _ := client.GetContact(xx)
- list += rengs + ". " + x.DisplayName + "\n"
- }
- }
- }
- if len(Gban) != 0 {
- list += "\n𝗘𝘅𝗶𝘀𝘁 𝗶𝗻 𝗴𝗯𝗮𝗻𝗹𝗶𝘀𝘁:\n\n"
- for n, xx := range Gban {
- rengs := strconv.Itoa(n + 1)
- new := client.Getcontactuser(xx)
- if new != nil {
- list += rengs + ". Closed Account \n"
- } else {
- x, _ := client.GetContact(xx)
- list += rengs + ". " + x.DisplayName + "\n"
- }
- }
- }
- if len(mute) != 0 {
- list += "\n𝗘𝘅𝗶𝘀𝘁 𝗶𝗻 𝗠𝘂𝘁𝗲𝗹𝗶𝘀𝘁:\n\n"
- for n, xx := range mute {
- rengs := strconv.Itoa(n + 1)
- new := client.Getcontactuser(xx)
- if new != nil {
- list += rengs + ". Closed Account \n"
- } else {
- x, _ := client.GetContact(xx)
- list += rengs + ". " + x.DisplayName + "\n"
- }
- }
- }
- }
- return list
- }
- func nukeAll(Client *oop.Account, Group string) {
- defer oop.PanicOnly()
- memlist := []string{}
- _, memlists := Client.GetGroupMember(Group)
- act := []*oop.Account{}
- for mid := range memlists {
- if MemUser(Group, mid) {
- memlist = append(memlist, mid)
- } else if InArray2(Squadlist, mid) {
- cl := GetKorban(mid)
- if !cl.Limited {
- act = append(act, cl)
- }
- }
- }
- lact := len(act)
- if lact == 0 {
- return
- } else {
- sort.Slice(act, func(i, j int) bool {
- return act[i].KickPoint < act[j].KickPoint
- })
- celek := len(memlist)
- if celek < MaxKick || lact == 1 {
- cl := act[0]
- for _, mem := range memlist {
- go cl.DeleteOtherFromChat(Group, mem)
- }
- } else {
- hajar := []string{}
- z := celek / MaxKick
- y := z + 1
- no := 0
- for i := 0; i < y; i++ {
- if no >= lact {
- no = 0
- }
- go func(Group string, no int, i int, z int, memlist []string, act []*oop.Account) {
- Client = act[no]
- if i == z {
- hajar = memlist[i*MaxKick:]
- } else {
- hajar = memlist[i*MaxKick : (i+1)*MaxKick]
- }
- if len(hajar) != 0 {
- for _, target := range hajar {
- go Client.DeleteOtherFromChat(Group, target)
- }
- }
- }(Group, no, i, z, memlist, act)
- no += 1
- }
- }
- oop.GetRoom(Group).HaveClient = act
- }
- }
- func AcceptJoin(client *oop.Account, Group string) {
- defer panicHandle("AcceptJoin")
- runtime.GOMAXPROCS(cpu)
- Room := oop.GetRoom(Group)
- if AutoPro {
- Room.AutoBro()
- }
- _, memlist := client.GetGroupMember(Group)
- oke := []string{}
- ban := []string{}
- exe := []*oop.Account{}
- Botss := []*oop.Account{}
- for mid := range memlist {
- if InArray2(Squadlist, mid) {
- oke = append(oke, mid)
- cl := GetKorban(mid)
- Botss = append(Botss, cl)
- if !cl.Limited {
- exe = append(exe, cl)
- }
- } else if MemBan(Group, mid) {
- ban = append(ban, mid)
- }
- }
- if len(exe) != 0 {
- sort.Slice(exe, func(i, j int) bool {
- return exe[i].KickPoint < exe[j].KickPoint
- })
- Room.HaveClient = exe
- Room.Client = Botss
- Room.Bot = oke
- oop.SetAva(Group, oke)
- if canceljoin {
- Canceljoin(client, Group)
- } else if NukeJoin {
- nukeAll(client, Group)
- } else {
- if AutoPurge {
- if len(ban) != 0 {
- no := 0
- ah := 0
- for _, target := range ban {
- go func(target string, no int) {
- exe[no].DeleteOtherFromChats(Group, target)
- }(target, no)
- if ah >= MaxKick {
- no++
- if no >= len(exe) {
- no = 0
- }
- ah = 0
- }
- ah++
- }
- }
- }
- }
- if Autojoin == "qr" {
- AutojoinQr(exe[0], Group)
- } else {
- if Autojoin == "invite" {
- Setinviteto(exe[0], Group, exe[0].Squads)
- }
- }
- }
- }
|