Advertisement
0xCor3

hw2

Aug 5th, 2018
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 68.14 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. from LineAPI.linepy import *
  4. from gtts import gTTS
  5. from bs4 import BeautifulSoup
  6. from datetime import datetime
  7. from googletrans import Translator
  8. import ast, codecs, json, os, pytz, re, random, requests, sys, time, urllib.parse
  9.  
  10. listApp = ["CHROMEOS", "DESKTOPWIN", "DESKTOPMAC", "IOSIPAD", "WIN10"]
  11. try:
  12.     for app in listApp:
  13.         try:
  14.             try:
  15.                 with open("authToken.txt", "r") as token:
  16.                     authToken = token.read()
  17.                     if not authToken:
  18.                         client = LINE()
  19.                         with open("authToken.txt","w") as token:
  20.                             token.write(client.authToken)
  21.                         continue
  22.                     client = LINE(authToken, speedThrift=False, appName="{}\t8.8.1\tHelloWorld\t11.2.5".format(app))
  23.                 break
  24.             except Exception as error:
  25.                 print(error)
  26.                 if error == "REVOKE":
  27.                     exit()
  28.                 elif "auth" in error:
  29.                     continue
  30.                 else:
  31.                     exit()
  32.         except Exception as error:
  33.             print(error)
  34. except Exception as error:
  35.     print(error)
  36. with open("authToken.txt", "w") as token:
  37.     token.write(str(client.authToken))
  38. clientMid = client.profile.mid
  39. clientStart = time.time()
  40. clientPoll = OEPoll(client)
  41.  
  42. languageOpen = codecs.open("language.json","r","utf-8")
  43. readOpen = codecs.open("read.json","r","utf-8")
  44. settingsOpen = codecs.open("setting.json","r","utf-8")
  45. unsendOpen = codecs.open("unsend.json","r","utf-8")
  46.  
  47. language = json.load(languageOpen)
  48. read = json.load(readOpen)
  49. settings = json.load(settingsOpen)
  50. unsend = json.load(unsendOpen)
  51.  
  52. def restartBot():
  53.     print ("[ INFO ] BOT RESETTED")
  54.     python = sys.executable
  55.     os.execl(python, python, *sys.argv)
  56.  
  57. def logError(text):
  58.     client.log("[ ERROR ] {}".format(str(text)))
  59.     tz = pytz.timezone("Asia/Makassar")
  60.     timeNow = datetime.now(tz=tz)
  61.     timeHours = datetime.strftime(timeNow,"(%H:%M)")
  62.     day = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday","Friday", "Saturday"]
  63.     hari = ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"]
  64.     bulan = ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"]
  65.     inihari = datetime.now(tz=tz)
  66.     hr = inihari.strftime('%A')
  67.     bln = inihari.strftime('%m')
  68.     for i in range(len(day)):
  69.         if hr == day[i]: hasil = hari[i]
  70.     for k in range(0, len(bulan)):
  71.         if bln == str(k): bln = bulan[k-1]
  72.     time = "{}, {} - {} - {} | {}".format(str(hasil), str(inihari.strftime('%d')), str(bln), str(inihari.strftime('%Y')), str(inihari.strftime('%H:%M:%S')))
  73.     with open("errorLog.txt","a") as error:
  74.         error.write("\n[{}] {}".format(str(time), text))
  75.  
  76. def timeChange(secs):
  77.     mins, secs = divmod(secs,60)
  78.     hours, mins = divmod(mins,60)
  79.     days, hours = divmod(hours,24)
  80.     weeks, days = divmod(days,7)
  81.     months, weeks = divmod(weeks,4)
  82.     text = ""
  83.     if months != 0: text += "%02d Bulan" % (months)
  84.     if weeks != 0: text += " %02d Minggu" % (weeks)
  85.     if days != 0: text += " %02d Hari" % (days)
  86.     if hours !=  0: text +=  " %02d Jam" % (hours)
  87.     if mins != 0: text += " %02d Menit" % (mins)
  88.     if secs != 0: text += " %02d Detik" % (secs)
  89.     if text[0] == " ":
  90.         text = text[1:]
  91.     return text
  92.  
  93. def command(text):
  94.     pesan = text.lower()
  95.     if settings["setKey"] == True:
  96.         if pesan.startswith(settings["keyCommand"]):
  97.             cmd = pesan.replace(settings["keyCommand"],"")
  98.         else:
  99.             cmd = "Undefined command"
  100.     else:
  101.         cmd = text.lower()
  102.     return cmd
  103.  
  104. def backupData():
  105.     try:
  106.         backup = read
  107.         f = codecs.open('read.json','w','utf-8')
  108.         json.dump(backup, f, sort_keys=True, indent=4, ensure_ascii=False)
  109.         backup = settings
  110.         f = codecs.open('setting.json','w','utf-8')
  111.         json.dump(backup, f, sort_keys=True, indent=4, ensure_ascii=False)
  112.         backup = unsend
  113.         f = codecs.open('unsend.json','w','utf-8')
  114.         json.dump(backup, f, sort_keys=True, indent=4, ensure_ascii=False)
  115.         return True
  116.     except Exception as error:
  117.         logError(error)
  118.         return False
  119.  
  120. def menuHelp():
  121.     if settings['setKey'] == True:
  122.         key = settings['keyCommand']
  123.     else:
  124.         key = ''
  125.     menuHelp =  "╔══[ Help Message ]" + "\n" + \
  126.                 "╠ " + key + "Help" + "\n" + \
  127.                 "╠ " + key + "Translate" + "\n" + \
  128.                 "╠ " + key + "TextToSpeech" + "\n" + \
  129.                 "╠══[ Status Command ]" + "\n" + \
  130.                 "╠ MyKey" + "\n" + \
  131.                 "╠ " + key + "Logout" + "\n" + \
  132.                 "╠ " + key + "Restart" + "\n" + \
  133.                 "╠ " + key + "Runtime" + "\n" + \
  134.                 "╠ " + key + "Speed" + "\n" + \
  135.                 "╠ " + key + "Status" + "\n" + \
  136.                 "╠══[ Settings Command ]" + "\n" + \
  137.                 "╠ SetKey 「On/Off」" + "\n" + \
  138.                 "╠ " + key + "AutoAdd 「On/Off」" + "\n" + \
  139.                 "╠ " + key + "AutoJoin 「On/Off」" + "\n" + \
  140.                 "╠ " + key + "AutoJoinTicket 「On/Off」" + "\n" + \
  141.                 "╠ " + key + "AutoRead 「On/Off」" + "\n" + \
  142.                 "╠ " + key + "AutoRespon 「On/Off」" + "\n" + \
  143.                 "╠ " + key + "CheckContact 「On/Off」" + "\n" + \
  144.                 "╠ " + key + "CheckPost 「On/Off」" + "\n" + \
  145.                 "╠ " + key + "CheckSticker 「On/Off」" + "\n" + \
  146.                 "╠ " + key + "DetectUnsend 「On/Off」" + "\n" + \
  147.                 "╠ " + key + "SetKey: 「text」" + "\n" + \
  148.                 "╠ " + key + "SetAutoAddMessage: 「text」" + "\n" + \
  149.                 "╠ " + key + "SetAutoResponMessage: 「text」" + "\n" + \
  150.                 "╠ " + key + "SetAutoJoinMessage: 「Text」" + "\n" + \
  151.                 "╠══[ Self Command ]" + "\n" + \
  152.                 "╠ " + key + "ChangeName: 「Text」" + "\n" + \
  153.                 "╠ " + key + "ChangeBio: 「Text」" + "\n" + \
  154.                 "╠ " + key + "Me" + "\n" + \
  155.                 "╠ " + key + "MyMid" + "\n" + \
  156.                 "╠ " + key + "MyName" + "\n" + \
  157.                 "╠ " + key + "MyBio" + "\n" + \
  158.                 "╠ " + key + "MyPicture" + "\n" + \
  159.                 "╠ " + key + "MyVideoProfile" + "\n" + \
  160.                 "╠ " + key + "MyCover" + "\n" + \
  161.                 "╠ " + key + "MyProfile" + "\n" + \
  162.                 "╠ " + key + "GetMid @Mention" + "\n" + \
  163.                 "╠ " + key + "GetName @Mention" + "\n" + \
  164.                 "╠ " + key + "GetBio @Mention" + "\n" + \
  165.                 "╠ " + key + "GetPicture @Mention" + "\n" + \
  166.                 "╠ " + key + "GetVideoProfile @Mention" + "\n" + \
  167.                 "╠ " + key + "GetCover @Mention" + "\n" + \
  168.                 "╠ " + key + "CloneProfile @Mention" + "\n" + \
  169.                 "╠ " + key + "RestoreProfile" + "\n" + \
  170.                 "╠ " + key + "BackupProfile" + "\n" + \
  171.                 "╠ " + key + "FriendList" + "\n" + \
  172.                 "╠ " + key + "FriendInfo 「Number」" + "\n" + \
  173.                 "╠ " + key + "BlockList" + "\n" + \
  174.                 "╠ " + key + "FriendBroadcast" + "\n" + \
  175.                 "╠ " + key + "ChangePictureProfile" + "\n" + \
  176.                 "╠══[ Group Command ]" + "\n" + \
  177.                 "╠ " + key + "ChangeGroupName: 「Text」" + "\n" + \
  178.                 "╠ " + key + "GroupCreator" + "\n" + \
  179.                 "╠ " + key + "GroupID" + "\n" + \
  180.                 "╠ " + key + "GroupName" + "\n" + \
  181.                 "╠ " + key + "GroupPicture" + "\n" + \
  182.                 "╠ " + key + "OpenQR" + "\n" + \
  183.                 "╠ " + key + "CloseQR" + "\n" + \
  184.                 "╠ " + key + "GroupList" + "\n" + \
  185.                 "╠ " + key + "MemberList" + "\n" + \
  186.                 "╠ " + key + "PendingList" + "\n" + \
  187.                 "╠ " + key + "GroupInfo" + "\n" + \
  188.                 "╠ " + key + "GroupBroadcast: 「Text」" + "\n" + \
  189.                 "╠ " + key + "ChangeGroupPicture" + "\n" + \
  190.                 "╠══[ Special Command ]" + "\n" + \
  191.                 "╠ " + key + "Mimic 「On/Off」" + "\n" + \
  192.                 "╠ " + key + "MimicList" + "\n" + \
  193.                 "╠ " + key + "MimicAdd @Mention" + "\n" + \
  194.                 "╠ " + key + "MimicDel @Mention" + "\n" + \
  195.                 "╠ " + key + "Mention" + "\n" + \
  196.                 "╠ " + key + "Lurking 「On/Off」" + "\n" + \
  197.                 "╠ " + key + "Lurking" + "\n" + \
  198.                 "╠══[ Media Command ]" + "\n" + \
  199.                 "╠ " + key + "InstaInfo 「Username」" + "\n" + \
  200.                 "╠ " + key + "InstaStory 「Username」" + "\n" + \
  201.                 "╠ " + key + "Quotes" + "\n" + \
  202.                 "╠ " + key + "SearchImage 「Search」" + "\n" + \
  203.                 "╠ " + key + "SearchMusic 「Search」" + "\n" + \
  204.                 "╠ " + key + "SearchLyric 「Search」" + "\n" + \
  205.                 "╠ " + key + "SearchYoutube 「Search」" + "\n" + \
  206.                 "╚══[ Copyright @Zero-Cool404 ]"
  207.     return menuHelp
  208.  
  209. def menuTextToSpeech():
  210.     if settings['setKey'] == True:
  211.         key = settings['keyCommand']
  212.     else:
  213.         key = ''
  214.     menuTextToSpeech =  "╔══[ Text To Speech ]" + "\n" + \
  215.                         "╠ " + key + "af : Afrikaans" + "\n" + \
  216.                         "╠ " + key + "sq : Albanian" + "\n" + \
  217.                         "╠ " + key + "ar : Arabic" + "\n" + \
  218.                         "╠ " + key + "hy : Armenian" + "\n" + \
  219.                         "╠ " + key + "bn : Bengali" + "\n" + \
  220.                         "╠ " + key + "ca : Catalan" + "\n" + \
  221.                         "╠ " + key + "zh : Chinese" + "\n" + \
  222.                         "╠ " + key + "zh-cn : Chinese (Mandarin/China)" + "\n" + \
  223.                         "╠ " + key + "zh-tw : Chinese (Mandarin/Taiwan)" + "\n" + \
  224.                         "╠ " + key + "zh-yue : Chinese (Cantonese)" + "\n" + \
  225.                         "╠ " + key + "hr : Croatian" + "\n" + \
  226.                         "╠ " + key + "cs : Czech" + "\n" + \
  227.                         "╠ " + key + "da : Danish" + "\n" + \
  228.                         "╠ " + key + "nl : Dutch" + "\n" + \
  229.                         "╠ " + key + "en : English" + "\n" + \
  230.                         "╠ " + key + "en-au : English (Australia)" + "\n" + \
  231.                         "╠ " + key + "en-uk : English (United Kingdom)" + "\n" + \
  232.                         "╠ " + key + "en-us : English (United States)" + "\n" + \
  233.                         "╠ " + key + "eo : Esperanto" + "\n" + \
  234.                         "╠ " + key + "fi : Finnish" + "\n" + \
  235.                         "╠ " + key + "fr : French" + "\n" + \
  236.                         "╠ " + key + "de : German" + "\n" + \
  237.                         "╠ " + key + "el : Greek" + "\n" + \
  238.                         "╠ " + key + "hi : Hindi" + "\n" + \
  239.                         "╠ " + key + "hu : Hungarian" + "\n" + \
  240.                         "╠ " + key + "is : Icelandic" + "\n" + \
  241.                         "╠ " + key + "id : Indonesian" + "\n" + \
  242.                         "╠ " + key + "it : Italian" + "\n" + \
  243.                         "╠ " + key + "ja : Japanese" + "\n" + \
  244.                         "╠ " + key + "km : Khmer (Cambodian)" + "\n" + \
  245.                         "╠ " + key + "ko : Korean" + "\n" + \
  246.                         "╠ " + key + "la : Latin" + "\n" + \
  247.                         "╠ " + key + "lv : Latvian" + "\n" + \
  248.                         "╠ " + key + "mk : Macedonian" + "\n" + \
  249.                         "╠ " + key + "no : Norwegian" + "\n" + \
  250.                         "╠ " + key + "pl : Polish" + "\n" + \
  251.                         "╠ " + key + "pt : Portuguese" + "\n" + \
  252.                         "╠ " + key + "ro : Romanian" + "\n" + \
  253.                         "╠ " + key + "ru : Russian" + "\n" + \
  254.                         "╠ " + key + "sr : Serbian" + "\n" + \
  255.                         "╠ " + key + "si : Sinhala" + "\n" + \
  256.                         "╠ " + key + "sk : Slovak" + "\n" + \
  257.                         "╠ " + key + "es : Spanish" + "\n" + \
  258.                         "╠ " + key + "es-es : Spanish (Spain)" + "\n" + \
  259.                         "╠ " + key + "es-us : Spanish (United States)" + "\n" + \
  260.                         "╠ " + key + "sw : Swahili" + "\n" + \
  261.                         "╠ " + key + "sv : Swedish" + "\n" + \
  262.                         "╠ " + key + "ta : Tamil" + "\n" + \
  263.                         "╠ " + key + "th : Thai" + "\n" + \
  264.                         "╠ " + key + "tr : Turkish" + "\n" + \
  265.                         "╠ " + key + "uk : Ukrainian" + "\n" + \
  266.                         "╠ " + key + "vi : Vietnamese" + "\n" + \
  267.                         "╠ " + key + "cy : Welsh" + "\n" + \
  268.                         "╚══[ Jangan Typo ]" + "\n" + "\n\n" + \
  269.                         "Contoh : " + key + "say-id chiken"
  270.     return menuTextToSpeech
  271.  
  272. def menuTranslate():
  273.     if settings['setKey'] == True:
  274.         key = settings['keyCommand']
  275.     else:
  276.         key = ''
  277.     menuTranslate = "╔══[ Translate ]" + "\n" + \
  278.                     "╠ " + key + "af : afrikaans" + "\n" + \
  279.                     "╠ " + key + "sq : albanian" + "\n" + \
  280.                     "╠ " + key + "am : amharic" + "\n" + \
  281.                     "╠ " + key + "ar : arabic" + "\n" + \
  282.                     "╠ " + key + "hy : armenian" + "\n" + \
  283.                     "╠ " + key + "az : azerbaijani" + "\n" + \
  284.                     "╠ " + key + "eu : basque" + "\n" + \
  285.                     "╠ " + key + "be : belarusian" + "\n" + \
  286.                     "╠ " + key + "bn : bengali" + "\n" + \
  287.                     "╠ " + key + "bs : bosnian" + "\n" + \
  288.                     "╠ " + key + "bg : bulgarian" + "\n" + \
  289.                     "╠ " + key + "ca : catalan" + "\n" + \
  290.                     "╠ " + key + "ceb : cebuano" + "\n" + \
  291.                     "╠ " + key + "ny : chichewa" + "\n" + \
  292.                     "╠ " + key + "zh-cn : chinese (simplified)" + "\n" + \
  293.                     "╠ " + key + "zh-tw : chinese (traditional)" + "\n" + \
  294.                     "╠ " + key + "co : corsican" + "\n" + \
  295.                     "╠ " + key + "hr : croatian" + "\n" + \
  296.                     "╠ " + key + "cs : czech" + "\n" + \
  297.                     "╠ " + key + "da : danish" + "\n" + \
  298.                     "╠ " + key + "nl : dutch" + "\n" + \
  299.                     "╠ " + key + "en : english" + "\n" + \
  300.                     "╠ " + key + "eo : esperanto" + "\n" + \
  301.                     "╠ " + key + "et : estonian" + "\n" + \
  302.                     "╠ " + key + "tl : filipino" + "\n" + \
  303.                     "╠ " + key + "fi : finnish" + "\n" + \
  304.                     "╠ " + key + "fr : french" + "\n" + \
  305.                     "╠ " + key + "fy : frisian" + "\n" + \
  306.                     "╠ " + key + "gl : galician" + "\n" + \
  307.                     "╠ " + key + "ka : georgian" + "\n" + \
  308.                     "╠ " + key + "de : german" + "\n" + \
  309.                     "╠ " + key + "el : greek" + "\n" + \
  310.                     "╠ " + key + "gu : gujarati" + "\n" + \
  311.                     "╠ " + key + "ht : haitian creole" + "\n" + \
  312.                     "╠ " + key + "ha : hausa" + "\n" + \
  313.                     "╠ " + key + "haw : hawaiian" + "\n" + \
  314.                     "╠ " + key + "iw : hebrew" + "\n" + \
  315.                     "╠ " + key + "hi : hindi" + "\n" + \
  316.                     "╠ " + key + "hmn : hmong" + "\n" + \
  317.                     "╠ " + key + "hu : hungarian" + "\n" + \
  318.                     "╠ " + key + "is : icelandic" + "\n" + \
  319.                     "╠ " + key + "ig : igbo" + "\n" + \
  320.                     "╠ " + key + "id : indonesian" + "\n" + \
  321.                     "╠ " + key + "ga : irish" + "\n" + \
  322.                     "╠ " + key + "it : italian" + "\n" + \
  323.                     "╠ " + key + "ja : japanese" + "\n" + \
  324.                     "╠ " + key + "jw : javanese" + "\n" + \
  325.                     "╠ " + key + "kn : kannada" + "\n" + \
  326.                     "╠ " + key + "kk : kazakh" + "\n" + \
  327.                     "╠ " + key + "km : khmer" + "\n" + \
  328.                     "╠ " + key + "ko : korean" + "\n" + \
  329.                     "╠ " + key + "ku : kurdish (kurmanji)" + "\n" + \
  330.                     "╠ " + key + "ky : kyrgyz" + "\n" + \
  331.                     "╠ " + key + "lo : lao" + "\n" + \
  332.                     "╠ " + key + "la : latin" + "\n" + \
  333.                     "╠ " + key + "lv : latvian" + "\n" + \
  334.                     "╠ " + key + "lt : lithuanian" + "\n" + \
  335.                     "╠ " + key + "lb : luxembourgish" + "\n" + \
  336.                     "╠ " + key + "mk : macedonian" + "\n" + \
  337.                     "╠ " + key + "mg : malagasy" + "\n" + \
  338.                     "╠ " + key + "ms : malay" + "\n" + \
  339.                     "╠ " + key + "ml : malayalam" + "\n" + \
  340.                     "╠ " + key + "mt : maltese" + "\n" + \
  341.                     "╠ " + key + "mi : maori" + "\n" + \
  342.                     "╠ " + key + "mr : marathi" + "\n" + \
  343.                     "╠ " + key + "mn : mongolian" + "\n" + \
  344.                     "╠ " + key + "my : myanmar (burmese)" + "\n" + \
  345.                     "╠ " + key + "ne : nepali" + "\n" + \
  346.                     "╠ " + key + "no : norwegian" + "\n" + \
  347.                     "╠ " + key + "ps : pashto" + "\n" + \
  348.                     "╠ " + key + "fa : persian" + "\n" + \
  349.                     "╠ " + key + "pl : polish" + "\n" + \
  350.                     "╠ " + key + "pt : portuguese" + "\n" + \
  351.                     "╠ " + key + "pa : punjabi" + "\n" + \
  352.                     "╠ " + key + "ro : romanian" + "\n" + \
  353.                     "╠ " + key + "ru : russian" + "\n" + \
  354.                     "╠ " + key + "sm : samoan" + "\n" + \
  355.                     "╠ " + key + "gd : scots gaelic" + "\n" + \
  356.                     "╠ " + key + "sr : serbian" + "\n" + \
  357.                     "╠ " + key + "st : sesotho" + "\n" + \
  358.                     "╠ " + key + "sn : shona" + "\n" + \
  359.                     "╠ " + key + "sd : sindhi" + "\n" + \
  360.                     "╠ " + key + "si : sinhala" + "\n" + \
  361.                     "╠ " + key + "sk : slovak" + "\n" + \
  362.                     "╠ " + key + "sl : slovenian" + "\n" + \
  363.                     "╠ " + key + "so : somali" + "\n" + \
  364.                     "╠ " + key + "es : spanish" + "\n" + \
  365.                     "╠ " + key + "su : sundanese" + "\n" + \
  366.                     "╠ " + key + "sw : swahili" + "\n" + \
  367.                     "╠ " + key + "sv : swedish" + "\n" + \
  368.                     "╠ " + key + "tg : tajik" + "\n" + \
  369.                     "╠ " + key + "ta : tamil" + "\n" + \
  370.                     "╠ " + key + "te : telugu" + "\n" + \
  371.                     "╠ " + key + "th : thai" + "\n" + \
  372.                     "╠ " + key + "tr : turkish" + "\n" + \
  373.                     "╠ " + key + "uk : ukrainian" + "\n" + \
  374.                     "╠ " + key + "ur : urdu" + "\n" + \
  375.                     "╠ " + key + "uz : uzbek" + "\n" + \
  376.                     "╠ " + key + "vi : vietnamese" + "\n" + \
  377.                     "╠ " + key + "cy : welsh" + "\n" + \
  378.                     "╠ " + key + "xh : xhosa" + "\n" + \
  379.                     "╠ " + key + "yi : yiddish" + "\n" + \
  380.                     "╠ " + key + "yo : yoruba" + "\n" + \
  381.                     "╠ " + key + "zu : zulu" + "\n" + \
  382.                     "╠ " + key + "fil : Filipino" + "\n" + \
  383.                     "╠ " + key + "he : Hebrew" + "\n" + \
  384.                     "╚══[ Jangan Typo ]" + "\n" + "\n\n" + \
  385.                     "Contoh : " + key + "tr-id chiken"
  386.     return menuTranslate
  387.  
  388. def clientBot(op):
  389.     try:
  390.         if op.type == 0:
  391.             print ("[ 0 ] END OF OPERATION")
  392.             return
  393.  
  394.         if op.type == 5:
  395.             print ("[ 5 ] NOTIFIED ADD CONTACT")
  396.             if settings["autoAdd"] == True:
  397.                 client.findAndAddContactsByMid(op.param1)
  398.             client.sendMention(op.param1, settings["autoAddMessage"], [op.param1])
  399.  
  400.         if op.type == 13:
  401.             print ("[ 13 ] NOTIFIED INVITE INTO GROUP")
  402.             if settings["autoJoin"] and clientMid in op.param3:
  403.                 client.acceptGroupInvitation(op.param1)
  404.                 client.sendMention(op.param1, settings["autoJoinMessage"], [op.param2])
  405.  
  406.         if op.type == 25:
  407.             try:
  408.                 print("[ 25 ] SEND MESSAGE")
  409.                 msg = op.message
  410.                 text = str(msg.text)
  411.                 msg_id = msg.id
  412.                 receiver = msg.to
  413.                 sender = msg._from
  414.                 cmd = command(text)
  415.                 setKey = settings["keyCommand"].title()
  416.                 if settings["setKey"] == False:
  417.                     setKey = ''
  418.                 if msg.toType == 0 or msg.toType == 1 or msg.toType == 2:
  419.                     if msg.toType == 0:
  420.                         if sender != client.profile.mid:
  421.                             to = sender
  422.                         else:
  423.                             to = receiver
  424.                     elif msg.toType == 1:
  425.                         to = receiver
  426.                     elif msg.toType == 2:
  427.                         to = receiver
  428.                     if msg.contentType == 0:
  429.                         if cmd == "logout":
  430.                             client.sendMessage(to, "Berhasil mematikan selfbot")
  431.                             sys.exit("[ INFO ] BOT SHUTDOWN")
  432.                             return
  433.                         elif cmd == "restart":
  434.                             client.sendMessage(to, "Berhasil mereset bot")
  435.                             restartBot()
  436.                         elif cmd == "speed":
  437.                             start = time.time()
  438.                             client.sendMessage(to, "Menghitung kecepatan...")
  439.                             elapsed_time = time.time() - start
  440.                             client.sendMessage(to, "Kecepatan mengirim pesan {} detik".format(str(elapsed_time)))
  441.                         elif cmd == "runtime":
  442.                             timeNow = time.time()
  443.                             runtime = timeNow - clientStart
  444.                             runtime = timeChange(runtime)
  445.                             client.sendMessage(to, "Selfbot telah aktif selama {}".format(str(runtime)))
  446.                         elif cmd.startswith("setkey: "):
  447.                             sep = text.split(" ")
  448.                             key = text.replace(sep[0] + " ","")
  449.                             if " " in key:
  450.                                 client.sendMessage(to, "Key tidak bisa menggunakan spasi")
  451.                             else:
  452.                                 settings["keyCommand"] = str(key).lower()
  453.                                 client.sendMessage(to, "Berhasil mengubah set key command menjadi : 「{}」".format(str(key).lower()))
  454.                         elif cmd == "help":
  455.                             helpMessage = menuHelp()
  456.                             contact = client.getContact(sender)
  457.                             icon = "http://dl.profile.line-cdn.net/{}".format(contact.pictureStatus)
  458.                             name = contact.displayName
  459.                             link = "https://pa1.narvii.com/6547/d29a5e4bb3405d83fc15cf50ec057f41640618a8_hq.gif"
  460.                             client.sendFooter(to, helpMessage, icon, name, link)
  461.                         elif cmd == "help status":
  462.                             statusMessage = "╠══[ Status Command ]" + "\n" + \
  463.                                             "╠ MyKey" + "\n" + \
  464.                                             "╠ " + key + "Logout" + "\n" + \
  465.                                             "╠ " + key + "Restart" + "\n" + \
  466.                                             "╠ " + key + "Runtime" + "\n" + \
  467.                                             "╠ " + key + "Speed" + "\n" + \
  468.                                             "╠ " + key + "Status" + "\n" + \
  469.                             contact = client.getContact(sender)
  470.                             icon = "http://dl.profile.line-cdn.net/{}".format(contact.pictureStatus)
  471.                             name = contact.displayName
  472.                             link = "https://pa1.narvii.com/6547/d29a5e4bb3405d83fc15cf50ec057f41640618a8_hq.gif"
  473.                             client.sendFooter(to, statusMessage, icon, name, link)
  474.                         elif cmd == "texttospeech":
  475.                             helpTextToSpeech = menuTextToSpeech()
  476.                             contact = client.getContact(sender)
  477.                             icon = "http://dl.profile.line-cdn.net/{}".format(contact.pictureStatus)
  478.                             name = contact.displayName
  479.                             link = "https://pa1.narvii.com/6547/d29a5e4bb3405d83fc15cf50ec057f41640618a8_hq.gif"
  480.                             client.sendFooter(to, helpTextToSpeech, icon, name, link)
  481.                         elif cmd == "translate":
  482.                             helpTranslate = menuTranslate()
  483.                             contact = client.getContact(sender)
  484.                             icon = "http://dl.profile.line-cdn.net/{}".format(contact.pictureStatus)
  485.                             name = contact.displayName
  486.                             link = "https://pa1.narvii.com/6547/d29a5e4bb3405d83fc15cf50ec057f41640618a8_hq.gif"
  487.                             client.sendFooter(to, helpTranslate, icon, name, link)
  488.  
  489.  
  490.                         elif cmd == "status":
  491.                             try:
  492.                                 ret_ = "╔══[ Status ]"
  493.                                 if settings["autoAdd"] == True: ret_ += "\n╠ Auto Add : ON"
  494.                                 else: ret_ += "\n╠ Auto Add : OFF"
  495.                                 if settings["autoJoin"] == True: ret_ += "\n╠ Auto Join : ON"
  496.                                 else: ret_ += "\n╠ Auto Join : OFF"
  497.                                 if settings["autoJoin"] == True: ret_ += "\n╠ Auto Join Ticket : ON"
  498.                                 else: ret_ += "\n╠ Auto Join Ticket : OFF"
  499.                                 if settings["autoRead"] == True: ret_ += "\n╠ Auto Read : ON"
  500.                                 else: ret_ += "\n╠ Auto Read : OFF"
  501.                                 if settings["autoRespon"] == True: ret_ += "\n╠ Auto Respon : ON"
  502.                                 else: ret_ += "\n╠ Auto Respon : OFF"
  503.                                 if settings["checkContact"] == True: ret_ += "\n╠ Check Contact : ON"
  504.                                 else: ret_ += "\n╠ Check Contact : OFF"
  505.                                 if settings["checkPost"] == True: ret_ += "\n╠ Check Post : ON"
  506.                                 else: ret_ += "\n╠ Check Post : OFF"
  507.                                 if settings["checkSticker"] == True: ret_ += "\n╠ Check Sticker : ON"
  508.                                 else: ret_ += "\n╠ Check Sticker : OFF"
  509.                                 if settings["detectUnsend"] == True: ret_ += "\n╠ Detect Unsend : ON"
  510.                                 else: ret_ += "\n╠ Detect Unsend : OFF"
  511.                                 if settings["setKey"] == True: ret_ += "\n╠ Set Key : ON"
  512.                                 else: ret_ += "\n╠ Set Key : OFF"
  513.                                 ret_ +="\n╠ Auto Add Message : {}".format(settings["autoAddMessage"])
  514.                                 ret_ +="\n╠ Auto Join Message : {}".format(settings["autoJoinMessage"])
  515.                                 ret_ +="\n╠ Auto Respon Message : {}".format(settings["autoResponMessage"])
  516.                                 ret_ += "\n╚══[ Status ]"
  517.                                 client.sendMessage(to, str(ret_))
  518.                             except Exception as error:
  519.                                 logError(error)
  520.                         elif cmd == "autoadd on":
  521.                             if settings["autoAdd"] == True:
  522.                                 client.sendMessage(to, "Auto add telah aktif")
  523.                             else:
  524.                                 settings["autoAdd"] = True
  525.                                 client.sendMessage(to, "Berhasil mengaktifkan auto add")
  526.                         elif cmd == "autoadd off":
  527.                             if settings["autoAdd"] == False:
  528.                                 client.sendMessage(to, "Auto add telah nonaktif")
  529.                             else:
  530.                                 settings["autoAdd"] = False
  531.                                 client.sendMessage(to, "Berhasil menonaktifkan auto add")
  532.                         elif cmd == "autojoin on":
  533.                             if settings["autoJoin"] == True:
  534.                                 client.sendMessage(to, "Auto join telah aktif")
  535.                             else:
  536.                                 settings["autoJoin"] = True
  537.                                 client.sendMessage(to, "Berhasil mengaktifkan auto join")
  538.                         elif cmd == "autojoin off":
  539.                             if settings["autoJoin"] == False:
  540.                                 client.sendMessage(to, "Auto join telah nonaktif")
  541.                             else:
  542.                                 settings["autoJoin"] = False
  543.                                 client.sendMessage(to, "Berhasil menonaktifkan auto join")
  544.                         elif cmd == "autojointicket on":
  545.                             if settings["autoJoinTicket"] == True:
  546.                                 client.sendMessage(to, "Auto join ticket telah aktif")
  547.                             else:
  548.                                 settings["autoJoinTicket"] = True
  549.                                 client.sendMessage(to, "Berhasil mengaktifkan auto join ticket")
  550.                         elif cmd == "autojointicket off":
  551.                             if settings["autoJoinTicket"] == False:
  552.                                 client.sendMessage(to, "Auto join ticket telah nonaktif")
  553.                             else:
  554.                                 settings["autoJoinTicket"] = False
  555.                                 client.sendMessage(to, "Berhasil menonaktifkan auto join ticket")
  556.                         elif cmd == "autoread on":
  557.                             if settings["autoRead"] == True:
  558.                                 client.sendMessage(to, "Auto read telah aktif")
  559.                             else:
  560.                                 settings["autoRead"] = True
  561.                                 client.sendMessage(to, "Berhasil mengaktifkan auto read")
  562.                         elif cmd == "autoread off":
  563.                             if settings["autoRead"] == False:
  564.                                 client.sendMessage(to, "Auto read telah nonaktif")
  565.                             else:
  566.                                 settings["autoRead"] = False
  567.                                 client.sendMessage(to, "Berhasil menonaktifkan auto read")
  568.                         elif cmd == "autorespon on":
  569.                             if settings["autoRespon"] == True:
  570.                                 client.sendMessage(to, "Auto respon telah aktif")
  571.                             else:
  572.                                 settings["autoRespon"] = True
  573.                                 client.sendMessage(to, "Berhasil mengaktifkan auto respon")
  574.                         elif cmd == "autorespon off":
  575.                             if settings["autoRespon"] == False:
  576.                                 client.sendMessage(to, "Auto respon telah nonaktif")
  577.                             else:
  578.                                 settings["autoRespon"] = False
  579.                                 client.sendMessage(to, "Berhasil menonaktifkan auto respon")
  580.                         elif cmd == "checkcontact on":
  581.                             if settings["checkContact"] == True:
  582.                                 client.sendMessage(to, "Check details contact telah aktif")
  583.                             else:
  584.                                 settings["checkContact"] = True
  585.                                 client.sendMessage(to, "Berhasil mengaktifkan check details contact")
  586.                         elif cmd == "checkcontact off":
  587.                             if settings["checkContact"] == False:
  588.                                 client.sendMessage(to, "Check details contact telah nonaktif")
  589.                             else:
  590.                                 settings["checkContact"] = False
  591.                                 client.sendMessage(to, "Berhasil menonaktifkan Check details contact")
  592.                         elif cmd == "checkpost on":
  593.                             if settings["checkPost"] == True:
  594.                                 client.sendMessage(to, "Check details post telah aktif")
  595.                             else:
  596.                                 settings["checkPost"] = True
  597.                                 client.sendMessage(to, "Berhasil mengaktifkan check details post")
  598.                         elif cmd == "checkpost off":
  599.                             if settings["checkPost"] == False:
  600.                                 client.sendMessage(to, "Check details post telah nonaktif")
  601.                             else:
  602.                                 settings["checkPost"] = False
  603.                                 client.sendMessage(to, "Berhasil menonaktifkan check details post")
  604.                         elif cmd == "checksticker on":
  605.                             if settings["checkSticker"] == True:
  606.                                 client.sendMessage(to, "Check details sticker telah aktif")
  607.                             else:
  608.                                 settings["checkSticker"] = True
  609.                                 client.sendMessage(to, "Berhasil mengaktifkan check details sticker")
  610.                         elif cmd == "checksticker off":
  611.                             if settings["checkSticker"] == False:
  612.                                 client.sendMessage(to, "Check details sticker telah nonaktif")
  613.                             else:
  614.                                 settings["checkSticker"] = False
  615.                                 client.sendMessage(to, "Berhasil menonaktifkan check details sticker")
  616.                         elif cmd == "detectunsend on":
  617.                             if settings["detectUnsend"] == True:
  618.                                 client.sendMessage(to, "Detect unsend telah aktif")
  619.                             else:
  620.                                 settings["detectUnsend"] = True
  621.                                 client.sendMessage(to, "Berhasil mengaktifkan detect unsend")
  622.                         elif cmd == "detectunsend off":
  623.                             if settings["detectUnsend"] == False:
  624.                                 client.sendMessage(to, "Detect unsend telah nonaktif")
  625.                             else:
  626.                                 settings["detectUnsend"] = False
  627.                                 client.sendMessage(to, "Berhasil menonaktifkan detect unsend")
  628.                         elif cmd.startswith("setautoaddmessage: "):
  629.                             sep = text.split(" ")
  630.                             txt = text.replace(sep[0] + " ","")
  631.                             try:
  632.                                 settings["autoAddMessage"] = txt
  633.                                 client.sendMessage(to, "Berhasil mengubah pesan auto add menjadi : 「{}」".format(txt))
  634.                             except:
  635.                                 client.sendMessage(to, "Gagal mengubah pesan auto add")
  636.                         elif cmd.startswith("setautoresponmessage: "):
  637.                             sep = text.split(" ")
  638.                             txt = text.replace(sep[0] + " ","")
  639.                             try:
  640.                                 settings["autoResponMessage"] = txt
  641.                                 client.sendMessage(to, "Berhasil mengubah pesan auto respon menjadi : 「{}」".format(txt))
  642.                             except:
  643.                                 client.sendMessage(to, "Gagal mengubah pesan auto respon")
  644.                         elif cmd.startswith("setautojoinmessage: "):
  645.                             sep = text.split(" ")
  646.                             txt = text.replace(sep[0] + " ","")
  647.                             try:
  648.                                 settings["autoJoinMessage"] = txt
  649.                                 client.sendMessage(to, "Berhasil mengubah pesan auto join menjadi : 「{}」".format(txt))
  650.                             except:
  651.                                 client.sendMessage(to, "Gagal mengubah pesan auto join")
  652.  
  653.  
  654.                         elif cmd.startswith("changename: "):
  655.                             sep = text.split(" ")
  656.                             name = text.replace(sep[0] + " ","")
  657.                             if len(name) <= 20:
  658.                                 profile = client.getProfile()
  659.                                 profile.displayName = name
  660.                                 client.updateProfile(profile)
  661.                                 client.sendMessage(to, "Berhasil mengubah nama menjadi : {}".format(name))
  662.                         elif cmd.startswith("changebio: "):
  663.                             sep = text.split(" ")
  664.                             bio = text.replace(sep[0] + " ","")
  665.                             if len(bio) <= 500:
  666.                                 profile = client.getProfile()
  667.                                 profile.displayName = bio
  668.                                 client.updateProfile(profile)
  669.                                 client.sendMessage(to, "Berhasil mengubah bio menjadi : {}".format(bio))
  670.                         elif cmd == "me":
  671.                             client.sendMention(to, "@!", [sender])
  672.                             client.sendContact(to, sender)
  673.                         elif cmd == "myprofile":
  674.                             contact = client.getContact(sender)
  675.                             cover = client.getProfileCoverURL(sender)
  676.                             result = "╔══[ Details Profile ]"
  677.                             result += "\n╠ Display Name : @!"
  678.                             result += "\n╠ Mid : {}".format(contact.mid)
  679.                             result += "\n╠ Status Message : {}".format(contact.statusMessage)
  680.                             result += "\n╠ Picture Profile : http://dl.profile.line-cdn.net/{}".format(contact.pictureStatus)
  681.                             result += "\n╠ Cover : {}".format(str(cover))
  682.                             result += "\n╚══[ Finish ]"
  683.                             client.sendImageWithURL(to, "http://dl.profile.line-cdn.net/{}".format(contact.pictureStatus))
  684.                             client.sendMention(to, result, [sender])
  685.                         elif cmd == "mymid":
  686.                             contact = client.getContact(sender)
  687.                             client.sendMention(to, "@!: {}".format(contact.mid), [sender])
  688.                         elif cmd == "myname":
  689.                             contact = client.getContact(sender)
  690.                             client.sendMention(to, "@!: {}".format(contact.displayName), [sender])
  691.                         elif cmd == "mybio":
  692.                             contact = client.getContact(sender)
  693.                             client.sendMention(to, "@!: {}".format(contact.statusMessage), [sender])
  694.                         elif cmd == "mypicture":
  695.                             contact = client.getContact(sender)
  696.                             client.sendImageWithURL(to, "http://dl.profile.line-cdn.net/{}".format(contact.pictureStatus))
  697.                         elif cmd == "myvideoprofile":
  698.                             contact = client.getContact(sender)
  699.                             if contact.videoProfile == None:
  700.                                 return client.sendMessage(to, "Anda tidak memiliki video profile")
  701.                             client.sendVideoWithURL(to, "http://dl.profile.line-cdn.net/{}/vp".format(contact.pictureStatus))
  702.                         elif cmd == "mycover":
  703.                             cover = client.getProfileCoverURL(sender)
  704.                             client.sendImageWithURL(to, str(cover))
  705.                         elif cmd.startswith("getmid "):
  706.                             if 'MENTION' in msg.contentMetadata.keys()!= None:
  707.                                 names = re.findall(r'@(\w+)', text)
  708.                                 mention = ast.literal_eval(msg.contentMetadata['MENTION'])
  709.                                 mentionees = mention['MENTIONEES']
  710.                                 lists = []
  711.                                 for mention in mentionees:
  712.                                     if mention["M"] not in lists:
  713.                                         lists.append(mention["M"])
  714.                                 for ls in lists:
  715.                                     client.sendMention(to, "@!: {}".format(ls), [ls])
  716.                         elif cmd.startswith("getname "):
  717.                             if 'MENTION' in msg.contentMetadata.keys()!= None:
  718.                                 names = re.findall(r'@(\w+)', text)
  719.                                 mention = ast.literal_eval(msg.contentMetadata['MENTION'])
  720.                                 mentionees = mention['MENTIONEES']
  721.                                 lists = []
  722.                                 for mention in mentionees:
  723.                                     if mention["M"] not in lists:
  724.                                         lists.append(mention["M"])
  725.                                 for ls in lists:
  726.                                     contact = client.getContact(ls)
  727.                                     client.sendMention(to, "@!: {}".format(contact.displayName), [ls])
  728.                         elif cmd.startswith("getbio "):
  729.                             if 'MENTION' in msg.contentMetadata.keys()!= None:
  730.                                 names = re.findall(r'@(\w+)', text)
  731.                                 mention = ast.literal_eval(msg.contentMetadata['MENTION'])
  732.                                 mentionees = mention['MENTIONEES']
  733.                                 lists = []
  734.                                 for mention in mentionees:
  735.                                     if mention["M"] not in lists:
  736.                                         lists.append(mention["M"])
  737.                                 for ls in lists:
  738.                                     contact = client.getContact(ls)
  739.                                     client.sendMention(to, "@!: {}".format(contact.statusMessage), [ls])
  740.                         elif cmd.startswith("getpicture "):
  741.                             if 'MENTION' in msg.contentMetadata.keys()!= None:
  742.                                 names = re.findall(r'@(\w+)', text)
  743.                                 mention = ast.literal_eval(msg.contentMetadata['MENTION'])
  744.                                 mentionees = mention['MENTIONEES']
  745.                                 lists = []
  746.                                 for mention in mentionees:
  747.                                     if mention["M"] not in lists:
  748.                                         lists.append(mention["M"])
  749.                                 for ls in lists:
  750.                                     contact = client.getContact(ls)
  751.                                     client.sendImageWithURL(to, "http://dl.profile.line-cdn.net/{}".format(contact.pictureStatus))
  752.                         elif cmd.startswith("getvideoprofile "):
  753.                             if 'MENTION' in msg.contentMetadata.keys()!= None:
  754.                                 names = re.findall(r'@(\w+)', text)
  755.                                 mention = ast.literal_eval(msg.contentMetadata['MENTION'])
  756.                                 mentionees = mention['MENTIONEES']
  757.                                 lists = []
  758.                                 for mention in mentionees:
  759.                                     if mention["M"] not in lists:
  760.                                         lists.append(mention["M"])
  761.                                 for ls in lists:
  762.                                     contact = client.getContact(ls)
  763.                                     if contact.videoProfile == None:
  764.                                         return client.sendMention(to, "@!tidak memiliki video profile", [ls])
  765.                                     client.sendVideoWithURL(to, "http://dl.profile.line-cdn.net/{}/vp".format(contact.pictureStatus))
  766.                         elif cmd.startswith("getcover "):
  767.                             if 'MENTION' in msg.contentMetadata.keys()!= None:
  768.                                 names = re.findall(r'@(\w+)', text)
  769.                                 mention = ast.literal_eval(msg.contentMetadata['MENTION'])
  770.                                 mentionees = mention['MENTIONEES']
  771.                                 lists = []
  772.                                 for mention in mentionees:
  773.                                     if mention["M"] not in lists:
  774.                                         lists.append(mention["M"])
  775.                                 for ls in lists:
  776.                                     cover = client.getProfileCoverURL(ls)
  777.                                     client.sendImageWithURL(to, str(cover))
  778.                         elif cmd.startswith("cloneprofile "):
  779.                             if 'MENTION' in msg.contentMetadata.keys()!= None:
  780.                                 names = re.findall(r'@(\w+)', text)
  781.                                 mention = ast.literal_eval(msg.contentMetadata['MENTION'])
  782.                                 mentionees = mention['MENTIONEES']
  783.                                 lists = []
  784.                                 for mention in mentionees:
  785.                                     if mention["M"] not in lists:
  786.                                         lists.append(mention["M"])
  787.                                 for ls in lists:
  788.                                     client.cloneContactProfile(ls)
  789.                                     client.sendContact(to, sender)
  790.                                     client.sendMessage(to, "Berhasil clone profile")
  791.                         elif cmd == "restoreprofile":
  792.                             try:
  793.                                 clientProfile = client.getProfile()
  794.                                 clientProfile.displayName = str(settings["myProfile"]["displayName"])
  795.                                 clientProfile.statusMessage = str(settings["myProfile"]["statusMessage"])
  796.                                 clientPictureStatus = client.downloadFileURL("http://dl.profile.line-cdn.net/{}".format(str(settings["myProfile"]["pictureStatus"])), saveAs="LineAPI/tmp/backupPicture.bin")
  797.                                 coverId = str(settings["myProfile"]["coverId"])
  798.                                 client.updateProfile(clientProfile)
  799.                                 client.updateProfileCoverById(coverId)
  800.                                 client.updateProfilePicture(clientPictureStatus)
  801.                                 client.sendMessage(to, "Berhasil restore profile")
  802.                                 client.sendContact(to, sender)
  803.                                 client.deleteFile(clientPictureStatus)
  804.                             except Exception as error:
  805.                                 logError(error)
  806.                                 client.sendMessage(to, "Gagal restore profile")
  807.                         elif cmd == "backupprofile":
  808.                             try:
  809.                                 clientProfile = client.getProfile()
  810.                                 settings["myProfile"]["displayName"] = str(clientProfile.displayName)
  811.                                 settings["myProfile"]["statusMessage"] = str(clientProfile.statusMessage)
  812.                                 settings["myProfile"]["pictureStatus"] = str(clientProfile.pictureStatus)
  813.                                 coverId = client.getProfileDetail()["result"]["objectId"]
  814.                                 settings["myProfile"]["coverId"] = str(coverId)
  815.                                 client.sendMessage(to, "Berhasil backup profile")
  816.                             except Exception as error:
  817.                                 logError(error)
  818.                                 client.sendMessage(to, "Gagal backup profile")
  819.                         elif cmd == "friendlist":
  820.                             contacts = client.getAllContactIds()
  821.                             num = 0
  822.                             result = "╔══[ Friend List ]"
  823.                             for listContact in contacts:
  824.                                 contact = client.getContact(listContact)
  825.                                 num += 1
  826.                                 result += "\n╠ {}. {}".format(num, contact.displayName)
  827.                             result += "\n╚══[ Total {} Friend ]".format(len(contacts))
  828.                             client.sendMessage(to, result)
  829.                         elif cmd.startswith("friendinfo "):
  830.                             sep = text.split(" ")
  831.                             query = text.replace(sep[0] + " ","")
  832.                             contacts = client.getAllContactIds()
  833.                             try:
  834.                                 listContact = contacts[int(query)-1]
  835.                                 contact = client.getContact(listContact)
  836.                                 cover = client.getProfileCoverURL(listContact)
  837.                                 result = "╔══[ Details Profile ]"
  838.                                 result += "\n╠ Display Name : @!"
  839.                                 result += "\n╠ Mid : {}".format(contact.mid)
  840.                                 result += "\n╠ Status Message : {}".format(contact.statusMessage)
  841.                                 result += "\n╠ Picture Profile : http://dl.profile.line-cdn.net/{}".format(contact.pictureStatus)
  842.                                 result += "\n╠ Cover : {}".format(str(cover))
  843.                                 result += "\n╚══[ Finish ]"
  844.                                 client.sendImageWithURL(to, "http://dl.profile.line-cdn.net/{}".format(contact.pictureStatus))
  845.                                 client.sendMention(to, result, [contact.mid])
  846.                             except Exception as error:
  847.                                 logError(error)
  848.                         elif cmd == "blocklist":
  849.                             blockeds = client.getBlockedContactIds()
  850.                             num = 0
  851.                             result = "╔══[ List Blocked ]"
  852.                             for listBlocked in blockeds:
  853.                                 contact = client.getContact(listBlocked)
  854.                                 num += 1
  855.                                 result += "\n╠ {}. {}".format(num, contact.displayName)
  856.                             result += "\n╚══[ Total {} Blocked ]".format(len(blockeds))
  857.                             client.sendMessage(to, result)
  858.                         elif cmd.startswith("friendbroadcast: "):
  859.                             sep = text.split(" ")
  860.                             txt = text.replace(sep[0] + " ","")
  861.                             contacts = client.getAllContactIds()
  862.                             for contact in contacts:
  863.                                 client.sendMessage(contact, "[ Broadcast ]\n{}".format(str(txt)))
  864.                             client.sendMessage(to, "Berhasil broadcast ke {} teman".format(str(len(contacts))))
  865.  
  866.  
  867.                         elif cmd.startswith("changegroupname: "):
  868.                             if msg.toType == 2:
  869.                                 sep = text.split(" ")
  870.                                 groupname = text.replace(sep[0] + " ","")
  871.                                 if len(groupname) <= 20:
  872.                                     group = client.getGroup(to)
  873.                                     group.name = groupname
  874.                                     client.updateGroup(group)
  875.                                     client.sendMessage(to, "Berhasil mengubah nama group menjadi : {}".format(groupname))
  876.                         elif cmd == "openqr":
  877.                             if msg.toType == 2:
  878.                                 group = client.getGroup(to)
  879.                                 group.preventedJoinByTicket = False
  880.                                 client.updateGroup(group)
  881.                                 groupUrl = client.reissueGroupTicket(to)
  882.                                 client.sendMessage(to, "Berhasil membuka QR Group\n\nGroupURL : line://ti/g/{}".format(groupUrl))
  883.                         elif cmd == "closeqr":
  884.                             if msg.toType == 2:
  885.                                 group = client.getGroup(to)
  886.                                 group.preventedJoinByTicket = True
  887.                                 client.updateGroup(group)
  888.                                 client.sendMessage(to, "Berhasil menutup QR Group")
  889.                         elif cmd == "grouppicture":
  890.                             if msg.toType == 2:
  891.                                 group = client.getGroup(to)
  892.                                 groupPicture = "http://dl.profile.line-cdn.net/{}".format(group.pictureStatus)
  893.                                 client.sendImageWithURL(to, groupPicture)
  894.                         elif cmd == "groupname":
  895.                             if msg.toType == 2:
  896.                                 group = client.getGroup(to)
  897.                                 client.sendMessage(to, "Nama Group : {}".format(group.name))
  898.                         elif cmd == "groupid":
  899.                             if msg.toType == 2:
  900.                                 group = client.getGroup(to)
  901.                                 client.sendMessage(to, "Group ID : {}".format(group.id))
  902.                         elif cmd == "grouplist":
  903.                             groups = client.getGroupIdsJoined()
  904.                             ret_ = "╔══[ Group List ]"
  905.                             no = 0
  906.                             for gid in groups:
  907.                                 group = client.getGroup(gid)
  908.                                 no += 1
  909.                                 ret_ += "\n╠ {}. {} | {}".format(str(no), str(group.name), str(len(group.members)))
  910.                             ret_ += "\n╚══[ Total {} Groups ]".format(str(len(groups)))
  911.                             client.sendMessage(to, str(ret_))
  912.                         elif cmd == "memberlist":
  913.                             if msg.toType == 2:
  914.                                 group = client.getGroup(to)
  915.                                 num = 0
  916.                                 ret_ = "╔══[ List Member ]"
  917.                                 for contact in group.members:
  918.                                     num += 1
  919.                                     ret_ += "\n╠ {}. {}".format(num, contact.displayName)
  920.                                 ret_ += "\n╚══[ Total {} Members]".format(len(group.members))
  921.                                 client.sendMessage(to, ret_)
  922.                         elif cmd == "pendinglist":
  923.                             if msg.toType == 2:
  924.                                 group = client.getGroup(to)
  925.                                 ret_ = "╔══[ Pending List ]"
  926.                                 no = 0
  927.                                 if group.invitee is None or group.invitee == []:
  928.                                     return client.sendMessage(to, "Tidak ada pendingan")
  929.                                 else:
  930.                                     for pending in group.invitee:
  931.                                         no += 1
  932.                                         ret_ += "\n╠ {}. {}".format(str(no), str(pending.displayName))
  933.                                     ret_ += "\n╚══[ Total {} Pending]".format(str(len(group.invitee)))
  934.                                     client.sendMessage(to, str(ret_))
  935.                         elif cmd == "groupinfo":
  936.                             group = client.getGroup(to)
  937.                             try:
  938.                                 try:
  939.                                     groupCreator = group.creator.mid
  940.                                 except:
  941.                                     groupCreator = "Tidak ditemukan"
  942.                                 if group.invitee is None:
  943.                                     groupPending = "0"
  944.                                 else:
  945.                                     groupPending = str(len(group.invitee))
  946.                                 if group.preventedJoinByTicket == True:
  947.                                     groupQr = "Tertutup"
  948.                                     groupTicket = "Tidak ada"
  949.                                 else:
  950.                                     groupQr = "Terbuka"
  951.                                     groupTicket = "https://line.me/R/ti/g/{}".format(str(client.reissueGroupTicket(group.id)))
  952.                                 ret_ = "╔══[ Group Information ]"
  953.                                 ret_ += "\n╠ Nama Group : {}".format(group.name)
  954.                                 ret_ += "\n╠ ID Group : {}".format(group.id)
  955.                                 ret_ += "\n╠ Pembuat : @!"
  956.                                 ret_ += "\n╠ Jumlah Member : {}".format(str(len(group.members)))
  957.                                 ret_ += "\n╠ Jumlah Pending : {}".format(groupPending)
  958.                                 ret_ += "\n╠ Group Qr : {}".format(groupQr)
  959.                                 ret_ += "\n╠ Group Ticket : {}".format(groupTicket)
  960.                                 ret_ += "\n╚══[ Success ]"
  961.                                 client.sendImageWithURL(to, "http://dl.profile.line-cdn.net/{}".format(group.pictureStatus))
  962.                                 client.sendMention(to, str(ret_), [groupCreator])
  963.                             except:
  964.                                 ret_ = "╔══[ Group Information ]"
  965.                                 ret_ += "\n╠ Nama Group : {}".format(group.name)
  966.                                 ret_ += "\n╠ ID Group : {}".format(group.id)
  967.                                 ret_ += "\n╠ Pembuat : {}".format(groupCreator)
  968.                                 ret_ += "\n╠ Jumlah Member : {}".format(str(len(group.members)))
  969.                                 ret_ += "\n╠ Jumlah Pending : {}".format(groupPending)
  970.                                 ret_ += "\n╠ Group Qr : {}".format(groupQr)
  971.                                 ret_ += "\n╠ Group Ticket : {}".format(groupTicket)
  972.                                 ret_ += "\n╚══[ Success ]"
  973.                                 client.sendImageWithURL(to, "http://dl.profile.line-cdn.net/{}".format(group.pictureStatus))
  974.                                 client.sendMessage(to, str(ret_))
  975.                         elif cmd.startswith("groupbroadcast: "):
  976.                             sep = text.split(" ")
  977.                             txt = text.replace(sep[0] + " ","")
  978.                             groups = client.getGroupIdsJoined()
  979.                             for group in groups:
  980.                                 client.sendMessage(group, "[ Broadcast ]\n{}".format(str(txt)))
  981.                             client.sendMessage(to, "Berhasil broadcast ke {} group".format(str(len(groups))))
  982.  
  983.  
  984.                         elif cmd == 'mentionall':
  985.                             group = client.getGroup(to)
  986.                             midMembers = [contact.mid for contact in group.members]
  987.                             midSelect = len(midMembers)//100
  988.                             for mentionMembers in range(midSelect+1):
  989.                                 no = 0
  990.                                 ret_ = "╔══[ Mention Members ]"
  991.                                 dataMid = []
  992.                                 for dataMention in group.members[mentionMembers*100 : (mentionMembers+1)*100]:
  993.                                     dataMid.append(dataMention.mid)
  994.                                     no += 1
  995.                                     ret_ += "\n╠ {}. @!".format(str(no))
  996.                                 ret_ += "\n╚══[ Total {} Members]".format(str(len(dataMid)))
  997.                                 client.sendMention(to, ret_, dataMid)
  998.                         elif cmd == "lurking on":
  999.                             tz = pytz.timezone("Asia/Makassar")
  1000.                             timeNow = datetime.now(tz=tz)
  1001.                             day = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday","Friday", "Saturday"]
  1002.                             hari = ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"]
  1003.                             bulan = ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"]
  1004.                             hr = timeNow.strftime("%A")
  1005.                             bln = timeNow.strftime("%m")
  1006.                             for i in range(len(day)):
  1007.                                 if hr == day[i]: hasil = hari[i]
  1008.                             for k in range(0, len(bulan)):
  1009.                                 if bln == str(k): bln = bulan[k-1]
  1010.                             readTime = hasil + ", " + timeNow.strftime('%d') + " - " + bln + " - " + timeNow.strftime('%Y') + "\nJam : [ " + timeNow.strftime('%H:%M:%S') + " ]"
  1011.                             if to in read['readPoint']:
  1012.                                 try:
  1013.                                     del read['readPoint'][to]
  1014.                                     del read['readMember'][to]
  1015.                                 except:
  1016.                                     pass
  1017.                                 read['readPoint'][to] = msg_id
  1018.                                 read['readMember'][to] = []
  1019.                                 client.sendMessage(to, "Lurking telah diaktifkan")
  1020.                             else:
  1021.                                 try:
  1022.                                     del read['readPoint'][to]
  1023.                                     del read['readMember'][to]
  1024.                                 except:
  1025.                                     pass
  1026.                                 read['readPoint'][to] = msg_id
  1027.                                 read['readMember'][to] = []
  1028.                                 client.sendMessage(to, "Set reading point : \n{}".format(readTime))
  1029.                         elif cmd == "lurking off":
  1030.                             tz = pytz.timezone("Asia/Makassar")
  1031.                             timeNow = datetime.now(tz=tz)
  1032.                             day = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday","Friday", "Saturday"]
  1033.                             hari = ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"]
  1034.                             bulan = ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"]
  1035.                             hr = timeNow.strftime("%A")
  1036.                             bln = timeNow.strftime("%m")
  1037.                             for i in range(len(day)):
  1038.                                 if hr == day[i]: hasil = hari[i]
  1039.                             for k in range(0, len(bulan)):
  1040.                                 if bln == str(k): bln = bulan[k-1]
  1041.                             readTime = hasil + ", " + timeNow.strftime('%d') + " - " + bln + " - " + timeNow.strftime('%Y') + "\nJam : [ " + timeNow.strftime('%H:%M:%S') + " ]"
  1042.                             if to not in read['readPoint']:
  1043.                                 client.sendMessage(to,"Lurking telah dinonaktifkan")
  1044.                             else:
  1045.                                 try:
  1046.                                     del read['readPoint'][to]
  1047.                                     del read['readMember'][to]
  1048.                                 except:
  1049.                                     pass
  1050.                                 client.sendMessage(to, "Delete reading point : \n{}".format(readTime))
  1051.                         elif cmd == "lurking":
  1052.                             if to in read['readPoint']:
  1053.                                 if read["readMember"][to] == []:
  1054.                                     return client.sendMessage(to, "Tidak Ada Sider")
  1055.                                 else:
  1056.                                     no = 0
  1057.                                     result = "╔══[ Reader ]"
  1058.                                     for dataRead in read["readMember"][to]:
  1059.                                         no += 1
  1060.                                         result += "\n╠ {}. @!".format(str(no))
  1061.                                     result += "\n╚══[ Total {} Sider ]".format(str(len(read["readMember"][to])))
  1062.                                     client.sendMention(to, result, read["readMember"][to])
  1063.                                     read['readMember'][to] = []
  1064.                         elif cmd == "changepictureprofile":
  1065.                             settings["changePictureProfile"] = True
  1066.                             client.sendMessage(to, "Silahkan kirim gambarnya")
  1067.                         elif cmd == "changegrouppicture":
  1068.                             if msg.toType == 2:
  1069.                                 if to not in settings["changeGroupPicture"]:
  1070.                                     settings["changeGroupPicture"].append(to)
  1071.                                 client.sendMessage(to, "Silahkan kirim gambarnya")
  1072.                         elif cmd == "mimic on":
  1073.                             if settings["mimic"]["status"] == True:
  1074.                                 client.sendMessage(to, "Reply message telah aktif")
  1075.                             else:
  1076.                                 settings["mimic"]["status"] = True
  1077.                                 client.sendMessage(to, "Berhasil mengaktifkan reply message")
  1078.                         elif cmd == "mimic off":
  1079.                             if settings["mimic"]["status"] == False:
  1080.                                 client.sendMessage(to, "Reply message telah nonaktif")
  1081.                             else:
  1082.                                 settings["mimic"]["status"] = False
  1083.                                 client.sendMessage(to, "Berhasil menonaktifkan reply message")
  1084.                         elif cmd == "mimiclist":
  1085.                             if settings["mimic"]["target"] == {}:
  1086.                                 client.sendMessage(to, "Tidak Ada Target")
  1087.                             else:
  1088.                                 no = 0
  1089.                                 result = "╔══[ Mimic List ]"
  1090.                                 target = []
  1091.                                 for mid in settings["mimic"]["target"]:
  1092.                                     target.append(mid)
  1093.                                     no += 1
  1094.                                     result += "\n╠ {}. @!".format(no)
  1095.                                 result += "\n╚══[ Total {} Mimic ]".format(str(len(target)))
  1096.                                 client.sendMention(to, result, target)
  1097.                         elif cmd.startswith("mimicadd "):
  1098.                             if 'MENTION' in msg.contentMetadata.keys()!= None:
  1099.                                 names = re.findall(r'@(\w+)', text)
  1100.                                 mention = ast.literal_eval(msg.contentMetadata['MENTION'])
  1101.                                 mentionees = mention['MENTIONEES']
  1102.                                 lists = []
  1103.                                 for mention in mentionees:
  1104.                                     if mention["M"] not in lists:
  1105.                                         lists.append(mention["M"])
  1106.                                 for ls in lists:
  1107.                                     try:
  1108.                                         if ls in settings["mimic"]["target"]:
  1109.                                             client.sendMessage(to, "Target sudah ada dalam list")
  1110.                                         else:
  1111.                                             settings["mimic"]["target"][ls] = True
  1112.                                             client.sendMessage(to, "Berhasil menambahkan target")
  1113.                                     except:
  1114.                                         client.sendMessage(to, "Gagal menambahkan target")
  1115.                         elif cmd.startswith("mimicdel "):
  1116.                             if 'MENTION' in msg.contentMetadata.keys()!= None:
  1117.                                 names = re.findall(r'@(\w+)', text)
  1118.                                 mention = ast.literal_eval(msg.contentMetadata['MENTION'])
  1119.                                 mentionees = mention['MENTIONEES']
  1120.                                 lists = []
  1121.                                 for mention in mentionees:
  1122.                                     if mention["M"] not in lists:
  1123.                                         lists.append(mention["M"])
  1124.                                 for ls in lists:
  1125.                                     try:
  1126.                                         if ls not in settings["mimic"]["target"]:
  1127.                                             client.sendMessage(to, "Target sudah tida didalam list")
  1128.                                         else:
  1129.                                             del settings["mimic"]["target"][ls]
  1130.                                             client.sendMessage(to, "Berhasil menghapus target")
  1131.                                     except:
  1132.                                         client.sendMessage(to, "Gagal menghapus target")
  1133.  
  1134.  
  1135.                         elif cmd.startswith("instainfo"):
  1136.                             sep = text.split(" ")
  1137.                             txt = text.replace(sep[0] + " ","")
  1138.                             url = requests.get("http://rahandiapi.herokuapp.com/instainfo/{}?key=betakey".format(txt))
  1139.                             data = url.json()
  1140.                             icon = "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Instagram_icon.png/599px-Instagram_icon.png"
  1141.                             name = "Instagram"
  1142.                             link = "https://www.instagram.com/{}".format(data["result"]["username"])
  1143.                             result = "╔══[ Instagram Info ]"
  1144.                             result += "\n╠ Name : {}".format(data["result"]["name"])
  1145.                             result += "\n╠ Username: {}".format(data["result"]["username"])
  1146.                             result += "\n╠ Bio : {}".format(data["result"]["bio"])
  1147.                             result += "\n╠ Follower : {}".format(data["result"]["follower"])
  1148.                             result += "\n╠ Following : {}".format(data["result"]["following"])
  1149.                             result += "\n╠ Private : {}".format(data["result"]["private"])
  1150.                             result += "\n╠ Post : {}".format(data["result"]["mediacount"])
  1151.                             result += "\n╚══[ Finish ]"
  1152.                             client.sendImageWithURL(to, data["result"]["url"])
  1153.                             client.sendFooter(to, result, icon, name, link)
  1154.                         elif cmd.startswith("instastory "):
  1155.                             sep = text.split(" ")
  1156.                             query = text.replace(sep[0] + " ","")
  1157.                             cond = query.split("|")
  1158.                             search = str(cond[0])
  1159.                             if len(cond) == 2:
  1160.                                 url = requests.get("http://rahandiapi.herokuapp.com/instastory/{}?key=betakey".format(search))
  1161.                                 data = url.json()
  1162.                                 num = int(cond[1])
  1163.                                 if num <= len(data["url"]):
  1164.                                     search = data["url"][num - 1]
  1165.                                     if search["tipe"] == 1:
  1166.                                         client.sendImageWithURL(to, str(search["link"]))
  1167.                                     elif search["tipe"] == 2:
  1168.                                         client.sendVideoWithURL(to, str(search["link"]))
  1169.                         elif cmd == "quotes":
  1170.                             url = requests.get("https://botfamily.faith/api/quotes/?apikey=beta")
  1171.                             data = url.json()
  1172.                             result = "╔══[ Quotes ]"
  1173.                             result += "\n╠ Author : {}".format(data["result"]["author"])
  1174.                             result += "\n╠ Category : {}".format(data["result"]["category"])
  1175.                             result += "\n╠ Quote : {}".format(data["result"]["quote"])
  1176.                             result += "\n╚══[ Finish ]"
  1177.                             client.sendMessage(to, result)
  1178.                         elif cmd.startswith("say-"):
  1179.                             sep = text.split("-")
  1180.                             sep = sep[1].split(" ")
  1181.                             lang = sep[0]
  1182.                             if settings["setKey"] == False:
  1183.                                 txt = text.lower().replace("say-" + lang + " ","")
  1184.                             else:
  1185.                                 txt = text.lower().replace(settings["keyCommand"] + "say-" + lang + " ","")
  1186.                             if lang not in language["gtts"]:
  1187.                                 return client.sendMessage(to, "Bahasa {} tidak ditemukan".format(lang))
  1188.                             tts = gTTS(text=txt, lang=lang)
  1189.                             tts.save("line/tmp/tts-{}.mp3".format(lang))
  1190.                             client.sendAudio(to, "line/tmp/tts-{}.mp3".format(lang))
  1191.                             client.deleteFile("line/tmp/tts-{}.mp3".format(lang))
  1192.                         elif cmd.startswith("searchyoutube "):
  1193.                             sep = text.split(" ")
  1194.                             txt = msg.text.replace(sep[0] + " ","")
  1195.                             cond = txt.split("|")
  1196.                             search = cond[0]
  1197.                             url = requests.get("http://api.w3hills.com/youtube/search?keyword={}&api_key=86A7FCF3-6CAF-DEB9-E214-B74BDB835B5B".format(search))
  1198.                             data = url.json()
  1199.                             if len(cond) == 1:
  1200.                                 no = 0
  1201.                                 result = "╔══[ Youtube Search ]"
  1202.                                 for anu in data["videos"]:
  1203.                                     no += 1
  1204.                                     result += "\n╠ {}. {}".format(str(no),str(anu["title"]))
  1205.                                 result += "\n╚══[ Total {} Result ]".format(str(len(data["videos"])))
  1206.                                 client.sendMessage(to, result)
  1207.                             elif len(cond) == 2:
  1208.                                 num = int(str(cond[1]))
  1209.                                 if num <= len(data):
  1210.                                     search = data["videos"][num - 1]
  1211.                                     ret_ = "╔══[ Youtube Info ]"
  1212.                                     ret_ += "\n╠ Channel : {}".format(str(search["publish"]["owner"]))
  1213.                                     ret_ += "\n╠ Title : {}".format(str(search["title"]))
  1214.                                     ret_ += "\n╠ Release : {}".format(str(search["publish"]["date"]))
  1215.                                     ret_ += "\n╠ Viewers : {}".format(str(search["stats"]["views"]))
  1216.                                     ret_ += "\n╠ Likes : {}".format(str(search["stats"]["likes"]))
  1217.                                     ret_ += "\n╠ Dislikes : {}".format(str(search["stats"]["dislikes"]))
  1218.                                     ret_ += "\n╠ Rating : {}".format(str(search["stats"]["rating"]))
  1219.                                     ret_ += "\n╠ Description : {}".format(str(search["description"]))
  1220.                                     ret_ += "\n╚══[ {} ]".format(str(search["webpage"]))
  1221.                                     client.sendImageWithURL(to, str(search["thumbnail"]))
  1222.                                     client.sendMessage(to, str(ret_))
  1223.                         elif cmd.startswith("searchimage "):
  1224.                             sep = text.split(" ")
  1225.                             txt = text.replace(sep[0] + " ","")
  1226.                             url = requests.get("http://rahandiapi.herokuapp.com/imageapi?key=betakey&q={}".format(txt))
  1227.                             data = url.json()
  1228.                             client.sendImageWithURL(to, random.choice(data["result"]))
  1229.                         elif cmd.startswith("searchmusic "):
  1230.                             sep = text.split(" ")
  1231.                             query = text.replace(sep[0] + " ","")
  1232.                             cond = query.split("|")
  1233.                             search = str(cond[0])
  1234.                             url = requests.get("http://api.ntcorp.us/joox/search?q={}".format(str(search)))
  1235.                             data = url.json()
  1236.                             if len(cond) == 1:
  1237.                                 num = 0
  1238.                                 ret_ = "╔══[ Result Music ]"
  1239.                                 for music in data["result"]:
  1240.                                     num += 1
  1241.                                     ret_ += "\n╠ {}. {}".format(str(num), str(music["single"]))
  1242.                                 ret_ += "\n╚══[ Total {} Music ]".format(str(len(data["result"])))
  1243.                                 ret_ += "\n\nUntuk mengirim music, silahkan gunakan command {}SearchMusic {}|「number」".format(str(setKey), str(search))
  1244.                                 client.sendMessage(to, str(ret_))
  1245.                             elif len(cond) == 2:
  1246.                                 num = int(cond[1])
  1247.                                 if num <= len(data["result"]):
  1248.                                     music = data["result"][num - 1]
  1249.                                     url = requests.get("http://api.ntcorp.us/joox/song_info?sid={}".format(str(music["sid"])))
  1250.                                     data = url.json()
  1251.                                     ret_ = "╔══[ Music ]"
  1252.                                     ret_ += "\n╠ Title : {}".format(str(data["result"]["song"]))
  1253.                                     ret_ += "\n╠ Album : {}".format(str(data["result"]["album"]))
  1254.                                     ret_ += "\n╠ Size : {}".format(str(data["result"]["size"]))
  1255.                                     ret_ += "\n╠ Link : {}".format(str(data["result"]["mp3"][0]))
  1256.                                     ret_ += "\n╚══[ Finish ]"
  1257.                                     client.sendImageWithURL(to, str(data["result"]["img"]))
  1258.                                     client.sendMessage(to, str(ret_))
  1259.                                     client.sendAudioWithURL(to, str(data["result"]["mp3"][0]))
  1260.                         elif cmd.startswith("searchlyric "):
  1261.                             sep = text.split(" ")
  1262.                             txt = text.replace(sep[0] + " ","")
  1263.                             cond = txt.split("|")
  1264.                             query = cond[0]
  1265.                             with requests.session() as web:
  1266.                                 web.headers["user-agent"] = "Mozilla/5.0"
  1267.                                 url = web.get("https://www.musixmatch.com/search/{}".format(urllib.parse.quote(query)))
  1268.                                 data = BeautifulSoup(url.content, "html.parser")
  1269.                                 result = []
  1270.                                 for trackList in data.findAll("ul", {"class":"tracks list"}):
  1271.                                     for urlList in trackList.findAll("a"):
  1272.                                         title = urlList.text
  1273.                                         url = urlList["href"]
  1274.                                         result.append({"title": title, "url": url})
  1275.                                 if len(cond) == 1:
  1276.                                     ret_ = "╔══[ Musixmatch Result ]"
  1277.                                     num = 0
  1278.                                     for title in result:
  1279.                                         num += 1
  1280.                                         ret_ += "\n╠ {}. {}".format(str(num), str(title["title"]))
  1281.                                     ret_ += "\n╚══[ Total {} Lyric ]".format(str(len(result)))
  1282.                                     ret_ += "\n\nUntuk melihat lyric, silahkan gunakan command {}SearchLyric {}|「number」".format(str(setKey), str(query))
  1283.                                     client.sendMessage(to, ret_)
  1284.                                 elif len(cond) == 2:
  1285.                                     num = int(cond[1])
  1286.                                     if num <= len(result):
  1287.                                         data = result[num - 1]
  1288.                                         with requests.session() as web:
  1289.                                             web.headers["user-agent"] = "Mozilla/5.0"
  1290.                                             url = web.get("https://www.musixmatch.com{}".format(urllib.parse.quote(data["url"])))
  1291.                                             data = BeautifulSoup(url.content, "html5lib")
  1292.                                             for lyricContent in data.findAll("p", {"class":"mxm-lyrics__content "}):
  1293.                                                 lyric = lyricContent.text
  1294.                                                 client.sendMessage(to, lyric)
  1295.                         elif cmd.startswith("tr-"):
  1296.                             sep = text.split("-")
  1297.                             sep = sep[1].split(" ")
  1298.                             lang = sep[0]
  1299.                             if settings["setKey"] == False:
  1300.                                 txt = text.lower().replace("tr-" + lang + " ","")
  1301.                             else:
  1302.                                 txt = text.lower().replace(settings["keyCommand"] + "tr-" + lang + " ","")
  1303.                             if lang not in language["googletrans"]:
  1304.                                 return client.sendMessage(to, "Bahasa {} tidak ditemukan".format(lang))
  1305.                             translator = Translator()
  1306.                             result = translator.translate(txt, dest=lang)
  1307.                             client.sendMessage(to, result.text)
  1308.                         if text.lower() == "mykey":
  1309.                             client.sendMessage(to, "Keycommand yang diset saat ini : 「{}」".format(str(settings["keyCommand"])))
  1310.                         elif text.lower() == "setkey on":
  1311.                             if settings["setKey"] == True:
  1312.                                 client.sendMessage(to, "Setkey telah aktif")
  1313.                             else:
  1314.                                 settings["setKey"] = True
  1315.                                 client.sendMessage(to, "Berhasil mengaktifkan setkey")
  1316.                         elif text.lower() == "setkey off":
  1317.                             if settings["setKey"] == False:
  1318.                                 client.sendMessage(to, "Setkey telah nonaktif")
  1319.                             else:
  1320.                                 settings["setKey"] = False
  1321.                                 client.sendMessage(to, "Berhasil menonaktifkan setkey")
  1322.                         if text is None: return
  1323.                         if "/ti/g/" in msg.text.lower():
  1324.                             if settings["autoJoinTicket"] == True:
  1325.                                 link_re = re.compile('(?:line\:\/|line\.me\/R)\/ti\/g\/([a-zA-Z0-9_-]+)?')
  1326.                                 links = link_re.findall(text)
  1327.                                 n_links = []
  1328.                                 for l in links:
  1329.                                     if l not in n_links:
  1330.                                         n_links.append(l)
  1331.                                 for ticket_id in n_links:
  1332.                                     group = client.findGroupByTicket(ticket_id)
  1333.                                     client.acceptGroupInvitationByTicket(group.id,ticket_id)
  1334.                                     client.sendMessage(to, "Berhasil masuk ke group %s" % str(group.name))
  1335.                     elif msg.contentType == 1:
  1336.                         if settings["changePictureProfile"] == True:
  1337.                             path = client.downloadObjectMsg(msg_id, saveAs="LineAPI/tmp/{}-cpp.bin".format(time.time()))
  1338.                             settings["changePictureProfile"] = False
  1339.                             client.updateProfilePicture(path)
  1340.                             client.sendMessage(to, "Berhasil mengubah foto profile")
  1341.                             client.deleteFile(path)
  1342.                         if msg.toType == 2:
  1343.                             if to in settings["changeGroupPicture"]:
  1344.                                 path = client.downloadObjectMsg(msg_id, saveAs="LineAPI/tmp/{}-cgp.bin".format(time.time()))
  1345.                                 settings["changeGroupPicture"].remove(to)
  1346.                                 client.updateGroupPicture(to, path)
  1347.                                 client.sendMessage(to, "Berhasil mengubah foto group")
  1348.                                 client.deleteFile(path)
  1349.                     elif msg.contentType == 7:
  1350.                         if settings["checkSticker"] == True:
  1351.                             stk_id = msg.contentMetadata['STKID']
  1352.                             stk_ver = msg.contentMetadata['STKVER']
  1353.                             pkg_id = msg.contentMetadata['STKPKGID']
  1354.                             ret_ = "╔══[ Sticker Info ]"
  1355.                             ret_ += "\n╠ STICKER ID : {}".format(stk_id)
  1356.                             ret_ += "\n╠ STICKER PACKAGES ID : {}".format(pkg_id)
  1357.                             ret_ += "\n╠ STICKER VERSION : {}".format(stk_ver)
  1358.                             ret_ += "\n╠ STICKER URL : line://shop/detail/{}".format(pkg_id)
  1359.                             ret_ += "\n╚══[ Finish ]"
  1360.                             client.sendMessage(to, str(ret_))
  1361.                     elif msg.contentType == 13:
  1362.                         if settings["checkContact"] == True:
  1363.                             try:
  1364.                                 contact = client.getContact(msg.contentMetadata["mid"])
  1365.                                 cover = client.getProfileCoverURL(msg.contentMetadata["mid"])
  1366.                                 ret_ = "╔══[ Details Contact ]"
  1367.                                 ret_ += "\n╠ Nama : {}".format(str(contact.displayName))
  1368.                                 ret_ += "\n╠ MID : {}".format(str(msg.contentMetadata["mid"]))
  1369.                                 ret_ += "\n╠ Bio : {}".format(str(contact.statusMessage))
  1370.                                 ret_ += "\n╠ Gambar Profile : http://dl.profile.line-cdn.net/{}".format(str(contact.pictureStatus))
  1371.                                 ret_ += "\n╠ Gambar Cover : {}".format(str(cover))
  1372.                                 ret_ += "\n╚══[ Finish ]"
  1373.                                 client.sendImageWithURL(to, "http://dl.profile.line-cdn.net/{}".format(str(contact.pictureStatus)))
  1374.                                 client.sendMessage(to, str(ret_))
  1375.                             except:
  1376.                                 client.sendMessage(to, "Kontak tidak valid")
  1377.                     elif msg.contentType == 16:
  1378.                         if settings["checkPost"] == True:
  1379.                             try:
  1380.                                 ret_ = "╔══[ Details Post ]"
  1381.                                 if msg.contentMetadata["serviceType"] == "GB":
  1382.                                     contact = client.getContact(sender)
  1383.                                     auth = "\n╠ Penulis : {}".format(str(contact.displayName))
  1384.                                 else:
  1385.                                     auth = "\n╠ Penulis : {}".format(str(msg.contentMetadata["serviceName"]))
  1386.                                 purl = "\n╠ URL : {}".format(str(msg.contentMetadata["postEndUrl"]).replace("line://","https://line.me/R/"))
  1387.                                 ret_ += auth
  1388.                                 ret_ += purl
  1389.                                 if "mediaOid" in msg.contentMetadata:
  1390.                                     object_ = msg.contentMetadata["mediaOid"].replace("svc=myhome|sid=h|","")
  1391.                                     if msg.contentMetadata["mediaType"] == "V":
  1392.                                         if msg.contentMetadata["serviceType"] == "GB":
  1393.                                             ourl = "\n╠ Objek URL : https://obs-us.line-apps.com/myhome/h/download.nhn?tid=612w&{}".format(str(msg.contentMetadata["mediaOid"]))
  1394.                                             murl = "\n╠ Media URL : https://obs-us.line-apps.com/myhome/h/download.nhn?{}".format(str(msg.contentMetadata["mediaOid"]))
  1395.                                         else:
  1396.                                             ourl = "\n╠ Objek URL : https://obs-us.line-apps.com/myhome/h/download.nhn?tid=612w&{}".format(str(object_))
  1397.                                             murl = "\n╠ Media URL : https://obs-us.line-apps.com/myhome/h/download.nhn?{}".format(str(object_))
  1398.                                         ret_ += murl
  1399.                                     else:
  1400.                                         if msg.contentMetadata["serviceType"] == "GB":
  1401.                                             ourl = "\n╠ Objek URL : https://obs-us.line-apps.com/myhome/h/download.nhn?tid=612w&{}".format(str(msg.contentMetadata["mediaOid"]))
  1402.                                         else:
  1403.                                             ourl = "\n╠ Objek URL : https://obs-us.line-apps.com/myhome/h/download.nhn?tid=612w&{}".format(str(object_))
  1404.                                     ret_ += ourl
  1405.                                 if "stickerId" in msg.contentMetadata:
  1406.                                     stck = "\n╠ Stiker : https://line.me/R/shop/detail/{}".format(str(msg.contentMetadata["packageId"]))
  1407.                                     ret_ += stck
  1408.                                 if "text" in msg.contentMetadata:
  1409.                                     text = "\n╠ Tulisan : {}".format(str(msg.contentMetadata["text"]))
  1410.                                     ret_ += text
  1411.                                 ret_ += "\n╚══[ Finish ]"
  1412.                                 client.sendMessage(to, str(ret_))
  1413.                             except:
  1414.                                 client.sendMessage(to, "Post tidak valid")
  1415.             except Exception as error:
  1416.                 logError(error)
  1417.  
  1418.  
  1419.         if op.type == 26:
  1420.             try:
  1421.                 print("[ 26 ] RECEIVE MESSAGE")
  1422.                 msg = op.message
  1423.                 text = str(msg.text)
  1424.                 msg_id = msg.id
  1425.                 receiver = msg.to
  1426.                 sender = msg._from
  1427.                 if msg.toType == 0 or msg.toType == 1 or msg.toType == 2:
  1428.                     if msg.toType == 0:
  1429.                         if sender != client.profile.mid:
  1430.                             to = sender
  1431.                         else:
  1432.                             to = receiver
  1433.                     elif msg.toType == 1:
  1434.                         to = receiver
  1435.                     elif msg.toType == 2:
  1436.                         to = receiver
  1437.                     if sender in settings["mimic"]["target"] and settings["mimic"]["status"] == True and settings["mimic"]["target"][sender] == True:
  1438.                         if msg.contentType == 0:
  1439.                             client.sendMessage(to, text)
  1440.                         elif msg.contentType == 1:
  1441.                             path = client.downloadObjectMsg(msg_id, saveAs="LineAPI/tmp/{}-mimic.bin".format(time.time()))
  1442.                             client.sendImage(to, path)
  1443.                             client.deleteFile(path)
  1444.                     if msg.contentType == 0:
  1445.                         if settings["autoRead"] == True:
  1446.                             client.sendChatChecked(to, msg_id)
  1447.                         if sender not in clientMid:
  1448.                             if msg.toType != 0 and msg.toType == 2:
  1449.                                 if 'MENTION' in msg.contentMetadata.keys()!= None:
  1450.                                     names = re.findall(r'@(\w+)', text)
  1451.                                     mention = ast.literal_eval(msg.contentMetadata['MENTION'])
  1452.                                     mentionees = mention['MENTIONEES']
  1453.                                     for mention in mentionees:
  1454.                                         if clientMid in mention["M"]:
  1455.                                             if settings["autoRespon"] == True:
  1456.                                                 client.sendMention(sender, settings["autoResponMessage"], [sender])
  1457.                                             break
  1458.                         if text is None: return
  1459.                         if "/ti/g/" in msg.text.lower():
  1460.                             if settings["autoJoinTicket"] == True:
  1461.                                 link_re = re.compile('(?:line\:\/|line\.me\/R)\/ti\/g\/([a-zA-Z0-9_-]+)?')
  1462.                                 links = link_re.findall(text)
  1463.                                 n_links = []
  1464.                                 for l in links:
  1465.                                     if l not in n_links:
  1466.                                         n_links.append(l)
  1467.                                 for ticket_id in n_links:
  1468.                                     group = client.findGroupByTicket(ticket_id)
  1469.                                     client.acceptGroupInvitationByTicket(group.id,ticket_id)
  1470.                                     client.sendMessage(to, "Berhasil masuk ke group %s" % str(group.name))
  1471.                         if settings["detectUnsend"] == True:
  1472.                             try:
  1473.                                 unsendTime = time.time()
  1474.                                 unsend[msg_id] = {"text": text, "from": sender, "time": unsendTime}
  1475.                             except Exception as error:
  1476.                                 logError(error)
  1477.                     if msg.contentType == 1:
  1478.                         if settings["detectUnsend"] == True:
  1479.                             try:
  1480.                                 unsendTime = time.time()
  1481.                                 image = client.downloadObjectMsg(msg_id, saveAs="LineAPI/tmp/{}-image.bin".format(time.time()))
  1482.                                 unsend[msg_id] = {"from": sender, "image": image, "time": unsendTime}
  1483.                             except Exception as error:
  1484.                                 logError(error)
  1485.             except Exception as error:
  1486.                 logError(error)
  1487.  
  1488.  
  1489.         if op.type == 55:
  1490.             print ("[ 55 ] NOTIFIED READ MESSAGE")
  1491.             if op.param1 in read["readPoint"]:
  1492.                 if op.param2 not in read["readMember"][op.param1]:
  1493.                     read["readMember"][op.param1].append(op.param2)
  1494.  
  1495.  
  1496.         if op.type == 65:
  1497.             try:
  1498.                 if settings["detectUnsend"] == True:
  1499.                     to = op.param1
  1500.                     sender = op.param2
  1501.                     if sender in unsend:
  1502.                         unsendTime = time.time()
  1503.                         contact = client.getContact(unsend[sender]["from"])
  1504.                         if "text" in unsend[sender]:
  1505.                             try:
  1506.                                 sendTime = unsendTime - unsend[sender]["time"]
  1507.                                 sendTime = timeChange(sendTime)
  1508.                                 ret_ = "╔══[ Unsend Message ]"
  1509.                                 ret_ += "\n╠ Sender : @!"
  1510.                                 ret_ += "\n╠ Time : {} yang lalu".format(sendTime)
  1511.                                 ret_ += "\n╠ Type : Text"
  1512.                                 ret_ += "\n╠ Text : {}".format(unsend[sender]["text"])
  1513.                                 ret_ += "\n╚══[ Finish ]"
  1514.                                 client.sendMention(to, ret_, [contact.mid])
  1515.                                 del unsend[sender]
  1516.                             except:
  1517.                                 del unsend[sender]
  1518.                         elif "image" in unsend[sender]:
  1519.                             try:
  1520.                                 sendTime = unsendTime - unsend[sender]["time"]
  1521.                                 sendTime = timeChange(sendTime)
  1522.                                 ret_ = "╔══[ Unsend Message ]"
  1523.                                 ret_ += "\n╠ Sender : @!"
  1524.                                 ret_ += "\n╠ Time : {} yang lalu".format(sendTime)
  1525.                                 ret_ += "\n╠ Type : Image"
  1526.                                 ret_ += "\n╠ Text : None"
  1527.                                 ret_ += "\n╚══[ Finish ]"
  1528.                                 client.sendMention(to, ret_, [contact.mid])
  1529.                                 client.sendImage(to, unsend[sender]["image"])
  1530.                                 client.deleteFile(unsend[sender]["image"])
  1531.                                 del unsend[sender]
  1532.                             except:
  1533.                                 client.deleteFile(unsend[sender]["image"])
  1534.                                 del unsend[sender]
  1535.                     else:
  1536.                         client.sendMessage(to, "Data unsend tidak ditemukan")
  1537.             except Exception as error:
  1538.                 logError(error)
  1539.         backupData()
  1540.     except Exception as error:
  1541.         logError(error)
  1542.  
  1543. def run():
  1544.     while True:
  1545.         ops = clientPoll.singleTrace(count=50)
  1546.         if ops != None:
  1547.             for op in ops:
  1548.                 try:
  1549.                     clientBot(op)
  1550.                 except Exception as error:
  1551.                     logError(error)
  1552.                 clientPoll.setRevision(op.revision)
  1553.  
  1554. if __name__ == "__main__":
  1555.     run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement