autoset.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. package main
  2. import (
  3. "fmt"
  4. "runtime"
  5. "sort"
  6. "strconv"
  7. "github.com/bashery/botline/oop"
  8. )
  9. //
  10. func InfoGroup(client *oop.Account, gid string) string {
  11. list := ""
  12. GetSquad(client, gid)
  13. Room := oop.GetRoom(gid)
  14. _, mem, pending := client.GetChatList(gid)
  15. creator := []string{}
  16. buyer := []string{}
  17. owner := []string{}
  18. master := []string{}
  19. admin := []string{}
  20. gowner := []string{}
  21. gadmin := []string{}
  22. squad := []string{}
  23. bot := []string{}
  24. ban := []string{}
  25. fuck := []string{}
  26. mute := []string{}
  27. Gban := []string{}
  28. Glist := []string{}
  29. Maker := []string{}
  30. Seller := []string{}
  31. mGlist := []string{}
  32. for _, from := range mem {
  33. if MemUser(gid, from) && !MemBan2(gid, from) {
  34. if !InArray2(Glist, from) {
  35. Glist = append(Glist, from)
  36. }
  37. } else if UserBot.GetCreator(from) {
  38. creator = append(creator, from)
  39. } else if UserBot.GetSeller(from) {
  40. Seller = append(Seller, from)
  41. } else if InArray2(MAKERS, from) {
  42. Maker = append(Maker, from)
  43. } else if UserBot.GetBuyer(from) {
  44. buyer = append(buyer, from)
  45. } else if UserBot.GetOwner(from) {
  46. owner = append(owner, from)
  47. } else if UserBot.GetMaster(from) {
  48. master = append(master, from)
  49. } else if UserBot.GetAdmin(from) {
  50. admin = append(admin, from)
  51. } else if InArray2(Room.Gowner, from) {
  52. gowner = append(gowner, from)
  53. } else if InArray2(Room.Gadmin, from) {
  54. gadmin = append(gadmin, from)
  55. } else if UserBot.GetBot(from) {
  56. bot = append(bot, from)
  57. } else if Banned.GetFuck(from) {
  58. fuck = append(fuck, from)
  59. } else if Banned.GetBan(from) {
  60. ban = append(ban, from)
  61. } else if Banned.GetMute(from) {
  62. mute = append(mute, from)
  63. } else if InArray2(Room.Gban, from) {
  64. Gban = append(Gban, from)
  65. } else if InArray2(Squadlist, from) {
  66. squad = append(squad, from)
  67. }
  68. }
  69. for _, from := range pending {
  70. if MemUser(gid, from) && !MemBan2(gid, from) {
  71. if !InArray2(mGlist, from) {
  72. mGlist = append(mGlist, from)
  73. }
  74. } else if UserBot.GetCreator(from) {
  75. creator = append(creator, from)
  76. } else if UserBot.GetSeller(from) {
  77. Seller = append(Seller, from)
  78. } else if InArray2(MAKERS, from) {
  79. Maker = append(Maker, from)
  80. } else if UserBot.GetBuyer(from) {
  81. buyer = append(buyer, from)
  82. } else if UserBot.GetOwner(from) {
  83. owner = append(owner, from)
  84. } else if UserBot.GetMaster(from) {
  85. master = append(master, from)
  86. } else if UserBot.GetAdmin(from) {
  87. admin = append(admin, from)
  88. } else if InArray2(Room.Gowner, from) {
  89. gowner = append(gowner, from)
  90. } else if InArray2(Room.Gadmin, from) {
  91. gadmin = append(gadmin, from)
  92. } else if UserBot.GetBot(from) {
  93. bot = append(bot, from)
  94. } else if Banned.GetFuck(from) {
  95. fuck = append(fuck, from)
  96. } else if Banned.GetBan(from) {
  97. ban = append(ban, from)
  98. } else if Banned.GetMute(from) {
  99. mute = append(mute, from)
  100. } else if InArray2(Room.Gban, from) {
  101. Gban = append(Gban, from)
  102. } else if InArray2(Squadlist, from) {
  103. squad = append(squad, from)
  104. }
  105. }
  106. list += fmt.Sprintf("Group Info: %s", Room.Name)
  107. if len(Glist) != 0 {
  108. list += "\n\nMember: \n"
  109. cuh, _ := client.GetContacts(Glist)
  110. for _, prs := range cuh {
  111. name := prs.DisplayName
  112. list += fmt.Sprintf("\n %s", name)
  113. }
  114. }
  115. if len(mGlist) != 0 {
  116. chp, _ := client.GetContacts(mGlist)
  117. list += "\n\n Pending: \n"
  118. for _, prs := range chp {
  119. name := prs.DisplayName
  120. list += fmt.Sprintf("\n %s", name)
  121. }
  122. }
  123. if len(Glist)+len(mGlist) != len(pending)+len(mem) {
  124. list += "\n\nUsers have access:\n"
  125. if len(creator) != 0 {
  126. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐˜๐—ฒ๐—ฎ๐—บ:\n"
  127. for n, xx := range creator {
  128. rengs := strconv.Itoa(n + 1)
  129. new := client.Getcontactuser(xx)
  130. if new != nil {
  131. list += rengs + ". Closed Account \n"
  132. } else {
  133. x, _ := client.GetContact(xx)
  134. list += rengs + ". " + x.DisplayName + "\n"
  135. }
  136. }
  137. }
  138. if len(Seller) != 0 {
  139. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐—ฆ๐—ฒ๐—น๐—น๐—ฒ๐—ฟ:\n"
  140. for n, xx := range Seller {
  141. rengs := strconv.Itoa(n + 1)
  142. new := client.Getcontactuser(xx)
  143. if new != nil {
  144. list += rengs + ". Closed Account \n"
  145. } else {
  146. x, _ := client.GetContact(xx)
  147. list += rengs + ". " + x.DisplayName + "\n"
  148. }
  149. }
  150. }
  151. if len(Maker) != 0 {
  152. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐˜๐—ฒ๐—ฎ๐—บ:\n"
  153. for n, xx := range Maker {
  154. rengs := strconv.Itoa(n + 1)
  155. new := client.Getcontactuser(xx)
  156. if new != nil {
  157. list += rengs + ". Closed Account \n"
  158. } else {
  159. x, _ := client.GetContact(xx)
  160. list += rengs + ". " + x.DisplayName + "\n"
  161. }
  162. }
  163. }
  164. if len(buyer) != 0 {
  165. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐—ฏ๐˜‚๐˜†๐—ฒ๐—ฟ๐˜€:\n"
  166. for n, xx := range buyer {
  167. rengs := strconv.Itoa(n + 1)
  168. new := client.Getcontactuser(xx)
  169. if new != nil {
  170. list += rengs + ". Closed Account \n"
  171. } else {
  172. x, _ := client.GetContact(xx)
  173. list += rengs + ". " + x.DisplayName + "\n"
  174. }
  175. }
  176. }
  177. if len(owner) != 0 {
  178. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐—ผ๐˜„๐—ป๐—ฒ๐—ฟ๐˜€:\n"
  179. for n, xx := range owner {
  180. rengs := strconv.Itoa(n + 1)
  181. new := client.Getcontactuser(xx)
  182. if new != nil {
  183. list += rengs + ". Closed Account \n"
  184. } else {
  185. x, _ := client.GetContact(xx)
  186. list += rengs + ". " + x.DisplayName + "\n"
  187. }
  188. }
  189. }
  190. if len(master) != 0 {
  191. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐—บ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ๐˜€:\n"
  192. for n, xx := range master {
  193. rengs := strconv.Itoa(n + 1)
  194. new := client.Getcontactuser(xx)
  195. if new != nil {
  196. list += rengs + ". Closed Account \n"
  197. } else {
  198. x, _ := client.GetContact(xx)
  199. list += rengs + ". " + x.DisplayName + "\n"
  200. }
  201. }
  202. }
  203. if len(admin) != 0 {
  204. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐—ฎ๐—ฑ๐—บ๐—ถ๐—ป๐˜€:\n"
  205. for n, xx := range admin {
  206. rengs := strconv.Itoa(n + 1)
  207. new := client.Getcontactuser(xx)
  208. if new != nil {
  209. list += rengs + ". Closed Account \n"
  210. } else {
  211. x, _ := client.GetContact(xx)
  212. list += rengs + ". " + x.DisplayName + "\n"
  213. }
  214. }
  215. }
  216. if len(gowner) != 0 {
  217. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐—ด๐—ผ๐˜„๐—ป๐—ฒ๐—ฟ๐˜€:\n"
  218. for n, xx := range gowner {
  219. rengs := strconv.Itoa(n + 1)
  220. new := client.Getcontactuser(xx)
  221. if new != nil {
  222. list += rengs + ". Closed Account \n"
  223. } else {
  224. x, _ := client.GetContact(xx)
  225. list += rengs + ". " + x.DisplayName + "\n"
  226. }
  227. }
  228. }
  229. if len(gadmin) != 0 {
  230. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐—ด๐—ฎ๐—ฑ๐—บ๐—ถ๐—ป๐˜€:\n"
  231. for n, xx := range gadmin {
  232. rengs := strconv.Itoa(n + 1)
  233. new := client.Getcontactuser(xx)
  234. if new != nil {
  235. list += rengs + ". Closed Account \n"
  236. } else {
  237. x, _ := client.GetContact(xx)
  238. list += rengs + ". " + x.DisplayName + "\n"
  239. }
  240. }
  241. }
  242. if len(bot) != 0 {
  243. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐—ฏ๐—ผ๐˜๐—น๐—ถ๐˜€๐˜\n"
  244. for n, xx := range bot {
  245. rengs := strconv.Itoa(n + 1)
  246. new := client.Getcontactuser(xx)
  247. if new != nil {
  248. list += rengs + ". Closed Account \n"
  249. } else {
  250. x, _ := client.GetContact(xx)
  251. list += rengs + ". " + x.DisplayName + "\n"
  252. }
  253. }
  254. }
  255. if len(squad) != 0 {
  256. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐˜€๐—พ๐˜‚๐—ฎ๐—ฑ:\n"
  257. for n, xx := range squad {
  258. rengs := strconv.Itoa(n + 1)
  259. new := client.Getcontactuser(xx)
  260. if new != nil {
  261. list += rengs + ". Closed Account \n"
  262. } else {
  263. x, _ := client.GetContact(xx)
  264. list += rengs + ". " + x.DisplayName + "\n"
  265. }
  266. }
  267. }
  268. if len(ban) != 0 {
  269. list += "๐—˜๐˜…๐—ถ๐˜€๐˜.๐—ถ๐—ป ๐—ฏ๐—ฎ๐—ป๐—น๐—ถ๐˜€๐˜:\n"
  270. for n, xx := range ban {
  271. rengs := strconv.Itoa(n + 1)
  272. new := client.Getcontactuser(xx)
  273. if new != nil {
  274. list += rengs + ". Closed Account \n"
  275. } else {
  276. x, _ := client.GetContact(xx)
  277. list += rengs + ". " + x.DisplayName + "\n"
  278. }
  279. }
  280. }
  281. if len(fuck) != 0 {
  282. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐—ณ๐˜‚๐—ฐ๐—ธ๐—น๐—ถ๐˜€๐˜:\n"
  283. for n, xx := range fuck {
  284. rengs := strconv.Itoa(n + 1)
  285. new := client.Getcontactuser(xx)
  286. if new != nil {
  287. list += rengs + ". Closed Account \n"
  288. } else {
  289. x, _ := client.GetContact(xx)
  290. list += rengs + ". " + x.DisplayName + "\n"
  291. }
  292. }
  293. }
  294. if len(Gban) != 0 {
  295. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐—ด๐—ฏ๐—ฎ๐—ป๐—น๐—ถ๐˜€๐˜:\n\n"
  296. for n, xx := range Gban {
  297. rengs := strconv.Itoa(n + 1)
  298. new := client.Getcontactuser(xx)
  299. if new != nil {
  300. list += rengs + ". Closed Account \n"
  301. } else {
  302. x, _ := client.GetContact(xx)
  303. list += rengs + ". " + x.DisplayName + "\n"
  304. }
  305. }
  306. }
  307. if len(mute) != 0 {
  308. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐— ๐˜‚๐˜๐—ฒ๐—น๐—ถ๐˜€๐˜:\n\n"
  309. for n, xx := range mute {
  310. rengs := strconv.Itoa(n + 1)
  311. new := client.Getcontactuser(xx)
  312. if new != nil {
  313. list += rengs + ". Closed Account \n"
  314. } else {
  315. x, _ := client.GetContact(xx)
  316. list += rengs + ". " + x.DisplayName + "\n"
  317. }
  318. }
  319. }
  320. }
  321. return list
  322. }
  323. func nukeAll(Client *oop.Account, Group string) {
  324. defer oop.PanicOnly()
  325. memlist := []string{}
  326. _, memlists := Client.GetGroupMember(Group)
  327. act := []*oop.Account{}
  328. for mid := range memlists {
  329. if MemUser(Group, mid) {
  330. memlist = append(memlist, mid)
  331. } else if InArray2(Squadlist, mid) {
  332. cl := GetKorban(mid)
  333. if !cl.Limited {
  334. act = append(act, cl)
  335. }
  336. }
  337. }
  338. lact := len(act)
  339. if lact == 0 {
  340. return
  341. } else {
  342. sort.Slice(act, func(i, j int) bool {
  343. return act[i].KickPoint < act[j].KickPoint
  344. })
  345. celek := len(memlist)
  346. if celek < MaxKick || lact == 1 {
  347. cl := act[0]
  348. for _, mem := range memlist {
  349. go cl.DeleteOtherFromChat(Group, mem)
  350. }
  351. } else {
  352. hajar := []string{}
  353. z := celek / MaxKick
  354. y := z + 1
  355. no := 0
  356. for i := 0; i < y; i++ {
  357. if no >= lact {
  358. no = 0
  359. }
  360. go func(Group string, no int, i int, z int, memlist []string, act []*oop.Account) {
  361. Client = act[no]
  362. if i == z {
  363. hajar = memlist[i*MaxKick:]
  364. } else {
  365. hajar = memlist[i*MaxKick : (i+1)*MaxKick]
  366. }
  367. if len(hajar) != 0 {
  368. for _, target := range hajar {
  369. go Client.DeleteOtherFromChat(Group, target)
  370. }
  371. }
  372. }(Group, no, i, z, memlist, act)
  373. no += 1
  374. }
  375. }
  376. oop.GetRoom(Group).HaveClient = act
  377. }
  378. }
  379. func AcceptJoin(client *oop.Account, Group string) {
  380. defer panicHandle("AcceptJoin")
  381. runtime.GOMAXPROCS(cpu)
  382. Room := oop.GetRoom(Group)
  383. if AutoPro {
  384. Room.AutoBro()
  385. }
  386. _, memlist := client.GetGroupMember(Group)
  387. oke := []string{}
  388. ban := []string{}
  389. exe := []*oop.Account{}
  390. Botss := []*oop.Account{}
  391. for mid := range memlist {
  392. if InArray2(Squadlist, mid) {
  393. oke = append(oke, mid)
  394. cl := GetKorban(mid)
  395. Botss = append(Botss, cl)
  396. if !cl.Limited {
  397. exe = append(exe, cl)
  398. }
  399. } else if MemBan(Group, mid) {
  400. ban = append(ban, mid)
  401. }
  402. }
  403. if len(exe) != 0 {
  404. sort.Slice(exe, func(i, j int) bool {
  405. return exe[i].KickPoint < exe[j].KickPoint
  406. })
  407. Room.HaveClient = exe
  408. Room.Client = Botss
  409. Room.Bot = oke
  410. oop.SetAva(Group, oke)
  411. if canceljoin {
  412. Canceljoin(client, Group)
  413. } else if NukeJoin {
  414. nukeAll(client, Group)
  415. } else {
  416. if AutoPurge {
  417. if len(ban) != 0 {
  418. no := 0
  419. ah := 0
  420. for _, target := range ban {
  421. go func(target string, no int) {
  422. exe[no].DeleteOtherFromChats(Group, target)
  423. }(target, no)
  424. if ah >= MaxKick {
  425. no++
  426. if no >= len(exe) {
  427. no = 0
  428. }
  429. ah = 0
  430. }
  431. ah++
  432. }
  433. }
  434. }
  435. }
  436. if Autojoin == "qr" {
  437. AutojoinQr(exe[0], Group)
  438. } else {
  439. if Autojoin == "invite" {
  440. Setinviteto(exe[0], Group, exe[0].Squads)
  441. }
  442. }
  443. }
  444. }