main3.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  1. package main
  2. import (
  3. "fmt"
  4. "runtime"
  5. "sort"
  6. "time"
  7. "github.com/bashery/botline/oop"
  8. // "github.com/bashery/botline/oop"
  9. )
  10. func getKey(cmd string) string {
  11. mp := oop.HashToMap(CmdHelper)
  12. for k, v := range mp {
  13. if v.(string) == cmd {
  14. return k
  15. }
  16. }
  17. return cmd
  18. }
  19. func SaveBackup() {
  20. fmt.Println("start Save Data *__*")
  21. Data.GbanBack = map[string][]string{}
  22. Data.GownerBack = map[string][]string{}
  23. Data.GadminBack = map[string][]string{}
  24. Data.BanBack = []string{}
  25. Data.SnameBack = MsSname
  26. Data.RnameBack = MsRname
  27. Data.ResponBack = MsgRespon
  28. Data.FuckBack = []string{}
  29. Data.MuteBack = []string{}
  30. Data.AnnunceBack = []string{}
  31. Data.ProQrBack = []string{}
  32. Data.ProjoinBack = []string{}
  33. Data.ProInviteBack = []string{}
  34. Data.ProCancelBack = []string{}
  35. Data.ProkickBack = []string{}
  36. Data.CreatorBack = []string{}
  37. Data.SellerBack = []string{}
  38. Data.BuyerBack = []string{}
  39. Data.OwnerBack = []string{}
  40. Data.MasterBack = []string{}
  41. Data.AdminBack = []string{}
  42. Data.BotBack = []string{}
  43. Data.TimeBanBack = map[string]time.Time{}
  44. if len(oop.KickBans) != 0 {
  45. for _, cl := range oop.KickBans {
  46. if _, ok := oop.GetBlock.Get(cl.MID); ok {
  47. Data.TimeBanBack[cl.MID] = cl.TimeBan
  48. }
  49. }
  50. }
  51. for _, room := range oop.SquadRoom {
  52. Data.GbanBack[room.Id] = []string{}
  53. Data.GownerBack[room.Id] = []string{}
  54. Data.GadminBack[room.Id] = []string{}
  55. if room.ProKick {
  56. Data.ProkickBack = append(Data.ProkickBack, room.Id)
  57. }
  58. if room.ProCancel {
  59. Data.ProCancelBack = append(Data.ProCancelBack, room.Id)
  60. }
  61. if room.ProInvite {
  62. Data.ProInviteBack = append(Data.ProInviteBack, room.Id)
  63. }
  64. if room.ProQr {
  65. Data.ProQrBack = append(Data.ProQrBack, room.Id)
  66. }
  67. if room.ProJoin {
  68. Data.ProjoinBack = append(Data.ProjoinBack, room.Id)
  69. }
  70. if room.Announce {
  71. Data.AnnunceBack = append(Data.AnnunceBack, room.Id)
  72. }
  73. }
  74. if len(UserBot.Creator) != 0 {
  75. for _, i := range UserBot.Creator {
  76. if !InArray2(Data.CreatorBack, i) {
  77. Data.CreatorBack = append(Data.CreatorBack, i)
  78. }
  79. }
  80. }
  81. if len(UserBot.Seller) != 0 {
  82. for _, i := range UserBot.Seller {
  83. if !InArray2(Data.SellerBack, i) {
  84. Data.SellerBack = append(Data.SellerBack, i)
  85. }
  86. }
  87. }
  88. if len(UserBot.Buyer) != 0 {
  89. for _, i := range UserBot.Buyer {
  90. if !InArray2(Data.BuyerBack, i) {
  91. Data.BuyerBack = append(Data.BuyerBack, i)
  92. }
  93. }
  94. }
  95. if len(UserBot.Owner) != 0 {
  96. for _, i := range UserBot.Owner {
  97. if !InArray2(Data.OwnerBack, i) {
  98. Data.OwnerBack = append(Data.OwnerBack, i)
  99. }
  100. }
  101. }
  102. if len(UserBot.Master) != 0 {
  103. for _, i := range UserBot.Master {
  104. if !InArray2(Data.MasterBack, i) {
  105. Data.MasterBack = append(Data.MasterBack, i)
  106. }
  107. }
  108. }
  109. if len(UserBot.Admin) != 0 {
  110. for _, i := range UserBot.Admin {
  111. if !InArray2(Data.AdminBack, i) {
  112. Data.AdminBack = append(Data.AdminBack, i)
  113. }
  114. }
  115. }
  116. if len(UserBot.Bot) != 0 {
  117. for _, i := range UserBot.Bot {
  118. if !InArray2(Data.BotBack, i) {
  119. Data.BotBack = append(Data.BotBack, i)
  120. }
  121. }
  122. }
  123. if len(Data.GbanBack) != 0 {
  124. for to := range Data.GbanBack {
  125. Room := oop.GetRoom(to)
  126. if len(Room.Gban) != 0 {
  127. for _, i := range Room.Gban {
  128. if MemUser(to, i) {
  129. if !InArray2(Data.GbanBack[to], i) {
  130. Data.GbanBack[to] = append(Data.GbanBack[to], i)
  131. }
  132. }
  133. }
  134. }
  135. }
  136. }
  137. if len(Data.GownerBack) != 0 {
  138. for to := range Data.GownerBack {
  139. Room := oop.GetRoom(to)
  140. if len(Room.Gowner) != 0 {
  141. for _, i := range Room.Gowner {
  142. if !InArray2(Data.GownerBack[to], i) {
  143. Data.GownerBack[to] = append(Data.GownerBack[to], i)
  144. }
  145. }
  146. }
  147. }
  148. }
  149. if len(Data.GadminBack) != 0 {
  150. for to := range Data.GadminBack {
  151. Room := oop.GetRoom(to)
  152. if len(Room.Gadmin) != 0 {
  153. for _, i := range Room.Gadmin {
  154. if !InArray2(Data.GadminBack[to], i) {
  155. Data.GadminBack[to] = append(Data.GadminBack[to], i)
  156. }
  157. }
  158. }
  159. }
  160. }
  161. if len(Banned.Banlist) != 0 {
  162. for _, i := range Banned.Banlist {
  163. if MemAccsess(i) {
  164. if !InArray2(Data.BanBack, i) {
  165. Data.BanBack = append(Data.BanBack, i)
  166. }
  167. }
  168. }
  169. }
  170. if len(Banned.Fucklist) != 0 {
  171. for _, i := range Banned.Fucklist {
  172. if MemAccsess(i) {
  173. if !InArray2(Data.FuckBack, i) {
  174. Data.FuckBack = append(Data.FuckBack, i)
  175. }
  176. }
  177. }
  178. }
  179. if len(Banned.Mutelist) != 0 {
  180. for _, i := range Banned.Mutelist {
  181. if MemAccsess(i) {
  182. if !InArray2(Data.MuteBack, i) {
  183. Data.MuteBack = append(Data.MuteBack, i)
  184. }
  185. }
  186. }
  187. }
  188. fmt.Println("done save Data *__*")
  189. SaveData()
  190. }
  191. func Checkkickuser(group string, user string, invited string) bool {
  192. Room := oop.GetRoom(group)
  193. if InArray2(MAKERS, invited) {
  194. if !InArray2(MAKERS, user) {
  195. return true
  196. }
  197. } else if UserBot.GetCreator(invited) {
  198. if !SendMycreator(user) && !Allbotlist(user) {
  199. return true
  200. }
  201. } else if UserBot.GetSeller(invited) {
  202. if !SendMyseller(user) && !Allbotlist(user) {
  203. return true
  204. }
  205. } else if UserBot.GetBuyer(invited) {
  206. if !SendMybuyer(user) && !Allbotlist(user) {
  207. return true
  208. }
  209. } else if UserBot.GetOwner(invited) {
  210. if !SendMyowner(user) && !Allbotlist(user) {
  211. return true
  212. }
  213. } else if UserBot.GetMaster(invited) {
  214. if !SendMymaster(user) && !Allbotlist(user) {
  215. return true
  216. }
  217. } else if UserBot.GetAdmin(invited) {
  218. if !SendMyadmin(user) && !Allbotlist(user) {
  219. return true
  220. }
  221. } else if InArray2(Room.Gowner, invited) {
  222. if !SendMygowner(group, user) && !Allbotlist(user) {
  223. return true
  224. }
  225. } else if InArray2(Room.Gadmin, invited) {
  226. if MemUser(group, user) {
  227. return true
  228. }
  229. } else if UserBot.GetBot(invited) {
  230. if MemUser(group, user) {
  231. return true
  232. }
  233. }
  234. return false
  235. }
  236. func MemUser(group string, from string) bool {
  237. Room := oop.GetRoom(group)
  238. if InArray2(Squadlist, from) {
  239. return false
  240. } else if UserBot.GetBot(from) {
  241. return false
  242. } else if InArray2(MAKERS, from) {
  243. return false
  244. } else if UserBot.GetCreator(from) {
  245. return false
  246. } else if UserBot.GetSeller(from) {
  247. return false
  248. } else if UserBot.GetBuyer(from) {
  249. return false
  250. } else if UserBot.GetOwner(from) {
  251. return false
  252. } else if UserBot.GetMaster(from) {
  253. return false
  254. } else if UserBot.GetAdmin(from) {
  255. return false
  256. } else if InArray2(Room.Gowner, from) {
  257. return false
  258. } else if InArray2(Room.Gadmin, from) {
  259. return false
  260. }
  261. return true
  262. }
  263. func MemAccsess(from string) bool {
  264. if InArray2(Squadlist, from) {
  265. return false
  266. } else if UserBot.GetBot(from) {
  267. return false
  268. } else if InArray2(MAKERS, from) {
  269. return false
  270. } else if UserBot.GetCreator(from) {
  271. return false
  272. } else if UserBot.GetSeller(from) {
  273. return false
  274. } else if UserBot.GetBuyer(from) {
  275. return false
  276. } else if UserBot.GetOwner(from) {
  277. return false
  278. } else if UserBot.GetMaster(from) {
  279. return false
  280. } else if UserBot.GetAdmin(from) {
  281. return false
  282. }
  283. return true
  284. }
  285. func MemUserN(group string, from string) bool {
  286. Room := oop.GetRoom(group)
  287. if UserBot.GetBot(from) {
  288. return false
  289. } else if InArray2(MAKERS, from) {
  290. return false
  291. } else if UserBot.GetCreator(from) {
  292. return false
  293. } else if UserBot.GetSeller(from) {
  294. return false
  295. } else if UserBot.GetBuyer(from) {
  296. return false
  297. } else if UserBot.GetOwner(from) {
  298. return false
  299. } else if UserBot.GetMaster(from) {
  300. return false
  301. } else if UserBot.GetAdmin(from) {
  302. return false
  303. } else if InArray2(Room.Gowner, from) {
  304. return false
  305. } else if InArray2(Room.Gadmin, from) {
  306. return false
  307. }
  308. return true
  309. }
  310. func Allbotlist(user string) bool {
  311. if InArray2(Squadlist, user) {
  312. return true
  313. } else if UserBot.GetBot(user) {
  314. return true
  315. }
  316. return false
  317. }
  318. func Upsetcmd(text string, text2 string) string {
  319. count := 0
  320. if text == "rollcall" {
  321. Commands.Botname = text2
  322. count = count + 1
  323. } else if text == "upallimage" {
  324. Commands.Upallimage = text2
  325. count = count + 1
  326. } else if text == "upallcover" {
  327. Commands.Upallcover = text2
  328. count = count + 1
  329. } else if text == "unsend" {
  330. Commands.Unsend = text2
  331. count = count + 1
  332. } else if text == "upvallimage" {
  333. Commands.Upvallimage = text2
  334. count = count + 1
  335. } else if text == "upvallcover" {
  336. Commands.Upvallcover = text2
  337. count = count + 1
  338. } else if text == "appname" {
  339. Commands.Appname = text2
  340. count = count + 1
  341. } else if text == "useragent" {
  342. Commands.Useragent = text2
  343. count = count + 1
  344. } else if text == "hostname" {
  345. Commands.Hostname = text2
  346. count = count + 1
  347. } else if text == "friends" {
  348. Commands.Friends = text2
  349. count = count + 1
  350. } else if text == "adds" {
  351. Commands.Adds = text2
  352. count = count + 1
  353. } else if text == "limits" {
  354. Commands.Limits = text2
  355. count = count + 1
  356. } else if text == "addallbots" {
  357. Commands.Addallbots = text2
  358. count = count + 1
  359. } else if text == "addallsquads" {
  360. Commands.Addallsquads = text2
  361. count = count + 1
  362. } else if text == "leave" {
  363. Commands.Leave = text2
  364. count = count + 1
  365. } else if text == "respon" {
  366. Commands.Respon = text2
  367. count = count + 1
  368. } else if text == "ping" {
  369. Commands.Ping = text2
  370. count = count + 1
  371. } else if text == "count" {
  372. Commands.Count = text2
  373. count = count + 1
  374. } else if text == "limitout" {
  375. Commands.Limitout = text2
  376. count = count + 1
  377. } else if text == "access" {
  378. Commands.Access = text2
  379. count = count + 1
  380. } else if text == "allbanlist" {
  381. Commands.Allbanlist = text2
  382. count = count + 1
  383. } else if text == "allgaccess" {
  384. Commands.Allgaccess = text2
  385. count = count + 1
  386. } else if text == "gaccess" {
  387. Commands.Gaccess = text2
  388. count = count + 1
  389. } else if text == "checkram" {
  390. Commands.Checkram = text2
  391. count = count + 1
  392. } else if text == "upimage" {
  393. Commands.Upimage = text2
  394. count = count + 1
  395. } else if text == "upcover" {
  396. Commands.Upcover = text2
  397. count = count + 1
  398. } else if text == "upvimage" {
  399. Commands.Upvimage = text2
  400. count = count + 1
  401. } else if text == "upvcover" {
  402. Commands.Upvcover = text2
  403. count = count + 1
  404. } else if text == "Purgeall" {
  405. Commands.Purgeall = text2
  406. count = count + 1
  407. } else if text == "banlist" {
  408. Commands.Banlist = text2
  409. count = count + 1
  410. } else if text == "clearban" {
  411. Commands.Clearban = text2
  412. count = count + 1
  413. } else if text == "bringall" {
  414. Commands.Bringall = text2
  415. count = count + 1
  416. } else if text == "stayall" {
  417. Commands.Stayall = text2
  418. count = count + 1
  419. } else if text == "clearchat" {
  420. Commands.Clearchat = text2
  421. count = count + 1
  422. } else if text == "here" {
  423. Commands.Here = text2
  424. count = count + 1
  425. } else if text == "speed" {
  426. Commands.Speed = text2
  427. count = count + 1
  428. } else if text == "status" {
  429. Commands.Status = text2
  430. count = count + 1
  431. } else if text == "tagall" {
  432. Commands.Tagall = text2
  433. count = count + 1
  434. } else if text == "kick" {
  435. Commands.Kick = text2
  436. count = count + 1
  437. } else if text == "max" {
  438. Commands.Max = text2
  439. count = count + 1
  440. } else if text == "none" {
  441. Commands.None = text2
  442. count = count + 1
  443. } else if text == "kickall" {
  444. Commands.Kickall = text2
  445. count = count + 1
  446. } else if text == "cancelall" {
  447. Commands.Cancelall = text2
  448. count = count + 1
  449. }
  450. if count != 0 {
  451. kowe := text
  452. jancuk := text2
  453. newsend := "Changed cmd: " + kowe + " to " + jancuk + "\n"
  454. return newsend
  455. }
  456. return ""
  457. }
  458. ////NEW
  459. func kickPelaku(client *oop.Account, to, pelaku string) {
  460. defer panicHandle("kickPelaku")
  461. runtime.GOMAXPROCS(cpu)
  462. Room := oop.GetRoom(to)
  463. _, memlist := client.GetGroupMember(to)
  464. exe := []*oop.Account{}
  465. oke := []string{}
  466. for mid, _ := range memlist {
  467. if InArray2(Squadlist, mid) {
  468. cl := GetKorban(mid)
  469. if cl.Limited == false {
  470. exe = append(exe, cl)
  471. }
  472. oke = append(oke, mid)
  473. }
  474. }
  475. if len(exe) != 0 {
  476. sort.Slice(exe, func(i, j int) bool {
  477. return exe[i].KickPoint < exe[j].KickPoint
  478. })
  479. Room.HaveClient = exe
  480. if _, ok := memlist[pelaku]; ok {
  481. exe[0].DeleteOtherFromChats(to, pelaku)
  482. }
  483. }
  484. oop.SetAva(to, oke)
  485. }
  486. func addwl(g string, w []string) {
  487. for _, mid := range w {
  488. if !MemBan(g, mid) {
  489. if !InArray2(Whitelist, mid) && MemUser(g, mid) {
  490. Whitelist = append(Whitelist, mid)
  491. }
  492. }
  493. }
  494. }
  495. func CancelProtect(client *oop.Account, mem []string, to string) {
  496. defer panicHandle("cancelall")
  497. runtime.GOMAXPROCS(cpu)
  498. Room := oop.GetRoom(to)
  499. cans := Room.HaveClient
  500. no := 0
  501. ah := 0
  502. if len(mem) > 50 {
  503. mem = mem[:50]
  504. }
  505. for _, target := range mem {
  506. go func(target string, no int) {
  507. cans[no].CancelChatInvitations(to, target)
  508. }(target, no)
  509. if ah >= MaxCancel {
  510. no++
  511. if no >= len(cans) {
  512. no = 0
  513. }
  514. ah = 0
  515. }
  516. ah++
  517. }
  518. }
  519. func cancelall(client *oop.Account, mem []string, to string) {
  520. defer panicHandle("cancelall")
  521. runtime.GOMAXPROCS(cpu)
  522. Room := oop.GetRoom(to)
  523. cans := Room.HaveClient
  524. no := 0
  525. ah := 0
  526. if len(mem) > 50 {
  527. mem = mem[:50]
  528. }
  529. for _, target := range mem {
  530. go func(target string, no int) {
  531. cans[no].CancelChatInvitations(to, target)
  532. }(target, no)
  533. if ah >= MaxCancel {
  534. no++
  535. if no >= len(cans) {
  536. no = 0
  537. }
  538. ah = 0
  539. }
  540. ah++
  541. }
  542. }
  543. func getfuck(cl *oop.Account, vo string, Group string) {
  544. defer panicHandle("getfuck")
  545. runtime.GOMAXPROCS(cpu)
  546. if MemBan(Group, vo) {
  547. cl.CancelChatInvitations(Group, vo)
  548. }
  549. }
  550. func cancelallcek(client *oop.Account, mem []string, to string) {
  551. defer panicHandle("cancelallcek")
  552. runtime.GOMAXPROCS(cpu)
  553. Room := oop.GetRoom(to)
  554. _, memlist := client.GetGroupMember(to)
  555. Cans := []*oop.Account{}
  556. oke := []string{}
  557. for mid, _ := range memlist {
  558. if InArray2(Squadlist, mid) {
  559. cl := GetKorban(mid)
  560. if cl.Limited == false {
  561. Cans = append(Cans, cl)
  562. }
  563. oke = append(oke, mid)
  564. }
  565. }
  566. if len(Cans) != 0 {
  567. sort.Slice(Cans, func(i, j int) bool {
  568. return Cans[i].KickPoint < Cans[j].KickPoint
  569. })
  570. Room.HaveClient = Cans
  571. no := 0
  572. ah := 0
  573. for _, target := range mem {
  574. go getfuck(Cans[no], target, to)
  575. if ah >= MaxCancel {
  576. no++
  577. if no >= len(Cans) {
  578. no = 0
  579. }
  580. ah = 0
  581. }
  582. ah++
  583. }
  584. }
  585. }
  586. func groupBackupKick(client *oop.Account, to, pelaku string, cek bool) {
  587. defer panicHandle("groupBackup")
  588. runtime.GOMAXPROCS(cpu)
  589. Room := oop.GetRoom(to)
  590. memlist, _ := client.GetChatListMap(to)
  591. ban := []string{}
  592. exe := []*oop.Account{}
  593. for mid, _ := range memlist {
  594. if InArray2(Squadlist, mid) {
  595. cl := GetKorban(mid)
  596. if cl.Limited == false {
  597. exe = append(exe, cl)
  598. }
  599. } else if MemBan(to, mid) {
  600. ban = append(ban, mid)
  601. }
  602. }
  603. if len(exe) != 0 {
  604. sort.Slice(exe, func(i, j int) bool {
  605. return exe[i].KickPoint < exe[j].KickPoint
  606. })
  607. Room.HaveClient = exe
  608. if Killmode != "none" && AutoBan && cek {
  609. if Killmode == "kill" {
  610. kill := exe[0].GetSameJoiningTime(to, pelaku)
  611. for _, i := range kill {
  612. if MemUser(to, i) && !InArray2(ban, i) {
  613. Banned.AddBan(i)
  614. ban = append(ban, i)
  615. }
  616. }
  617. }
  618. no := 0
  619. ah := 0
  620. for _, target := range ban {
  621. go func(target string, no int) {
  622. exe[no].DeleteOtherFromChats(to, target)
  623. }(target, no)
  624. if ah >= MaxKick {
  625. no++
  626. if no >= len(exe) {
  627. no = 0
  628. }
  629. ah = 0
  630. }
  631. ah++
  632. }
  633. } else {
  634. if _, ok := memlist[pelaku]; ok {
  635. exe[0].DeleteOtherFromChats(to, pelaku)
  636. }
  637. }
  638. }
  639. }
  640. func deljoin(user string) {
  641. for _, us := range opjoin {
  642. if us == user {
  643. opjoin = Remove(opjoin, user)
  644. }
  645. }
  646. }
  647. func groupBackupInv(client *oop.Account, to string, optime int64, korban string) {
  648. runtime.GOMAXPROCS(cpu)
  649. defer panicHandle("groupBackupInv")
  650. memlist, _ := client.GetChatListMap(to)
  651. exe := []*oop.Account{}
  652. oke := []string{}
  653. for mid, _ := range memlist {
  654. if InArray2(Squadlist, mid) {
  655. cl := GetKorban(mid)
  656. if cl.Limited == false {
  657. exe = append(exe, cl)
  658. }
  659. oke = append(oke, mid)
  660. }
  661. }
  662. ClAct := len(exe)
  663. if ClAct != 0 {
  664. sort.Slice(exe, func(i, j int) bool {
  665. return exe[i].KickPoint < exe[j].KickPoint
  666. })
  667. if ModeBackup == "invite" {
  668. exe[0].InviteIntoGroupNormal(to, []string{korban})
  669. }
  670. }
  671. oop.SetAva(to, oke)
  672. }
  673. func getBot(client *oop.Account, to string) []*oop.Account {
  674. _, memlist := client.GetGroupMember(to)
  675. exe := []*oop.Account{}
  676. for mid, _ := range memlist {
  677. if InArray2(Squadlist, mid) {
  678. cl := GetKorban(mid)
  679. if cl.Limited == false {
  680. exe = append(exe, cl)
  681. }
  682. }
  683. }
  684. sort.Slice(exe, func(i, j int) bool {
  685. return exe[i].KickPoint < exe[j].KickPoint
  686. })
  687. oop.GetRoom(to).HaveClient = exe
  688. return exe
  689. }
  690. func AddContact2(cl *oop.Account, con string) int {
  691. fl, _ := cl.GetAllContactIds()
  692. if !InArray2(fl, con) {
  693. if con != cl.MID && !cl.Limitadd {
  694. _, err := cl.FindAndAddContactsByMidnew(con)
  695. if err != nil {
  696. println(fmt.Sprintf("%v", err.Error()))
  697. return 0
  698. }
  699. return 1
  700. } else {
  701. return 0
  702. }
  703. }
  704. return 1
  705. }
  706. func kickDirt(client *oop.Account, to, pelaku string) {
  707. runtime.GOMAXPROCS(cpu)
  708. cans := oop.Actor(to)
  709. for _, cl := range cans {
  710. if oop.GetRoom(to).Act(cl) {
  711. in := cl.DeleteOtherFromChat(to, pelaku)
  712. if in == 35 || in == 10 {
  713. continue
  714. } else {
  715. break
  716. }
  717. }
  718. }
  719. }
  720. func CekPurge(optime int64) bool {
  721. defer oop.PanicOnly()
  722. for _, tar := range PurgeOP {
  723. if tar == optime {
  724. return false
  725. }
  726. }
  727. PurgeOP = append(PurgeOP, optime)
  728. return true
  729. }
  730. func cekjoin(optime string) bool {
  731. defer oop.PanicOnly()
  732. for _, tar := range opjoin {
  733. if tar == optime {
  734. return false
  735. }
  736. }
  737. opjoin = append(opjoin, optime)
  738. return true
  739. }
  740. func cekOp2(optime int64) bool {
  741. for _, tar := range cekoptime {
  742. if tar == optime {
  743. return false
  744. }
  745. }
  746. cekoptime = append(cekoptime, optime)
  747. return true
  748. }
  749. // here func getKey
  750. func LogFight(room *oop.LineRoom) {
  751. defer panicHandle("logfight")
  752. if LogMode {
  753. var tx = ""
  754. for i := 0; i < len(ClientBot); i++ {
  755. exe := ClientBot[i]
  756. if !exe.Frez {
  757. g, err := exe.GetGroupMember(room.Id)
  758. if err != nil {
  759. continue
  760. } else {
  761. room.Name = g
  762. break
  763. }
  764. }
  765. }
  766. tx += fmt.Sprintf("Squad action's in Group:\n%s\n", room.Name)
  767. if room.Kick != 0 {
  768. tx += fmt.Sprintf("\nKick's: %v", room.Kick)
  769. }
  770. if room.Invite != 0 {
  771. tx += fmt.Sprintf("\nInvite's: %v", room.Invite)
  772. }
  773. if room.Cancel != 0 {
  774. tx += fmt.Sprintf("\nCancel's: %v", room.Cancel)
  775. }
  776. if room.Kick == 0 && room.Invite == 0 && room.Cancel == 0 {
  777. room.Kick = 0
  778. room.Invite = 0
  779. room.Cancel = 0
  780. return
  781. }
  782. room := oop.GetRoom(LogGroup)
  783. if len(room.Client) != 0 {
  784. exe, err := SelectBot(room.Client[0], LogGroup)
  785. if err == nil {
  786. if exe != nil {
  787. exe.SendMessage(LogGroup, tx)
  788. }
  789. } else {
  790. LogMode = false
  791. LogGroup = ""
  792. }
  793. }
  794. }
  795. room.Kick = 0
  796. room.Invite = 0
  797. room.Cancel = 0
  798. }