init.go 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142
  1. package main
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "io/ioutil"
  6. "log"
  7. "math/rand"
  8. "net"
  9. "os"
  10. "os/signal"
  11. "strconv"
  12. "syscall"
  13. "time"
  14. talkservice "github.com/bashery/linethrift"
  15. "github.com/bashery/botline/hashmap"
  16. "github.com/bashery/botline/oop"
  17. )
  18. func getArg() string {
  19. args := os.Args
  20. if len(os.Args) <= 1 {
  21. fmt.Println("\033[0;31m not enoght args")
  22. fmt.Println("\033[37m try :\n\t \033[33m <app-name> <arg>")
  23. fmt.Println("\033[37m for example:\n\t \033[33m ./botline dir-name")
  24. fmt.Println("\033[37m or\n\t \033[33m go run *go dir-name", "")
  25. os.Exit(0)
  26. }
  27. return args[1]
  28. }
  29. var (
  30. GO = getArg()
  31. Whitelist = []string{}
  32. SetHelper = &oop.Helper{Rngcmd: make(map[string]int)}
  33. DB *DATA
  34. ClientBot []*oop.Account
  35. Midlist []string
  36. aclear = time.Now()
  37. Grupas []*talkservice.Group
  38. Poll *oop.Account
  39. Self *oop.Account
  40. cpu int
  41. botleave = &hashmap.HashMap{}
  42. changepic []*oop.Account
  43. timeabort = time.Now()
  44. TimeSave = time.Now()
  45. Laststicker = &hashmap.HashMap{}
  46. ChangCover = false
  47. MsgRespon = "๐ˆ'๐ฆ ๐‡๐ž๐ซ๐ž ๐๐จ๐ฌ๐ฌ..."
  48. MsgBan = "Cleared %v blacklist."
  49. MsFresh = " โœ“"
  50. MsLimit = " โœ˜"
  51. MsSname = "."
  52. MsRname = "bot"
  53. AllCheng = false
  54. Lastleave = &hashmap.HashMap{}
  55. ChangPict = false
  56. ChangName = false
  57. AutokickBan = false
  58. ChangVpict = false
  59. ChangVcover = false
  60. ChangeBio = false
  61. CmdHelper = &hashmap.HashMap{}
  62. cewel = &hashmap.HashMap{}
  63. cleave = &hashmap.HashMap{}
  64. NukeJoin = false
  65. AutoBan = false
  66. canceljoin = false
  67. Autojoin = "off"
  68. backlist = &hashmap.HashMap{}
  69. cekoptime = []int64{}
  70. Ceknuke = &hashmap.HashMap{}
  71. Cekstaybot = &hashmap.HashMap{}
  72. Commands = &oop.Command{}
  73. Waitlistin = map[string][]string{}
  74. AutoproN = false
  75. LogMode = false
  76. LogGroup = ""
  77. delayed = 10 * time.Second
  78. MsgBio = ""
  79. MsgName = ""
  80. StartChangeImg = false
  81. StartChangevImg = false
  82. StartChangevImg2 = false
  83. AutoPro = true
  84. Command = &hashmap.HashMap{}
  85. tempginv = []string{}
  86. remotegrupidto = ""
  87. ModeBackup = "invite"
  88. checkHaid = []string{}
  89. botStart = time.Now()
  90. TimeBackup = time.Now()
  91. oplist = []int64{}
  92. oplistinvite = []int64{}
  93. PurgeOP = []int64{}
  94. oplistjoin = []int64{}
  95. AutoPurge = true
  96. ClientMid = map[string]*oop.Account{}
  97. Squadlist = []string{}
  98. argsRaw = os.Args
  99. Sinderremote = []string{}
  100. StartChangeVideo = false
  101. tempgroup = []string{}
  102. Lastinvite = &hashmap.HashMap{}
  103. Lastkick = &hashmap.HashMap{}
  104. Lastjoin = &hashmap.HashMap{}
  105. Lastcancel = &hashmap.HashMap{}
  106. Nkick = &hashmap.HashMap{}
  107. Lastupdate = &hashmap.HashMap{}
  108. Lastmid = &hashmap.HashMap{}
  109. filterop = &hashmap.HashMap{}
  110. Lasttag = &hashmap.HashMap{}
  111. Lastcon = &hashmap.HashMap{}
  112. Commandss = &hashmap.HashMap{}
  113. Detectjoin = &oop.SaveJoin{}
  114. Banned = &oop.BanUser{Banlist: []string{}, Fucklist: []string{}, Mutelist: []string{}}
  115. UserBot = &oop.Access{Creator: []string{}, Seller: []string{}, Buyer: []string{}, Owner: []string{}, Master: []string{}, Admin: []string{}, Bot: []string{}}
  116. timeSend = []int64{}
  117. opjoin = []string{}
  118. Cekpurge = []int64{}
  119. MaxCancel = 50
  120. MaxKick = 50
  121. cekGo = []int64{}
  122. UpdatePicture = map[string]bool{}
  123. UpdateCover = map[string]bool{}
  124. UpdateVProfile = map[string]bool{}
  125. UpdateVCover = map[string]bool{}
  126. Qrwar = false
  127. filterWar = &kickop{Kick: []string{}, Inv: []string{}, Opinv: []int64{}}
  128. ColorCyan = "\033[36m"
  129. ColorReset = "\033[0m"
  130. Data DATA
  131. remotegrupid = ""
  132. LastActive = &hashmap.HashMap{}
  133. used = ""
  134. IPServer string
  135. Killmode = "kill"
  136. filtermsg = &hashmap.HashMap{}
  137. Opinvite = []int64{}
  138. stringToInt = []rune("01")
  139. DATABASE = "db/" + getArg() + ".json"
  140. MAKERS = []string{"u27603a2c021c18746b7aa34e3d2b2220", "u9ef25059bb2e71a0834fb3b2cadd6297", "u7b566e01279ac3dcf0108e8248b67e41"}
  141. HostName = []string{
  142. "legy-jp-long",
  143. }
  144. carierMap = map[string]string{
  145. "IOSIPAD": "51089, 1-0",
  146. "IOS": "51089, 1-0",
  147. "ANDROIDLITE": "51000",
  148. "ANDROID": "51010",
  149. "CHROMEOS": "",
  150. "DESKTOPMAC": "",
  151. "DESKTOPWIN": "",
  152. "CHANNELCP": "51010",
  153. }
  154. helppro = []string{
  155. "Allowall",
  156. "Allow invite",
  157. "Allow kick",
  158. "Allow cancel",
  159. "Allow join",
  160. "Allow link",
  161. "Allow name",
  162. "Denyall",
  163. "Deny invite",
  164. "Deny kick",
  165. "Deny cancel",
  166. "Deny join",
  167. "Deny link",
  168. "Deny name",
  169. "Protect max",
  170. "Protect none",
  171. }
  172. ListIp = []string{
  173. "172.105.226.94",
  174. "",
  175. }
  176. helpmaker = []string{
  177. "Addallbots",
  178. "Addallsquads",
  179. "Addday",
  180. "Addmonth",
  181. "Addyear",
  182. "Appname",
  183. "Buyer",
  184. "Creator",
  185. "Creators",
  186. "Clearbuyer",
  187. "Clearcreator",
  188. "Clearfriend",
  189. "Clearseller",
  190. "Expel",
  191. "Friends",
  192. "Hostname",
  193. "Reboot",
  194. "Unbuyer",
  195. "Uncreator",
  196. "Unfriend",
  197. "Upallcover",
  198. "Upallimage",
  199. "Upallname",
  200. "Upallstatus",
  201. "Upvallcover",
  202. "Upvallimage",
  203. "Useragent",
  204. "Setdate",
  205. }
  206. helpbuyer = []string{
  207. "About",
  208. "Access",
  209. "Accept",
  210. "Acceptall",
  211. "Adds",
  212. "Autoban",
  213. "Autojoin",
  214. "Autopro",
  215. "Autopurge",
  216. "Banpurge",
  217. "Backup",
  218. "Bot",
  219. "Botlist",
  220. "Buyers",
  221. "Cancelall",
  222. "Canceljoin",
  223. "Clearallprotect",
  224. "Clearban",
  225. "Clearbot",
  226. "Clearbuyer",
  227. "Clearowner",
  228. "Clearmaster",
  229. "Clearadmin",
  230. "Clearfuck",
  231. "Clearhide",
  232. "Clearlistcmd",
  233. "Clearmute",
  234. "Clone:",
  235. "Decline",
  236. "Declineall",
  237. "Expel",
  238. "Friends",
  239. "Friendlist",
  240. "Gleave",
  241. "Gourl",
  242. "Groupcast",
  243. "Groups",
  244. "Groupinfo:",
  245. "Hide",
  246. "Hidelist",
  247. "Invme",
  248. "Joinqrkick:",
  249. "Kickall",
  250. "Leaveall",
  251. "List protect",
  252. "Msgclearban",
  253. "Msglimit",
  254. "Msglurk",
  255. "Msgrespon",
  256. "Msgstatus",
  257. "Nukejoin",
  258. "Owner",
  259. "Perm",
  260. "Permlist:",
  261. "Refresh",
  262. "Remote",
  263. "Stats",
  264. "Setcancel",
  265. "setlogo",
  266. "Setkick",
  267. "Setlimiter",
  268. "Setrname",
  269. "Setsname",
  270. "Statusall",
  271. "Timeleft",
  272. "Unbot",
  273. "Unhide",
  274. "Unowner",
  275. "Upcover",
  276. "Upimage",
  277. "upgname",
  278. "Upname",
  279. "Upstatus",
  280. "Upvcover",
  281. "Upvimage",
  282. }
  283. helpowner = []string{
  284. "Allbanlist",
  285. "Allgaccess",
  286. "Antitag",
  287. "Bringall",
  288. "Clearcache",
  289. "Clearchat",
  290. "Cleargban",
  291. "Cleargowner",
  292. "Contactsquad",
  293. "Expel",
  294. "Fixed",
  295. "Fuck",
  296. "Fucklist",
  297. "Joinqr:",
  298. "Killmode:",
  299. "Leave",
  300. "Limits",
  301. "Limitout",
  302. "Listcmd",
  303. "Master",
  304. "Owners",
  305. "Purgeall",
  306. "Purgeallbans:",
  307. "Runtime",
  308. "Set",
  309. "Setcmd",
  310. "Sendimage",
  311. "Squadmid",
  312. "Status",
  313. "Stay",
  314. "Timenow",
  315. "Unfuck",
  316. "Unmaster",
  317. }
  318. helpmaster = []string{
  319. "Admin",
  320. "Announce",
  321. "Ban",
  322. "Banlist",
  323. "Bans",
  324. "Bring",
  325. "Cleargadmin",
  326. "Contact",
  327. "Count",
  328. "Curl",
  329. "Expel",
  330. "Go",
  331. "Gojoin",
  332. "Gowner",
  333. "Hostage",
  334. "Leave on/off",
  335. "Masters",
  336. "Msgleave",
  337. "Msgwelcome",
  338. "Mute",
  339. "Mutelist",
  340. "Ourl",
  341. "Rollcall",
  342. "Sayall",
  343. "Settings",
  344. "Speed",
  345. "Unadmin",
  346. "Unban",
  347. "Ungowner",
  348. "Unmute",
  349. "Unsend",
  350. "Welcome on/off",
  351. "Whois",
  352. }
  353. helpadmin = []string{
  354. "Abort",
  355. "Admins",
  356. "Allow all",
  357. "Allow invite",
  358. "Allow kick",
  359. "Allow cancel",
  360. "Allow join",
  361. "Allow link",
  362. "Allow name",
  363. "Bio",
  364. "Cancel",
  365. "Cover",
  366. "Deny all",
  367. "Deny invite",
  368. "Deny kick",
  369. "Deny cancel",
  370. "Deny link",
  371. "Deny name",
  372. "Expel",
  373. "Gaccess",
  374. "Gadmin",
  375. "Gban",
  376. "Gbanlist",
  377. "Gadmins",
  378. "Here",
  379. "Image",
  380. "Invite",
  381. "Kick",
  382. "vKick",
  383. "Lcon",
  384. "Linvite",
  385. "Lkick",
  386. "Lcancel",
  387. "Lleave",
  388. "Ljoin",
  389. "Lmid",
  390. "Ltag",
  391. "Lurk name",
  392. "Lurk mention",
  393. "Lurk hide",
  394. "Lurk on/off",
  395. "Lurks",
  396. "Mid",
  397. "Max",
  398. "None",
  399. "Name",
  400. "Ping",
  401. "Prefix",
  402. "Protect max",
  403. "Protect none",
  404. "Respon",
  405. "Rname",
  406. "Sname",
  407. "Say",
  408. "Tag",
  409. "Tagall",
  410. "Ungadmin",
  411. "Ungban",
  412. }
  413. details = map[string]string{
  414. "shutdown": "'%s%s'\n\nShutting down the bot's.",
  415. "perm": "'%s%s .<grade>.<command>'\n\nAvailable grade buyer/owner/master/admin",
  416. "nukejoin": "'%s%s' on/off\nkickall member's while bot has invited..",
  417. "announce": "'%s%s on/off'\n\nEnable detect announce.",
  418. "hostage": "'%s%s on/off'\n\nEnable auto invite leave member.",
  419. "accept": "'%s%s <number>'\n\nAccept group invitation by number.",
  420. "reject": "'%s%s <number>'\n\nReject group invitation by number.",
  421. "welcome": "'%s%s on/off'\n\nEnable welcome message.",
  422. "leave": "'%s%s on/off'\n\nEnable leave message.",
  423. "setcmd": "'%s%s <state> <command>'\n\nUsed to enabling/disabling command\nAvailable state lock/unlock/disable/enable.",
  424. "fixed": "'%s%s'\n\nIf bot's error, please use this command to autofix.",
  425. "logmode": "'%s%s <state>'\n\nUsed to see bot's activity.\nAvailable state on/off",
  426. "go": "'%s%s <number>'\n\nSet bot to stay on group invitation.\nDefault is 2 bot.",
  427. "unseller": "'%s%s <range/lcon/lkick/etc>'Used to expel seller.\nAvailable range '<', '>', '-', ',' with number.",
  428. "unbuyer": "'%s%s <range/lcon/lkick/etc>'Used to expel buyer.\nAvailable range '<', '>', '-', ',' with number.",
  429. "unowner": "'%s%s <range/lcon/lkick/etc>'Used to expel owner.\nAvailable range '<', '>', '-', ',' with number.",
  430. "unadmin": "'%s%s <range/lcon/lkick/etc>'Used to expel admin.\nAvailable range '<', '>', '-', ',' with number.",
  431. "unmaster": "'%s%s <range/lcon/lkick/etc>'Used to expel master.\nAvailable range '<', '>', '-', ',' with number.",
  432. "ungowner": "'%s%s <range/lcon/lkick/etc>'Used to expel gowner.\nAvailable range '<', '>', '-', ',' with number.",
  433. "ungadmin": "'%s%s <range/lcon/lkick/etc>'Used to expel gadmin.\nAvailable range '<', '>', '-', ',' with number.",
  434. "clearseller": "'%s%s'\n\nClearing all sellers.",
  435. "clearbuyer": "'%s%s'\n\nClearing all buyer list.",
  436. "clearowner": "'%s%s'\n\nClearing all owner list.",
  437. "clearmaster": "'%s%s'\n\nClearing all master list.",
  438. "clearadmin": "'%s%s'\n\nClearing all admin list.",
  439. "cleargadmin": "'%s%s'\n\nClearing all gadmin list.",
  440. "cleargowner": "'%s%s'\n\nClearing all gowner list.",
  441. "clearbot": "'%s%s'\n\nClearing all bot list.",
  442. "clearban": "'%s%s'\n\nClearing all ban list.",
  443. "clearfuck": "'%s%s'\n\nClearing all fuck list.",
  444. "clearmute": "'%s%s'\n\nClearing all mute list.",
  445. "cleargban": "'%s%s'\n\nClearing all gban list.",
  446. "clearchat": "'%s%s'\n\nClearing all squad messages.",
  447. "upvallimage": "'%s%s'\n\nUpdating all bot's video profile.",
  448. "upvimage": "'%s%s'\n\nUpdating all bot's video profile.",
  449. "upallimage": "'%s%s'\n\nUpdating all bot's picture profile.",
  450. "upimage": "'%s%s'\n\nUpdating bot's profile picture.",
  451. "upvallcover": "'%s%s'\n\nUpdating all bot's video cover.",
  452. "upvcover": "'%s%s @tag bot'\n\nUpdating bot's video cover.",
  453. "upcover": "'%s%s' @tag\n\nUpdating bot's cover picture.",
  454. "upallcover": "'%s%s'\n\nUpdating all bot's cover picture.",
  455. "upname": "'%s%s newname'\n\nUpdating bot's displayname.",
  456. "upallname": "'%s%s newname'\n\nUpdating all bot's displayname.",
  457. "leaveall": "'%s%s'\n\nleave all bot's from all group's.",
  458. "groups": "'%s%s'\n\nsee bot group's.",
  459. "stayall": "'%s%s'\n\naccepting all group invitation.",
  460. "setcom": "'%s%s .key .value'\n\nChange command.",
  461. "upstatus": "'%s%s <status message>'\n\nUpdating bot's profile bio.",
  462. "upallstatus": "'%s%s <status message>'\n\nUpdating all bot's profile bio.",
  463. "kick": "'%s%s @tag/lcon/lkick/etc'\n\nKick member's.",
  464. "prefix": "'%s%s on/off'\n\nEnable/disable prefix.",
  465. "list protect": "'%s%s'\n\nShow all protection group's.",
  466. "invme": "'%s%s gnumber'\n\nInvite user to the destination group.",
  467. "autojoin": "'%s%s qr/invite/off'\n\nForcing bot's to joinall while invited.",
  468. "autoban": "'%s%s on/off'\n\nAuto banned user.",
  469. "sellers": "'%s%s'\n\nShow seller list.",
  470. "buyers": "'%s%s'\n\nShow buyer list.",
  471. "owners": "'%s%s'\n\nShow owner list.",
  472. "masters": "'%s%s'\n\nShow master list.",
  473. "admins": "'%s%s'\n\nShow admin list.",
  474. "gowners": "'%s%s'\n\nShow gowner list.",
  475. "gadmins": "'%s%s'\n\nShow gadmin list.",
  476. "botlist": "'%s%s'\n\nShow bot list.",
  477. "banlist": "'%s%s'\n\nShow ban list.",
  478. "fucklist": "'%s%s'\n\nShow fuck list.",
  479. "mutelist": "'%s%s'\n\nShow mutelist list.",
  480. "gbanlist": "'%s%s'\n\nShow gban list.",
  481. "hides": "'%s%s'\n\nShow Invisible user.",
  482. "hide": "'%s%s @tag/lcon/lkick/etc'\n\nAdded user to invisible list.",
  483. "kickall": "'%s%s'\n\nKick all group member's.",
  484. "group info": "'%s%s'\n\nShow all group member's./pendings/access",
  485. "autopurge": "'%s%s on/off'\n\nEnable autopurge.",
  486. "lurk": "'%s%s on/off'\n\nEnable lurking mode.",
  487. "lurkmsg": "'%s%s <message>'\n\nSet lurk message.\nUse @! for placing user tagging.",
  488. "antitag": "'%s%s on/off'\n\nEnable antitag.",
  489. "killmode": "'%s%s kill/purge/on/off/range'\n\nKiller mode to kick all banlist/squad.",
  490. "autopro": "'%s%s on/off'\n\nAuto protect max while bot's join.",
  491. "setlimit": "'%s%s number'\n\nSet max kick in killmode /bot.",
  492. "stay": "'%s%s number'\n\nSet amount of bot's in group invite via link invitation.",
  493. "bringall": "'%s%s'\n\nBring all bot's by invitation.",
  494. "bring": "'%s%s number'\n\nSet amount of bot's in group via invitation.",
  495. "here": "'%s%s'\n\nShow amount of bot's in group.",
  496. "friends": "'%s%s'\n\nShow all bot's friends.",
  497. "msgrespon": "'%s%s respon'\n\nSet bot's response.",
  498. "msgwelcome": "'%s%s <message>'\n\nSet welcome message each group.\nParameter for changing need to adding @user for replacing username and @group for replacing groupname.",
  499. "setrname": "'%s%s newrname'\n\nChange the rname prefix.",
  500. "setsname": "'%s%s newsname'\n\nChange the sname prefix.",
  501. "invite": "'%s%s @tag/lcon/lkick/etc'\n\nInvite target to the group's.",
  502. "clone": "'%s%s @tag/lcon/lkick/etc @tagbot'\n\nCloning targte profile.",
  503. "gaccess": "'%s%s'\n\nSee all group access list.",
  504. "limitout": "'%s%s'\n\nLeave the kicbanned bot's.",
  505. "say": "'%s%s word'\n\nThe bot's would said the word.",
  506. "sayall": "'%s%s word'\n\nAll bot's would said the word.",
  507. "expel": "'%s%s @tag/lcon/lkick/etc'\n\nUsed to expel user access.",
  508. "respon": "'%s%s'\n\nBot response.",
  509. "ping": "'%s%s'\n\nBot response.",
  510. "permlist": "'%s%s key'\n\nGet the command value.",
  511. "settings": "'%s%s'\n\nShow the group preset status in group.",
  512. "set": "'%s%s'\n\nShow the bot's set.",
  513. "help": "'%s%s'\n\nShow the help command.",
  514. "deny": "'%s%s invite/kick/qr/join/cancel/off/all/max'\n\nEnable the protection.",
  515. "allow": "'%s%s invite/kick/qr/join/cancel/all'\n\nDisable the protection.",
  516. "ourl": "'%s%s'\n\nOpen group links.",
  517. "curl": "'%s%s'\n\nClose group links.",
  518. "mysquad": "'%s%s'\n\nSend squad contact's",
  519. "count": "'%s%s'\n\nShow bot's number.",
  520. "speed": "'%s%s'\n\nShow bot response speed.",
  521. "unsend": "'%s%s count'\n\nUnsend recent bot's message.\nIf count not definde, it would unsend all recent message.",
  522. "tagall": "'%s%s'\n\nTagging all member's.",
  523. "ftagall": "'%s%s'\n\nTagging all member's with sticker.",
  524. "access": "'%s%s'\n\nShow all bot access.",
  525. "bans": "'%s%s'\n\nShow the bot's status.",
  526. "runtime": "'%s%s'\n\nShiw the bot's time alive.",
  527. "timeleft": "'%s%s'\n\nShow the bot's timeleft.",
  528. "linvite": "'%s%s'\n\nShow the last invited in group.",
  529. "lkick": "'%s%s'\n\nShow the last kicked in group.",
  530. "lmid": "'%s%s'\n\nShow the last mid in group.",
  531. "lcon": "'%s%s'\n\nShow the last contact in group.",
  532. "ltag": "'%s%s'\n\nShow the last tag in group.",
  533. "lban": "'%s%s'\n\nShow the last banned in group.",
  534. "lcancel": "'%s%s'\n\nShow the last cancel in group.",
  535. "lqr": "'%s%s'\n\nShow the last upded qr in group.",
  536. "ljoin": "'%s%s'\n\nShow the last join in group.",
  537. "lleave": "'%s%s'\n\nShow the last leave in group.",
  538. "abort": "'%s%s'\n\nAborting command.",
  539. "groupcast": "'%s%s <your word>'\n\nBroadcasting message to all groups.",
  540. "contact": "'%s%s @tag/lcon/lkick/etc'\n\nUsed to get contact's.",
  541. "rollcall": "'%s%s'\n\nShow bot's name.",
  542. "gojoin": "'%s%s'\n\nJoining bot's from invitation list.",
  543. "mid": "'%s%s @tag/lcon/lkick/etc'\n\nGet midlist.",
  544. "name": "'%s%s @tag/lcon/lkick/etc'\n\nGet namelist.",
  545. "purgeall": "'%s%s'\n\nPurge all banlist in all group.",
  546. "squadmid": "'%s%s'\n\nShow all bots mid.",
  547. "whois": "'%s%s @tag/lcon/lkick/etc'\n\nSee user info.",
  548. "cancel": "'%s%s @tag/lcon/lkick/etc'\n\nCancel group invitation.",
  549. "remote": "'%s%s:'\n\nthe right number\nSee group number with command groups.\nExample:\n remote: 2 gmember.\nund send command.",
  550. }
  551. )
  552. type (
  553. mentions struct {
  554. MENTIONEES []struct {
  555. Start string `json:"S"`
  556. End string `json:"E"`
  557. Mid string `json:"M"`
  558. } `json:"MENTIONEES"`
  559. }
  560. kickop struct {
  561. Kick []string
  562. Inv []string
  563. Opinv []int64
  564. }
  565. Stickers struct {
  566. Id string
  567. Pid string
  568. }
  569. clustering struct {
  570. mem string
  571. tm int64
  572. fr []string
  573. }
  574. DATA struct {
  575. Authoken []string `json:"Authoken"`
  576. CreatorBack []string `json:"CreatorBack"`
  577. BuyerBack []string `json:"BuyerBack"`
  578. OwnerBack []string `json:"OwnerBack"`
  579. MasterBack []string `json:"MasterBack"`
  580. AdminBack []string `json:"AdminBack"`
  581. ResponBack string `json:"ResponBack"`
  582. RnameBack string `json:"RnameBack"`
  583. SnameBack string `json:"SnameBack"`
  584. BotBack []string `json:"BotBack"`
  585. Dalltime string `json:"Dalltime"`
  586. Logobot string `json:"Logobot"`
  587. SellerBack []string `json:"SellerBack"`
  588. BanBack []string `json:"BanBack"`
  589. FuckBack []string `json:"FuckBack"`
  590. Limit string `json:"MLimit"`
  591. Fresh string `json:"MFfresh"`
  592. MuteBack []string `json:"MuteBack"`
  593. AnnunceBack []string `json:"AnnunceBack"`
  594. ProQrBack []string `json:"ProQrBack"`
  595. ProjoinBack []string `json:"ProjoinBack"`
  596. ProInviteBack []string `json:"ProInviteBack"`
  597. ProCancelBack []string `json:"ProCancelBack"`
  598. ProkickBack []string `json:"ProkickBack"`
  599. GbanBack map[string][]string `json:"GbanBack"`
  600. GadminBack map[string][]string `json:"GadminBack"`
  601. GownerBack map[string][]string `json:"GownerBack"`
  602. TimeBanBack map[string]time.Time `json:"TimeBanBack"`
  603. }
  604. )
  605. func Resprem() {
  606. rngcmd := GetComs(3, "clone")
  607. rngcmd = GetComs(3, "joinqrkick")
  608. rngcmd = GetComs(4, "joinqr")
  609. rngcmd = GetComs(3, "cancelall")
  610. rngcmd = GetComs(3, "kickall")
  611. rngcmd = GetComs(7, "none")
  612. rngcmd = GetComs(7, "max")
  613. rngcmd = GetComs(6, "allowall")
  614. rngcmd = GetComs(6, "denyall")
  615. rngcmd = GetComs(5, "hostage")
  616. rngcmd = GetComs(3, "backup")
  617. rngcmd = GetComs(5, "upgname")
  618. rngcmd = GetComs(5, "welcome")
  619. rngcmd = GetComs(4, "sendimage")
  620. rngcmd = GetComs(4, "leave")
  621. rngcmd = GetComs(5, "announce")
  622. rngcmd = GetComs(5, "unban")
  623. rngcmd = GetComs(6, "bio")
  624. rngcmd = GetComs(6, "tag")
  625. rngcmd = GetComs(6, "image")
  626. rngcmd = GetComs(5, "contact")
  627. rngcmd = GetComs(5, "ban")
  628. rngcmd = GetComs(6, "kick")
  629. rngcmd = GetComs(6, "vkick")
  630. rngcmd = GetComs(6, "invite")
  631. rngcmd = GetComs(6, "cancel")
  632. rngcmd = GetComs(7, "ungban")
  633. rngcmd = GetComs(3, "unbot")
  634. rngcmd = GetComs(8, "tagall")
  635. rngcmd = GetComs(4, "statusall")
  636. rngcmd = GetComs(5, "status")
  637. rngcmd = GetComs(5, "whois")
  638. rngcmd = GetComs(5, "mute")
  639. rngcmd = GetComs(4, "fuck")
  640. rngcmd = GetComs(3, "setlimiter")
  641. rngcmd = GetComs(3, "setcancel")
  642. rngcmd = GetComs(3, "setkick")
  643. rngcmd = GetComs(3, "msglimit")
  644. rngcmd = GetComs(3, "msgstatus")
  645. rngcmd = GetComs(3, "msglurk")
  646. rngcmd = GetComs(3, "msgclearban")
  647. rngcmd = GetComs(4, "msgleave")
  648. rngcmd = GetComs(4, "speed")
  649. rngcmd = GetComs(6, "lurk")
  650. rngcmd = GetComs(4, "msgwelcome")
  651. rngcmd = GetComs(3, "msgrespon")
  652. rngcmd = GetComs(3, "setrname")
  653. rngcmd = GetComs(3, "setsname")
  654. rngcmd = GetComs(3, "logmode")
  655. rngcmd = GetComs(4, "killmode")
  656. rngcmd = GetComs(3, "unowner")
  657. rngcmd = GetComs(6, "name")
  658. rngcmd = GetComs(3, "Stats")
  659. rngcmd = GetComs(3, "buyers")
  660. rngcmd = GetComs(3, "upname")
  661. rngcmd = GetComs(3, "upstatus")
  662. rngcmd = GetComs(3, "acceptall")
  663. rngcmd = GetComs(3, "declineall")
  664. rngcmd = GetComs(6, "abort")
  665. rngcmd = GetComs(3, "accept")
  666. rngcmd = GetComs(3, "decline")
  667. rngcmd = GetComs(3, "invme")
  668. rngcmd = GetComs(3, "gleave")
  669. rngcmd = GetComs(4, "Purgeallbans")
  670. rngcmd = GetComs(4, "purgeall")
  671. rngcmd = GetComs(5, "unsend")
  672. rngcmd = GetComs(1, "creators")
  673. rngcmd = GetComs(3, "upvcover")
  674. rngcmd = GetComs(1, "unseller")
  675. rngcmd = GetComs(1, "clearseller")
  676. rngcmd = GetComs(2, "sellers")
  677. rngcmd = GetComs(1, "seller")
  678. rngcmd = GetComs(0, "uncreator")
  679. rngcmd = GetComs(0, "clearcreator")
  680. rngcmd = GetComs(3, "upvimage")
  681. rngcmd = GetComs(3, "upcover")
  682. rngcmd = GetComs(3, "upimage")
  683. rngcmd = GetComs(2, "clearbuyer")
  684. rngcmd = GetComs(2, "unbuyer")
  685. rngcmd = GetComs(2, "buyer")
  686. rngcmd = GetComs(7, "gaccess")
  687. rngcmd = GetComs(4, "allbanlist")
  688. rngcmd = GetComs(3, "access")
  689. rngcmd = GetComs(7, "expel")
  690. rngcmd = GetComs(4, "listcmd")
  691. rngcmd = GetComs(3, "owner")
  692. rngcmd = GetComs(3, "hide")
  693. rngcmd = GetComs(3, "unhide")
  694. rngcmd = GetComs(3, "hidelist")
  695. rngcmd = GetComs(3, "clearhide")
  696. rngcmd = GetComs(6, "mid")
  697. rngcmd = GetComs(4, "cleargowner")
  698. rngcmd = GetComs(3, "logmode")
  699. rngcmd = GetComs(3, "clearowner")
  700. rngcmd = GetComs(4, "unmaster")
  701. rngcmd = GetComs(5, "unmute")
  702. rngcmd = GetComs(3, "clearlistcmd")
  703. rngcmd = GetComs(4, "setcmd")
  704. rngcmd = GetComs(6, "gowner")
  705. rngcmd = GetComs(4, "master")
  706. rngcmd = GetComs(4, "gojoin")
  707. rngcmd = GetComs(5, "ungowner")
  708. rngcmd = GetComs(5, "settings")
  709. rngcmd = GetComs(5, "set")
  710. rngcmd = GetComs(4, "runtime")
  711. rngcmd = GetComs(4, "timenow")
  712. rngcmd = GetComs(3, "timeleft")
  713. rngcmd = GetComs(8, "say")
  714. rngcmd = GetComs(5, "curl")
  715. rngcmd = GetComs(5, "ourl")
  716. rngcmd = GetComs(8, "here")
  717. rngcmd = GetComs(7, "gbanlist")
  718. rngcmd = GetComs(4, "clearcache")
  719. rngcmd = GetComs(4, "clearchat")
  720. rngcmd = GetComs(4, "cleargban")
  721. rngcmd = GetComs(3, "clearbot")
  722. rngcmd = GetComs(3, "botlist")
  723. rngcmd = GetComs(5, "bans")
  724. rngcmd = GetComs(4, "fixed")
  725. rngcmd = GetComs(7, "gban")
  726. rngcmd = GetComs(3, "bot")
  727. rngcmd = GetComs(4, "stay")
  728. rngcmd = GetComs(3, "leaveall")
  729. rngcmd = GetComs(4, "go")
  730. rngcmd = GetComs(5, "stayall")
  731. rngcmd = GetComs(4, "bringall")
  732. rngcmd = GetComs(3, "listprotect")
  733. rngcmd = GetComs(6, "cleargadmin")
  734. rngcmd = GetComs(3, "clearban")
  735. rngcmd = GetComs(3, "clearadmin")
  736. rngcmd = GetComs(2, "upallname")
  737. rngcmd = GetComs(3, "upallstatus")
  738. rngcmd = GetComs(5, "limitout")
  739. rngcmd = GetComs(5, "sayall")
  740. rngcmd = GetComs(6, "count")
  741. rngcmd = GetComs(8, "ping")
  742. rngcmd = GetComs(4, "leave")
  743. rngcmd = GetComs(1, "addallsquads")
  744. rngcmd = GetComs(2, "addallbots")
  745. rngcmd = GetComs(4, "limits")
  746. rngcmd = GetComs(3, "adds")
  747. rngcmd = GetComs(3, "friends")
  748. rngcmd = GetComs(2, "upvallcover")
  749. rngcmd = GetComs(2, "upvallimage")
  750. rngcmd = GetComs(5, "unsend")
  751. rngcmd = GetComs(2, "upallcover")
  752. rngcmd = GetComs(2, "upallimage")
  753. rngcmd = GetComs(5, "rollcall")
  754. rngcmd = GetComs(6, "respon")
  755. rngcmd = GetComs(5, "banlist")
  756. rngcmd = GetComs(4, "antitag")
  757. rngcmd = GetComs(6, "admins")
  758. rngcmd = GetComs(8, "gadmin")
  759. rngcmd = GetComs(4, "squadmid")
  760. rngcmd = GetComs(7, "ungadmin")
  761. rngcmd = GetComs(5, "unadmin")
  762. rngcmd = GetComs(5, "masters")
  763. rngcmd = GetComs(5, "gowners")
  764. rngcmd = GetComs(5, "admin")
  765. rngcmd = GetComs(4, "unfuck")
  766. rngcmd = GetComs(3, "remote")
  767. rngcmd = GetComs(3, "groupinfo")
  768. rngcmd = GetComs(3, "banpurge")
  769. rngcmd = GetComs(3, "autoban")
  770. rngcmd = GetComs(3, "autopurge")
  771. rngcmd = GetComs(3, "canceljoin")
  772. rngcmd = GetComs(3, "nukejoin")
  773. rngcmd = GetComs(3, "groups")
  774. rngcmd = GetComs(3, "gourl")
  775. rngcmd = GetComs(3, "groupcast")
  776. rngcmd = GetComs(4, "fucklist")
  777. rngcmd = GetComs(5, "mutelist")
  778. rngcmd = GetComs(3, "autojoin")
  779. rngcmd = GetComs(3, "perm")
  780. rngcmd = GetComs(3, "permlist")
  781. rngcmd = GetComs(3, "clearallprotect")
  782. rngcmd = GetComs(3, "clearmute")
  783. rngcmd = GetComs(3, "clearfuck")
  784. rngcmd = GetComs(3, "clearmaster")
  785. fmt.Println(rngcmd)
  786. }
  787. func abort() {
  788. remotegrupidto = ""
  789. StartChangeImg = false
  790. StartChangevImg = false
  791. StartChangevImg2 = false
  792. Sinderremote = []string{}
  793. remotegrupid = ""
  794. changepic = []*oop.Account{}
  795. ChangName = false
  796. ChangCover = false
  797. ChangPict = false
  798. ChangeBio = false
  799. ChangVpict = false
  800. ChangVcover = false
  801. AllCheng = false
  802. MsgBio = ""
  803. MsgName = ""
  804. timeabort = time.Now()
  805. }
  806. func AllBanList(self *oop.Account) string {
  807. listadm := "โœ  ๐—”๐—น๐—น ๐—ฏ๐—ฎ๐—ป๐—น๐—ถ๐˜€๐˜๐˜€ โœ "
  808. if len(Banned.Banlist) != 0 {
  809. listadm += "\n\n โ˜ ๏ธ ๐—•๐—ฎ๐—ป๐—น๐—ถ๐˜€๐˜ โ˜ ๏ธ "
  810. for num, xd := range Banned.Banlist {
  811. num++
  812. rengs := strconv.Itoa(num)
  813. new := self.Getcontactuser(xd)
  814. if new != nil {
  815. listadm += "\n " + rengs + ". Closed Account"
  816. } else {
  817. x, _ := self.GetContact(xd)
  818. listadm += "\n " + rengs + ". " + x.DisplayName
  819. }
  820. }
  821. }
  822. if len(Banned.Fucklist) != 0 {
  823. listadm += "\n\n โ˜ ๏ธ ๐—™๐˜‚๐—ฐ๐—ธ๐—น๐—ถ๐˜€๐˜ โ˜ ๏ธ "
  824. for num, xd := range Banned.Fucklist {
  825. num++
  826. rengs := strconv.Itoa(num)
  827. new := self.Getcontactuser(xd)
  828. if new != nil {
  829. listadm += "\n " + rengs + ". Closed Account"
  830. } else {
  831. x, _ := self.GetContact(xd)
  832. listadm += "\n " + rengs + ". " + x.DisplayName
  833. }
  834. }
  835. }
  836. if len(Banned.Mutelist) != 0 {
  837. listadm += "\n\n โ˜ ๏ธ ๐— ๐˜‚๐˜๐—ฒ๐—น๐—ถ๐˜€๐˜ โ˜ ๏ธ "
  838. for num, xd := range Banned.Mutelist {
  839. num++
  840. rengs := strconv.Itoa(num)
  841. new := self.Getcontactuser(xd)
  842. if new != nil {
  843. listadm += "\n " + rengs + ". Closed Account"
  844. } else {
  845. x, _ := self.GetContact(xd)
  846. listadm += "\n " + rengs + ". " + x.DisplayName
  847. }
  848. }
  849. }
  850. return listadm
  851. }
  852. func Checkserver(ip string) bool {
  853. if InArray2(ListIp, ip) {
  854. return true
  855. }
  856. return false
  857. }
  858. func MemBan(to, user string) bool {
  859. defer oop.PanicOnly()
  860. if Banned.GetBan(user) {
  861. return true
  862. } else if Banned.GetFuck(user) {
  863. return true
  864. } else {
  865. Room := oop.GetRoom(to)
  866. if InArray2(Room.Gban, user) {
  867. return true
  868. }
  869. return false
  870. }
  871. //return false
  872. }
  873. func MemBan2(to, user string) bool {
  874. defer oop.PanicOnly()
  875. if Banned.GetBan(user) {
  876. return true
  877. } else if Banned.GetFuck(user) {
  878. return true
  879. } else if Banned.GetMute(user) {
  880. return true
  881. } else {
  882. Room := oop.GetRoom(to)
  883. if InArray2(Room.Gban, user) {
  884. return true
  885. }
  886. return false
  887. }
  888. //return false
  889. }
  890. func Cekbanwhois(client *oop.Account, to string, targets []string) {
  891. room := oop.GetRoom(to)
  892. list := ""
  893. if len(targets) > 1 {
  894. ban := []string{}
  895. fuck := []string{}
  896. mute := []string{}
  897. Gban := []string{}
  898. for _, from := range targets {
  899. if Banned.GetFuck(from) {
  900. fuck = append(fuck, from)
  901. } else if Banned.GetBan(from) {
  902. ban = append(ban, from)
  903. } else if Banned.GetMute(from) {
  904. mute = append(mute, from)
  905. } else if InArray2(room.Gban, from) {
  906. Gban = append(Gban, from)
  907. }
  908. }
  909. if len(ban) != 0 {
  910. list += "๐—˜๐˜…๐—ถ๐˜€๐˜.๐—ถ๐—ป ๐—ฏ๐—ฎ๐—ป๐—น๐—ถ๐˜€๐˜:\n"
  911. for n, xx := range ban {
  912. rengs := strconv.Itoa(n + 1)
  913. new := client.Getcontactuser(xx)
  914. if new != nil {
  915. list += rengs + ". Closed Account \n"
  916. } else {
  917. x, _ := client.GetContact(xx)
  918. list += rengs + ". " + x.DisplayName + "\n"
  919. }
  920. }
  921. }
  922. if len(fuck) != 0 {
  923. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐—ณ๐˜‚๐—ฐ๐—ธ๐—น๐—ถ๐˜€๐˜:\n"
  924. for n, xx := range fuck {
  925. rengs := strconv.Itoa(n + 1)
  926. new := client.Getcontactuser(xx)
  927. if new != nil {
  928. list += rengs + ". Closed Account \n"
  929. } else {
  930. x, _ := client.GetContact(xx)
  931. list += rengs + ". " + x.DisplayName + "\n"
  932. }
  933. }
  934. }
  935. if len(Gban) != 0 {
  936. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐—ด๐—ฏ๐—ฎ๐—ป๐—น๐—ถ๐˜€๐˜:\n"
  937. for n, xx := range Gban {
  938. rengs := strconv.Itoa(n + 1)
  939. new := client.Getcontactuser(xx)
  940. if new != nil {
  941. list += rengs + ". Closed Account \n"
  942. } else {
  943. x, _ := client.GetContact(xx)
  944. list += rengs + ". " + x.DisplayName + "\n"
  945. }
  946. }
  947. }
  948. if len(mute) != 0 {
  949. list += "\n๐—˜๐˜…๐—ถ๐˜€๐˜ ๐—ถ๐—ป ๐— ๐˜‚๐˜๐—ฒ๐—น๐—ถ๐˜€๐˜:\n"
  950. for n, xx := range mute {
  951. rengs := strconv.Itoa(n + 1)
  952. new := client.Getcontactuser(xx)
  953. if new != nil {
  954. list += rengs + ". Closed Account \n"
  955. } else {
  956. x, _ := client.GetContact(xx)
  957. list += rengs + ". " + x.DisplayName + "\n"
  958. }
  959. }
  960. }
  961. } else {
  962. for _, from := range targets {
  963. if Banned.GetFuck(from) {
  964. list += "User have access exist in fuck list."
  965. } else if Banned.GetBan(from) {
  966. list += "User have access exist in ban list."
  967. } else if InArray2(room.Gban, from) {
  968. list += "User have access exist in gban list."
  969. } else if Banned.GetMute(from) {
  970. list += "User have access exist in mute list."
  971. }
  972. }
  973. }
  974. if list != "" {
  975. client.SendMessage(to, list)
  976. }
  977. }
  978. func autokickban(client *oop.Account, to string, target string) {
  979. if AutokickBan {
  980. gr, _ := client.GetGroupIdsJoined()
  981. for _, aa := range gr {
  982. go client.DeleteOtherFromChats(aa, target)
  983. go client.CancelChatInvitations(aa, target)
  984. }
  985. }
  986. }
  987. func KIckbansPurges(client *oop.Account, group string) {
  988. defer oop.PanicOnly()
  989. gr, _ := client.GetGroupIdsJoined()
  990. nus := []string{}
  991. list := ""
  992. list += fmt.Sprintf("Purged %v groups: \n", len(gr))
  993. for num, aa := range gr {
  994. num++
  995. //list += fmt.Sprintf("%v- %v :", num, name)
  996. for _, v := range Banned.Banlist {
  997. if oop.IsMembers(client, aa, v) == true {
  998. if Banned.GetBan(v) {
  999. go func(v string) { client.DeleteOtherFromChats(aa, v) }(v)
  1000. if oop.IsPending(client, aa, v) == true {
  1001. client.CancelChatInvitations(group, v)
  1002. }
  1003. new := client.Getcontactuser(v)
  1004. rengs := strconv.Itoa(num)
  1005. if new != nil {
  1006. list += "\n " + rengs + ". Closed Account"
  1007. } else {
  1008. x, _ := client.GetContact(v)
  1009. nus = append(nus, v)
  1010. list += "\n " + rengs + ". " + x.DisplayName
  1011. }
  1012. }
  1013. }
  1014. }
  1015. }
  1016. list += fmt.Sprintf("\n\nTotal kicks: %v.", len(nus))
  1017. client.SendMessage(group, list)
  1018. }
  1019. func Ungban(group string, asu string) {
  1020. room := oop.GetRoom(group)
  1021. if InArray2(room.Gban, asu) {
  1022. room.Gban = Remove(room.Gban, asu)
  1023. }
  1024. }
  1025. func Addgban(asu string, group string) {
  1026. room := oop.GetRoom(group)
  1027. if !InArray2(room.Gban, asu) && asu != "" {
  1028. room.Gban = append(room.Gban, asu)
  1029. }
  1030. }
  1031. func IndexOf(data []string, element string) int {
  1032. for k, v := range data {
  1033. if element == v {
  1034. return k
  1035. }
  1036. }
  1037. return -1
  1038. }
  1039. func Joinsave(Pelaku string, Optime int64) {
  1040. defer oop.PanicOnly()
  1041. ix := IndexOf(Detectjoin.User, Pelaku)
  1042. if ix == -1 {
  1043. Detectjoin.User = append(Detectjoin.User, Pelaku)
  1044. Detectjoin.Time = append(Detectjoin.Time, Optime)
  1045. } else {
  1046. Detectjoin.Time[ix] = Optime
  1047. }
  1048. }
  1049. func Checkmulti(list1 []string, list2 []string) bool {
  1050. for _, v := range list1 {
  1051. if InArray2(list2, v) {
  1052. return true
  1053. }
  1054. }
  1055. return false
  1056. }
  1057. func AddbanOp3(mid []string) {
  1058. for _, m := range mid {
  1059. Banned.AddBan(m)
  1060. }
  1061. }
  1062. func SaveData() {
  1063. defer oop.PanicOnly()
  1064. file, _ := json.MarshalIndent(Data, "", " ")
  1065. _ = ioutil.WriteFile(DATABASE, file, 0644)
  1066. }
  1067. func gracefulShutdown() {
  1068. s := make(chan os.Signal, 1)
  1069. signal.Notify(s, os.Interrupt)
  1070. signal.Notify(s, syscall.SIGTERM)
  1071. go func() {
  1072. <-s
  1073. fmt.Println("Sutting down application.")
  1074. os.Exit(0)
  1075. }()
  1076. }
  1077. func randomToString(count int) string {
  1078. numb := make([]rune, count)
  1079. for i := range numb {
  1080. numb[i] = stringToInt[rand.Intn(len(stringToInt))]
  1081. }
  1082. return string(numb)
  1083. }
  1084. func panicHandle(s string) {
  1085. if r := recover(); r != nil {
  1086. Ides := fmt.Sprintf("\nEror \nFunc: %v", s)
  1087. println(Ides)
  1088. }
  1089. }
  1090. func GetMentionData(data string) []string {
  1091. var midmen []string
  1092. var midbefore []string
  1093. res := mentions{}
  1094. json.Unmarshal([]byte(data), &res)
  1095. for _, v := range res.MENTIONEES {
  1096. if InArray2(midbefore, v.Mid) == false {
  1097. midbefore = append(midbefore, v.Mid)
  1098. midmen = append(midmen, v.Mid)
  1099. }
  1100. }
  1101. return midmen
  1102. }
  1103. func MentionList(op *talkservice.Operation) []string {
  1104. msg := op.Message
  1105. str := fmt.Sprintf("%v", msg.ContentMetadata["MENTION"])
  1106. taglist := GetMentionData(str)
  1107. return taglist
  1108. }
  1109. func GetIP() net.IP {
  1110. conn, err := net.Dial("udp", "8.8.8.8:80")
  1111. if err != nil {
  1112. log.Fatal(err)
  1113. }
  1114. defer conn.Close()
  1115. localAddr := conn.LocalAddr().(*net.UDPAddr)
  1116. return localAddr.IP
  1117. }