Advertisement
Faerlynn

Miku v0.21.3 (26.1.2019)

Jan 25th, 2019
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 57.99 KB | None | 0 0
  1. import discord
  2. import random
  3. import time
  4. import os
  5. import timeit
  6. import sys
  7. import asyncio
  8. from youtube_dl import YoutubeDL
  9. from apiclient.discovery import build
  10. import datetime
  11. import ctypes
  12.  
  13. client = discord.Client()
  14.  
  15. def log(msg, message_channel, message_author, cmd_type):
  16.     if cmd_type == '':
  17.         cmd_type = 'unknown'
  18.     print('Command \'{0}\' used in {1} by {2}!'.format(cmd_type, str(message_channel), str(message_author)))
  19.  
  20. def reload_files():
  21.     global cuddle_message, hug_message, kiss_message, about, patchnotes, pat_message, version, slap_message, s_id, success
  22.     global miku_message, dev_key, youtube, help_message, shy_message
  23.     #Opens file for 'cuddle'
  24.     success = False
  25.     try:
  26.         file = open("bot_save_files\cuddle_messages.txt",'r')
  27.         line = file.readline()
  28.         cuddle_message = []
  29.         while line:
  30.             cuddle_message.append(line)
  31.             line = file.readline()
  32.         file.close()
  33.     except:
  34.         print("File 'cuddle_messages.txt' couldn't be opened!")
  35.         success = True
  36.  
  37.     #Opens file for 'hug'
  38.     try:
  39.         file = open("bot_save_files\hug_messages.txt",'r')
  40.         line = file.readline()
  41.         hug_message = []
  42.         while line:
  43.             hug_message.append(line)
  44.             line = file.readline()
  45.         file.close()
  46.     except:
  47.         print("File 'hug_messages.txt' couldn't be opened!")
  48.         success = True
  49.  
  50.     #Opens file for 'pat'
  51.     try:
  52.         file = open("bot_save_files\pat_messages.txt",'r')
  53.         line = file.readline()
  54.         pat_message = []
  55.         while line:
  56.             pat_message.append(line)
  57.             line = file.readline()
  58.         file.close()
  59.     except:
  60.         print("File 'pat_messages.txt' couldn't be opened!")
  61.         success = True
  62.        
  63.     #Opens file for 'kiss'
  64.     try:
  65.         file = open("bot_save_files\kiss_messages.txt",'r')
  66.         line = file.readline()
  67.         kiss_message = []
  68.         while line:
  69.             kiss_message.append(line)
  70.             line = file.readline()
  71.         file.close()
  72.     except:
  73.         print("File 'kiss_messages.txt' couldn't be opened!")
  74.         success = True
  75.        
  76.     #Opens file for 'about'
  77.     try:
  78.         about = ''
  79.         file = open("bot_save_files\\about.txt",'r')
  80.         about = file.read()
  81.         file.close()
  82.     except:
  83.         print("File 'about.txt' couldn't be opened!")
  84.         success = True
  85.  
  86.     #Opens file for 'about'
  87.     try:
  88.         version = ''
  89.         file = open("bot_save_files\\patch.txt",'r')
  90.         version = file.read()
  91.         file.close()
  92.     except:
  93.         print("File 'patch.txt' couldn't be opened!")
  94.         success = True
  95.  
  96.     #Opens file for 'patchnotes'
  97.     try:
  98.         patchnotes = ''
  99.         file = open("bot_save_files\\patch_notes.txt",'r')
  100.         patchnotes = file.read()
  101.         file.close()
  102.     except:
  103.         print("File 'patch_notes.txt' couldn't be opened!")
  104.         success = True
  105.  
  106.     #Opens file for 'slap'
  107.     try:
  108.         file = open("bot_save_files\slap_messages.txt",'r')
  109.         line = file.readline()
  110.         slap_message = []
  111.         while line:
  112.             slap_message.append(line)
  113.             line = file.readline()
  114.         file.close()
  115.     except:
  116.         print("File 'slap_messages.txt' couldn't be opened!")
  117.         success = True
  118.  
  119.     #Opens file for 'shy'
  120.     try:
  121.         file = open("bot_save_files\shy_messages.txt",'r')
  122.         line = file.readline()
  123.         shy_message = []
  124.         while line:
  125.             shy_message.append(line)
  126.             line = file.readline()
  127.         file.close()
  128.     except:
  129.         print("File 'shy_messages.txt' couldn't be opened!")
  130.         success = True
  131.  
  132.     #Opens fire for s_id
  133.     s_id = {}
  134.     try:
  135.         file = open("bot_save_files\server_id.txt",'r')
  136.         line = file.readline()
  137.         while line:
  138.             key, value = line.split(':')
  139.             s_id[key] = value[:1]
  140.             line = file.readline()
  141.         file.close()
  142.     except:
  143.         print("File 'server_id.txt' couldn't be opened!")
  144.         success = True
  145.  
  146.     #Opens file for 'miku reaction'
  147.     try:
  148.         file = open("bot_save_files\miku_reaction_msg.txt",'r')
  149.         line = file.readline()
  150.         miku_message = []
  151.         while line:
  152.             miku_message.append(line)
  153.             line = file.readline()
  154.         file.close()
  155.     except:
  156.         print("File 'miku_reaction_msg.txt' couldn't be opened!")
  157.         success = True
  158.  
  159.     #Opens file for 'help command'
  160.     try:
  161.         file = open("bot_save_files\help_list.txt", 'r')
  162.         help_message = file.read()
  163.         file.close()
  164.     except Exception as e:
  165.         print(e)
  166.     #Loads dev_key
  167.     file = open('bot_save_files\dev_key.txt', 'r')
  168.     dev_key = file.readline()
  169.     file.close()
  170.     youtube = build('youtube', 'v3', developerKey=dev_key)
  171.     return success
  172.        
  173.    
  174.  
  175. def save():
  176.     global s_id
  177.     key, value = '', ''
  178.     s_id_file = ''
  179.     for key, value in s_id.items():
  180.         s_id_file = s_id_file + "{0}:{1}\n".format(key, value)
  181.     os.remove("bot_save_files\server_id.txt")
  182.     file = open("bot_save_files\server_id.txt",'w')
  183.     file.write(str(s_id_file))
  184.     file.close()
  185.  
  186.  
  187. #startup variables
  188. ydl_opts = {
  189.     'format': 'bestaudio/best',
  190.     'outtmpl': 'tmp/%(id)s.%(ext)s',
  191.     'noplaylist': True,
  192.     'quiet': True,
  193.     'prefer_ffmpeg': True,
  194.     'audioformat': 'wav',
  195.     'forceduration':True
  196. }
  197.  
  198. game_number = 274**21
  199. game_active = False
  200. attempts = 0
  201. round_active = False
  202. error = ''
  203. player = ''
  204. author = ''
  205. msg = ''
  206. gmn_cp = {}
  207. gmn_number = {}
  208. gmn_a = {}
  209. edits = ['*', '__', '~~', '**', '***']
  210. players = {}
  211. playlist = {}
  212. cp = {}
  213. loop = {}
  214. lp = {}
  215. ytdl = YoutubeDL()
  216. urls = {}
  217. cpsong = {}
  218. miku_names = ['miku', 'Miku', 'M I K U', 'MIKU', 'm i k u', 'mIku', 'miKu', 'mikU', 'MIku', 'MiKu',
  219.               'MikU', 'mIKu', 'mIkU', 'mIKU', 'MiKU', 'MIkU', 'MIKu', 'miKU']
  220. play_list = {}
  221. info = {}
  222. dev_key = ''
  223. cpsong_two = {}
  224. voice_list = {}
  225. ts = None
  226. chat_log = ''
  227. log_enable = False
  228.  
  229.  
  230. #@client.event
  231. async def message_in(message, c):
  232.     global game_number, game_active, error, round_active, attempts, about, player, author, msg, version, s_id, gmn_cp, success
  233.     global miku_message, edits, statuses, players, vc, playlist, cp, loop, lp, miku_names, cpsong
  234.     global play_list, ytdl, dev_key, youtube, client, help_message, cpsong_two, shy_message, voice_list
  235.     global ts, chat_log
  236.    
  237.     now = datetime.datetime.now()
  238.     current_time = now.strftime("%Y-%m-%d %H:%M:%S")
  239.                                
  240.     chat_log += '[{0}][{1}][{2}] {3}:{4}\n'.format(current_time, message.server, message.channel, message.author, message.content)
  241.    
  242.     client = c
  243.     if message.author == client.user:
  244.         return
  245.     sid = message.server.id
  246.  
  247.     if not message.server.id in s_id:
  248.         s_id[message.server.id] = '$'
  249.         print('Creating a backup...')
  250.         msg = 'Creating a first settings for your server!'
  251.         await client.send_message(message.channel, msg)
  252.         save()
  253.         reload_files()
  254.         return
  255.    
  256.     #done       HELLO
  257.     if message.content.startswith('{0}hello'.format(s_id[sid])):
  258.         cmd = 'hello'
  259.         msg = '*Hello {0.author.mention}'.format(message) + '''! My name is MikuBot! If you wanna find more about me and my creator, just type* **`{0}about`** *and read!\nIf you want to know more, just type* **`{0}help`**, *and there you can find all my available commands!*'''.format(s_id[message.server.id])
  260.         log(msg, message.channel, message.author, cmd)
  261.         await client.send_message(message.channel, msg)
  262.  
  263.     #done       LOVE
  264.     if message.content.startswith('{0}love'.format(s_id[sid])):
  265.         cmd = 'love'
  266.         msg = "Hi Lily! This is just a reminder, that I, Ana Alexandra Adria Katalina Aisaka, really love you so so much!!! <3 always <3 *hugs you tightly and strokes your hair, then after moment of huggling she pats your head and giggles*"
  267.         log(msg, message.channel, message.author, cmd)
  268.         await client.send_message(message.channel, msg)
  269.  
  270.     #done       RANDOM NUMBER
  271.     if message.content.startswith('{0}random'.format(s_id[sid])):
  272.         cmd = 'random'
  273.         msg = ('Randomly generated number: '+str(random.randrange(101)))
  274.         log(msg, message.channel, message.author, cmd)
  275.         await client.send_message(message.channel, msg)
  276.  
  277.     #done       POKE
  278.     if message.content.startswith('{0}poke'.format(s_id[sid])):
  279.         cmd = "poke"
  280.         msg = str(message.content)[6:]
  281.         msg_list = msg.split(' ')
  282.         msg_recipient = ''
  283.         msg_author = str(message.author)[:-5]
  284.         msg_content_test = False
  285.         for i in range(len(msg_list)):
  286.             msg_check = msg_list[i]
  287.             if (('<@!' and '>') in msg_check) == True:
  288.                 msg_recipient = msg_check
  289.                 msg_content_test = True
  290.         if not '@' in msg_recipient:
  291.             msg_recipient = 'fridge'
  292.         if msg_content_test == False:
  293.             msg = '*' + msg_author + " tries to poke an empty air, and there should be nothing there.. But suddenly a white cloud appears before them, forming into a big ghost with a single long arm, and only three fingers. " + msg_author + " can't move any limbs, and as ghost's finger comes closer, they close their eyes, only to feel a small poke on their nose. When " + msg_author + " finally opens eyes, there is no more ghost to be seen.*"
  294.         else:
  295.             msg = '*' + msg_author + " pokes " + msg_recipient + "'s shoulder gently and then just waits for their response patiently.*"
  296.  
  297.         log(msg, message.channel, message.author, cmd)
  298.         await client.send_message(message.channel, msg)
  299.         if msg_recipient == '<@!492432534181773313>':
  300.             time.sleep(1)
  301.             msg = "*She looks at {0.author.mention} curiously, and after moment she pokes {0.author.mention}'s nose back.*".format(message)
  302.             await client.send_message(message.channel, msg)
  303.  
  304.     #done       CUDDLE
  305.     if message.content.startswith('{0}cuddle'.format(s_id[sid])):
  306.         cmd = 'cuddle'
  307.         try:
  308.             msg = str(message.content)[8:]
  309.             msg_list = msg.split(' ')
  310.             msg_recipient = ''
  311.             msg_author = str(message.author)[:-5]
  312.             msg_content_test = False
  313.            
  314.             for i in range(len(msg_list)):
  315.                 msg_check = msg_list[i]
  316.                 if (('<@!' and '>') in msg_check) == True:
  317.                     msg_recipient = msg_check
  318.                     msg_content_test = True
  319.             if not '!' in msg_recipient:
  320.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  321.             if not '@' in msg_recipient:
  322.                 msg_recipient = 'themselve'
  323.  
  324.             if msg_recipient == str(message.author.mention):
  325.                 msg = random.choice(cuddle_message).format('Miku', msg_recipient)
  326.             else:
  327.            
  328.                 if not msg_content_test:
  329.                     msg = '*' + msg_author + " cuddles their pillow, smiling but alone.*"
  330.                 else:
  331.                     msg = random.choice(cuddle_message).format(msg_author, msg_recipient)
  332.             log(msg, message.channel, message.author, cmd)
  333.        
  334.             await client.send_message(message.channel, msg)
  335.         except ValueError in error:
  336.             print(error)
  337.             await client.send_message(message.channel, 'Something went wrong.... :sob:\n'.format(error))
  338.        
  339.  
  340.     #done       HUG
  341.     if message.content.startswith('{0}hug'.format(s_id[sid])):
  342.         cmd = 'hug'
  343.         msg = str(message.content)[5:]
  344.         msg_list = msg.split(' ')
  345.         msg_recipient = ''
  346.         msg_author = str(message.author)[:-5]
  347.         msg_content_test = False
  348.         for i in range(len(msg_list)):
  349.             msg_check = msg_list[i]
  350.             if (('<@!' and '>') in msg_check) == True:
  351.                 msg_recipient = msg_check
  352.                 msg_content_test = True
  353.         if not '!' in msg_recipient:
  354.             msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  355.         if not '@' in msg_recipient:
  356.             msg_recipient = 'someone adorable'
  357.         if not msg_content_test:
  358.             msg_recipient = 'bottle of expensive red wine'
  359.         if msg_recipient == str(message.author.mention):
  360.             msg = random.choice(hug_message).format('Miku', msg_recipient)
  361.         else:
  362.             msg = random.choice(hug_message).format(msg_author, msg_recipient)
  363.         log(msg, message.channel, message.author, cmd)
  364.         try:
  365.             await client.send_message(message.channel, msg)
  366.         except Exception in error:
  367.             print(error)
  368.             await client.send_message(message.channel, 'Something went wrong.... :sob:')
  369.  
  370.     #done       KISS
  371.     if message.content.startswith('{0}kiss'.format(s_id[sid])):
  372.         cmd = 'kiss'
  373.         msg = str(message.content)[5:]
  374.         msg_list = msg.split(' ')
  375.         msg_recipient = ''
  376.         msg_author = str(message.author)[:-5]
  377.         msg_content_test = False
  378.         for i in range(len(msg_list)):
  379.             msg_check = msg_list[i]
  380.             if (('<@!' and '>') in msg_check) == True:
  381.                 msg_recipient = msg_check
  382.                 msg_content_test = True
  383.         if not '!' in msg_recipient:
  384.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  385.         if not '@' in msg_recipient:
  386.             msg_recipient = 'someone cute'
  387.         if msg_content_test == False:
  388.             msg_recipient = 'bottle of cheap red wine'
  389.         if msg_recipient == str(message.author.mention):
  390.             msg = random.choice(kiss_message).format('Miku', msg_recipient)
  391.         else:
  392.             msg = random.choice(kiss_message).format(msg_author, msg_recipient)
  393.         log(msg, message.channel, message.author, cmd)
  394.         try:
  395.             await client.send_message(message.channel, msg)
  396.         except ValueError in error:
  397.             print(error)
  398.             await client.send_message(message.channel, 'Something went wrong.... :sob:')
  399.  
  400.     #done       PAT
  401.     if message.content.startswith('{0}pat'.format(s_id[sid])):
  402.         cmd = 'pat'
  403.         if '{0}pat '.format(s_id[sid]) in message.content:
  404.             msg = str(message.content)[4:]
  405.             msg_list = msg.split(' ')
  406.             msg_recipient = ''
  407.             msg_author = str(message.author)[:-5]
  408.             msg_content_test = False
  409.             for i in range(len(msg_list)):
  410.                 msg_check = msg_list[i]
  411.                 if (('<@!' and '>') in msg_check) == True:
  412.                     msg_recipient = msg_check
  413.                     msg_content_test = True
  414.             if not '!' in msg_recipient:
  415.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  416.             if not '@' in msg_recipient:
  417.                 msg_recipient = 'Pa Butt'
  418.             if msg_content_test == False:
  419.                 msg_recipient = 'invisible unicorn'
  420.             if msg_recipient == str(message.author.mention):
  421.                 msg = random.choice(pat_message).format('Miku', msg_recipient)
  422.             else:
  423.                 msg = random.choice(pat_message).format(msg_author, msg_recipient)
  424.             log(msg, message.channel, message.author, cmd)
  425.             try:        
  426.                 await client.send_message(message.channel, msg)
  427.             except ValueError in error:
  428.                 print(error)
  429.                 await client.send_message(message.channel, 'Something went wrong.... :sob:')
  430.  
  431.     #SLAP
  432.     if message.content.startswith('{0}slap'.format(s_id[sid])):
  433.         cmd = 'slap'
  434.         if '{0}slap '.format(s_id[sid]) in message.content:
  435.             msg = str(message.content)[5:]
  436.             msg_list = msg.split(' ')
  437.             msg_recipient = ''
  438.             msg_author = str(message.author)[:-5]
  439.             msg_content_test = False
  440.             for i in range(len(msg_list)):
  441.                 msg_check = msg_list[i]
  442.                 if (('<@!' and '>') in msg_check) == True:
  443.                     msg_recipient = msg_check
  444.                     msg_content_test = True
  445.             if not '!' in msg_recipient:
  446.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  447.             if not '@' in msg_recipient:
  448.                 msg_recipient = 'random emoji'
  449.             if msg_content_test == False:
  450.                 msg_recipient = 'air'
  451.             if msg_recipient == str(message.author.mention):
  452.                 msg = random.choice(pat_message).format('Miku', msg_recipient)
  453.             else:
  454.                 msg = random.choice(slap_message).format(msg_author, msg_recipient)
  455.             log(msg, message.channel, message.author, cmd)
  456.             try:
  457.                 abc = str(message.author.mention).strip('<')
  458.                 await client.send_message(message.channel, msg)
  459.                
  460.             except ValueError in error:
  461.                 print(error)
  462.                 await client.send_message(message.channel, 'Something went wrong.... :sob:')
  463.  
  464.                
  465.     #done       ZHY
  466.     if message.content.startswith('{0}shy'.format(s_id[sid])):
  467.         cmd = 'shy'
  468.         if '{0}shy '.format(s_id[sid]) in message.content:
  469.             msg = str(message.content)[4:]
  470.             msg_list = msg.split(' ')
  471.             msg_recipient = ''
  472.             msg_author = str(message.author)[:-5]
  473.             msg_content_test = False
  474.             for i in range(len(msg_list)):
  475.                 msg_check = msg_list[i]
  476.                 if (('<@!' and '>') in msg_check) == True:
  477.                     msg_recipient = msg_check
  478.                     msg_content_test = True
  479.             if not '!' in msg_recipient:
  480.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  481.             if not '@' in msg_recipient:
  482.                 msg_recipient = 'fridge'
  483.             if msg_content_test == False:
  484.                 msg_recipient = 'noone'
  485.             if msg_recipient == str(message.author.mention):
  486.                 msg = random.choice(shy_message).format('Miku', msg_recipient)
  487.             else:
  488.                 msg = random.choice(shy_message).format(msg_author, msg_recipient)
  489.             log(msg, message.channel, message.author, cmd)
  490.             try:        
  491.                 await client.send_message(message.channel, msg)
  492.             except Exception in error:
  493.                 print(error)
  494.                 await client.send_message(message.channel, 'Something went wrong.... :sob:')
  495.    
  496.     #done       HELP
  497.     if message.content.startswith('{0}help'.format(s_id[sid])):
  498.         msg = help_message.format(s_id[sid])
  499.         color = 4122822
  500.         embed = discord.Embed(title = 'List of my commands:', description = msg, color = color)
  501.         await client.send_message(message.author, embed = embed)
  502.         await client.add_reaction(message, '\U00002705')
  503.  
  504.     #done       ABOUT
  505.     if message.content.startswith('{0}about'.format(s_id[sid])):
  506.         cmd = 'about'
  507.         log(msg, message.channel, message.author, cmd)
  508.         await client.send_message(message.channel, about)
  509.  
  510.     #done       CHART
  511.     if message.content.startswith('{0}chart'.format(s_id[sid])):
  512.         cmd = 'chart'
  513.         msg = '''**日 a i u e o a i u e o 本
  514.        ー ア イ ウ エ オ あ い う え お
  515.        k カ キ ク ケ コ か き く け こ
  516.        s サ シ ス デ ソ さ し す せ そ
  517.        t タ チ ツ テ ト た ち つ て と
  518.        n ナ ニ ヌ ネ ノ な に ぬ ね の
  519.        m マ ミ ム メ モ ま み む め も
  520.        r ラ リ ル レ ロ ら り る れ ろ
  521.        h ハ ヒ フ ヘ ホ は ひ ふ へ ほ
  522.        w ワ       ヲ わ       を
  523.        y ヤ   ユ   ヨ や   ゆ   よ
  524.        n ン         ん**'''
  525.         color = 4122822
  526.         embed = discord.Embed(title = 'Katakana and hiragana chart:', description = msg, color = color)
  527.         log(msg, message.channel, message.author, cmd)
  528.         await client.send_message(message.channel, embed = embed)
  529.  
  530.     if message.content.startswith('{0}days'.format(s_id[sid])):
  531.         cmd = 'days'
  532.         msg = '''**日曜日** *Nichiyoubi* - Sun day - Sunday
  533. **月曜日** *Gatsuyoubi* - Moon day - Monday
  534. **火曜日** *Kayoubi* - Fire day - Tuesday
  535. **水曜日** *Suiyoubi* - Water day - Wednesday
  536. **木曜日** *Mokuyoubi* - Tree day - Thursday
  537. **金曜日** *Kinyoubi* - Gold day - Friday
  538. **土曜日** *Doyoubi* - Earth day - Saturday'''
  539.         log(msg, message.channel, message.author, cmd)
  540.         await client.send_message(message.channel, msg)
  541.        
  542.     #done       AYAYA AYAYAAAAAA
  543.     if (message.content.startswith('ayaya')) or (message.content.startswith('AYAYA')):
  544.         cmd = 'ayaya'
  545.         msg = '''**⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣬⡛⣿⣿⣿⣯⢻
  546. ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⢻⣿⣿⢟⣻⣿⣿⣿⣿⣿⣿⣮⡻⣿⣿⣧
  547. ⣿⣿⣿⣿⣿⢻⣿⣿⣿⣿⣿⣿⣆⠻⡫⣢⠿⣿⣿⣿⣿⣿⣿⣿⣷⣜⢻⣿
  548. ⣿⣿⡏⣿⣿⣨⣝⠿⣿⣿⣿⣿⣿⢕⠸⣛⣩⣥⣄⣩⢝⣛⡿⠿⣿⣿⣆⢝
  549. ⣿⣿⢡⣸⣿⣏⣿⣿⣶⣯⣙⠫⢺⣿⣷⡈⣿⣿⣿⣿⡿⠿⢿⣟⣒⣋⣙⠊
  550. ⣿⡏⡿⣛⣍⢿⣮⣿⣿⣿⣿⣿⣿⣿⣶⣶⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿
  551. ⣿⢱⣾⣿⣿⣿⣝⡮⡻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠛⣋⣻⣿⣿⣿⣿
  552. ⢿⢸⣿⣿⣿⣿⣿⣿⣷⣽⣿⣿⣿⣿⣿⣿⣿⡕⣡⣴⣶⣿⣿⣿⡟⣿⣿⣿
  553. ⣦⡸⣿⣿⣿⣿⣿⣿⡛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⣿⣿⣿
  554. ⢛⠷⡹⣿⠋⣉⣠⣤⣶⣶⣿⣿⣿⣿⣿⣿⡿⠿⢿⣿⣿⣿⣿⣿⣷⢹⣿⣿
  555. ⣷⡝⣿⡞⣿⣿⣿⣿⣿⣿⣿⣿⡟⠋⠁⣠⣤⣤⣦⣽⣿⣿⣿⡿⠋⠘⣿⣿
  556. ⣿⣿⡹⣿⡼⣿⣿⣿⣿⣿⣿⣿⣧⡰⣿⣿⣿⣿⣿⣹⡿⠟⠉⡀⠄⠄⢿⣿
  557. ⣿⣿⣿⣽⣿⣼⣛⠿⠿⣿⣿⣿⣿⣿⣯⣿⠿⢟⣻⡽⢚⣤⡞⠄⠄⠄⢸⣿**'''
  558.         log(msg, message.channel, message.author, cmd)
  559.         await client.send_message(message.channel, msg)
  560.  
  561.     #done       INVITE
  562.     if message.content.startswith('{0}invite'.format(s_id[sid])):
  563.         msg = "*You can invite me to your server using this link:*\nhttps://discordapp.com/oauth2/authorize?client_id=492432534181773313&scope=bot"
  564.         await client.send_message(message.author, msg)
  565.  
  566.     #done       TERRARIA
  567.     if message.content.startswith('{0}terraria'.format(s_id[sid])):
  568.         cmd = 'terraria'
  569.         msg = '''
  570.        **IP:** 95.105.211.38
  571.        **Port:** 6666
  572.        **Password:** *Ask Ana#3140*
  573.        *Server is hosted same way as I am.. That means it runs whenever I am online!!
  574.        Connecting to the server requires* **TModLoader**. *Our mods will get downloaded automatically when connecting!*
  575.        **List of mods:** *RecipeBrowser, WhereIsMyItem, Boss Checklist*
  576.        *You can get TModLoader here: https://tmodloader.net/*
  577.        '''
  578.         color = 4122822
  579.         embed = discord.Embed(title = 'Our Terraria server: ', description = msg, color = color)
  580.         log(msg, message.channel, message.author, cmd)
  581.         await client.send_message(message.channel, embed = embed)
  582.  
  583.     #done       CHOICE
  584.     if message.content.startswith('{0}choice'.format(s_id[sid])):
  585.         cmd = 'choice'
  586.         msg = message.content[8:]
  587.         choice_list = []
  588.         choice_list = msg.split(',')
  589.         msg = "I've randomly chosen this for you: " + str(random.choice(choice_list))
  590.         log(msg, message.channel, message.author, cmd)
  591.         await client.send_message(message.channel, msg)
  592.  
  593.     #done       PATCHNOTES
  594.     if message.content.startswith('{0}patchnotes'.format(s_id[sid])):
  595.         cmd = 'patchnotes'
  596.         p_notes_split = patchnotes.split('<$>')
  597.         #print(p_notes_split)
  598.         log(msg, message.channel, message.author, cmd)
  599.         for i in p_notes_split:
  600.             msg = '```{0}```'.format(i)
  601.             await client.send_message(message.author, msg)
  602.  
  603.     #done       VERSION
  604.     if message.content.startswith('{0}version'.format(s_id[sid])):
  605.         cmd = 'version'
  606.         msg = '`Current version of this bot is: {0}`'.format(version)
  607.         log(msg, message.channel, message.author, cmd)
  608.         await client.send_message(message.channel, msg)
  609.  
  610.     #done       RANDOM NUMBER X Z
  611.     if message.content.startswith('{0}rnf'.format(s_id[sid])):
  612.         cmd = 'random number from <x, z>'
  613.         msg = message.content[5:]
  614.         numbers = []
  615.         numbers = msg.split(' ')
  616.         log(msg, message.channel, message.author, cmd)
  617.         error = ''
  618.         if len(numbers) == (1 or 0):
  619.             msg = 'You need two numbers!'
  620.             await client.send_message(message.channel, msg)
  621.         else:
  622.             try:
  623.                 print(numbers[0], numbers[1])
  624.                 a = int(round(float(numbers[0])))
  625.                 b = int(round(float(numbers[1])))
  626.                 print(a, b)
  627.                
  628.                 if a >= b:
  629.                     c = a
  630.                     a = b
  631.                     b = c
  632.                    
  633.                 if a == b:
  634.                     msg = "Your random number is not really random, but here you go: {0}".format(a)
  635.                 else:
  636.                     num = random.randrange(a, b+1)
  637.                     msg = "Your random number is: " + str(num)
  638.                 await client.send_message(message.channel, msg)
  639.                
  640.             except ValueError as error:
  641.                 print(error)
  642.                 msg = 'Something went wrong!'
  643.                 await client.send_message(message.channel, msg)
  644.  
  645.     #done       INCH to CM
  646.     if message.content.startswith('{0}cm'.format(s_id[sid])):
  647.         mes = str(message.content)[4:]
  648.         thingy = str(mes).split("'")
  649.         a, b = thingy[0], thingy[1]
  650.         try:
  651.             a, b = int(a), float(b)
  652.             msg =  str(round(a * 12 * 2.54 + b * 2.54, 2)) + 'cm'
  653.         except Exception as e:
  654.             msg = 'Error!\n{0}'.format(e)
  655.         await client.send_message(message.channel, msg)
  656.  
  657.     #done       CM TO INCH
  658.     if message.content.startswith('{0}inch'.format(s_id[sid])):
  659.         mes = float(str(message.content)[6:])
  660.         mes = int(round(mes))
  661.         try:
  662.             msg = str(int(mes // (30.48)))
  663.             mes = (mes % 30.48)*100000
  664.             zv = int(round(mes // 2.54))
  665.             zv = round(zv/100000)
  666.             msg += "'{0}".format(zv)
  667.         except Exception as e:
  668.             msg = 'Error!\n{0}'.format(e)
  669.         await client.send_message(message.channel, msg)
  670.            
  671.  
  672.     #done       COINFLIP
  673.     if message.content.startswith('{0}coinflip'.format(s_id[sid])):
  674.         cmd = 'coinflip'
  675.         num = random.randrange(1000)+1
  676.         if num == 741:
  677.             msg = "***It landed on it's side! How lucky!!!***"
  678.         else:
  679.             if num == 274:
  680.                 msg = "As coin spins in the air, you notice it doesn't stop spinning. After few seconds of spinning in the place, everything goes black, and from a dark purple portal long tentacle appears and takes your coin... You will need a new one, I guess..."
  681.             else:
  682.                 if num > 500:
  683.                     msg = 'Heads!' + '!'*random.randrange(4)
  684.                 else:
  685.                     msg = 'Tails!' + '!'*random.randrange(4)
  686.         #log(msg, message.channel, message.author, cmd)
  687.         print("Command '$" + cmd + "' used in " + str(message.channel) + ' by ' + str(message.author) +'! Rolled: ' + str(num))
  688.         await client.send_message(message.channel, msg)
  689.  
  690.     #done       RANDOM COLOUR
  691.     if message.content.startswith('{0}rc'.format(s_id[sid])):
  692.         cmd = 'random colour'
  693.         color = random.randrange(256**3)
  694.         print(color)
  695.         msg = str(f'#{color:06x}')
  696.         embed = discord.Embed(title = 'Your random colour: ', description = msg, color = color)
  697.         log(str(msg), message.channel, message.author, cmd)
  698.         await client.send_message(message.channel, embed = embed)
  699.  
  700.     #done       GUESS MY NUMBER
  701.     if message.content.startswith('{0}gmn'.format(s_id[sid])):
  702.        
  703.         if not str(message.author) in gmn_cp:
  704.             gmn_cp[str(message.author)] = False
  705.             gmn_a[str(message.author)] = 0
  706.             gmn_number[str(message.author)] = 0
  707.            
  708.         if gmn_cp[str(message.author)] == False:
  709.             await client.send_message(message.channel, "Oh.. S-senpai..! L-let's play a g-game..! I.. I will think of a number b-between 1 and 100, a-and you will have to g-guess it..!!")
  710.             time.sleep(0.25)
  711.             await client.send_message(message.channel, "I..I am w-waiting for y-your guess, s-senpai..! J-just type **`{0}gmn your_number`**...! G-good luck! *blushes*".format(s_id[message.server.id]))
  712.             game_number = random.randrange(100)+1
  713.             gmn_number[str(message.author)] = game_number
  714.             gmn_a[str(message.author)] = 0
  715.             player = str(message.author)
  716.             gmn_cp[str(message.author)] = True
  717.            
  718.         elif gmn_cp[str(message.author)] == True:
  719.             number = message.content[4:]
  720.             try:
  721.                 number = int(number)
  722.                 gmn_cp[str(message.author)] = True
  723.                
  724.                 if gmn_number[str(message.author)] == number:
  725.                     msg = "Y-yes..! That's the number I.. I've been thinking of! Y-you are so good s-senpai! :heart_eyes:"
  726.                     gmn_a[str(message.author)] = 0
  727.                     await client.send_message(message.channel, msg)
  728.                     gmn_a[str(message.author)] = 0
  729.                     gmn_cp[str(message.author)] = False
  730.  
  731.                    
  732.                 elif (gmn_a[str(message.author)] == 0) and (gmn_cp[str(message.author)] == True):
  733.  
  734.                     if gmn_number[str(message.author)] < number:
  735.                         msg = "T-that's not it, s-senpai..! :flushed: Your n-number is too b-big.. T-try again..! *blushes*"
  736.                         await client.send_message(message.channel, msg)
  737.                     else:
  738.                         msg = "T-that's not it, s-senpai..! :flushed: Your n-number is not b-big enough.. T-try again..! *blushes*"
  739.                         await client.send_message(message.channel, msg)
  740.  
  741.                     gmn_a[str(message.author)] = 1
  742.                     print('New game! Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  743.                    
  744.                 elif (gmn_a[str(message.author)] == 1) and (gmn_cp[str(message.author)] == True):
  745.  
  746.                    
  747.                     if gmn_number[str(message.author)] < number:
  748.                         msg = "N-no senpai... S-still not my number.. It's n-not that big..."
  749.                         await client.send_message(message.channel, msg)
  750.                     else:
  751.                         msg = "N s-senpai... S-still not my special number.. It's even higher..."
  752.                         await client.send_message(message.channel, msg)
  753.                        
  754.                     gmn_a[str(message.author)] = 2
  755.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  756.  
  757.                    
  758.                 elif (gmn_a[str(message.author)] == 2) and (gmn_cp[str(message.author)] == True):
  759.                    
  760.                     if gmn_number[str(message.author)] < number:
  761.                         msg = "That's again n-not my n-number *blushes* T-too big..! Last chance..!"
  762.                         await client.send_message(message.channel, msg)
  763.                     else:
  764.                         msg = "N-not my n-number, senpai..! *blushes* Go h-higher..! L-last attempt..!"
  765.                         await client.send_message(message.channel, msg)
  766.                        
  767.                     gmn_a[str(message.author)] = 3
  768.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  769.                    
  770.                 elif (gmn_a[str(message.author)] == 3) and (gmn_cp[str(message.author)] == True):
  771.                    
  772.                     if gmn_number[str(message.author)] < number:
  773.                         msg = "I.. I am s-sorry, s-senpai..! Your number w-was t-too big..! I was t-thinking of a number " + str(gmn_number[str(message.author)])
  774.                         await client.send_message(message.channel, msg)
  775.                     else:
  776.                         msg = "S-senpai..! T-that's not my number..! I was t-thinking of a number " + str(gmn_number[str(message.author)])
  777.                         await client.send_message(message.channel, msg)
  778.                        
  779.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  780.                     gmn_a[str(message.author)] = 0
  781.                     gmn_cp[str(message.author)] = False
  782.                    
  783.             except:
  784.                 await client.send_message(message.channel, "That's not a number, b-baka s-senpai..!!")
  785.         else:
  786.             await client.send_message(message.channel, "I.. I'm s-sorry senpai, b-but... You h-haven't finished y-your previous g-game yet... :flushed:")
  787.  
  788.  
  789.     #done       LEWD
  790.     if message.content.startswith('{0}lewd'.format(s_id[sid])):
  791.         if str(message.author) == 'Ana#3140':
  792.             msg = 'Y-yes, s-senpai.. I.. I w-will do a-anything y-you want m-me to d-do.. A-anything... I.. I promise..:heart_eyes: I.. I p-promise t-to be a *good g-girl*..! ***__A-anything..!__***'
  793.         else:
  794.             msg = '**Y-YOU ARE SO L-LEWD, SENPAI**' + '!'*int(random.randrange(9)+3)
  795.         await client.send_message(message.channel, msg)
  796.  
  797.     #done       SERVER PREFIX CHANGE
  798.     if message.content.startswith('{0}prefix set'.format(s_id[sid])):
  799.         if message.author == message.server.owner:
  800.             try:
  801.                 prefix = message.content[12:]
  802.                 if len(prefix) > 1:
  803.                     msg = 'Prefix can consist of only one character!'
  804.                 else:
  805.                     s_id[message.server.id] = str(prefix)
  806.                     save()
  807.                     reload_files()
  808.                     msg = 'Prefix of this server has been changed to {0}'.format(prefix)
  809.             except:
  810.                 msg = 'Something went wrong!'
  811.         else:
  812.             msg = "I'm sorry s-senpai, b-but you are n-not owner of t-this server!"
  813.         await client.send_message(message.channel, msg)
  814.                
  815.  
  816.     #bet reaction
  817.     if (message.content.startswith('bet'))or (message.content.startswith('beet')) or (message.content.startswith('Bet')):
  818.         num = random.randrange(10000)
  819.         if num == 2714:
  820.             msg = 'BEEEEEEEEEEEEEEEEEEEEEEEEEEEET!!!!!'
  821.             await client.send_message(message.channel, msg)
  822.         else:
  823.             if num == 8743:
  824.                 msg = 'No bets allowed to underage trolls (That means you are not allowed to bet if you are not 18+.... B-baka senpai.. >.>)'
  825.                 await client.send_message(message.channel, msg)
  826.             else:
  827.                 msg = "{0}bet{0}".format(edits[random.randrange(5)])
  828.                 await client.send_message(message.channel, msg)
  829.  
  830.     #miku reaction
  831.     await miku_reaction(message)
  832.  
  833.     #Reactions for other bots
  834.     if (message.content.startswith('+pat <@!492432534181773313>')) or (message.content.startswith('{0}pat <@!492432534181773313>'.format(s_id[sid]))) or (message.content.startswith('{0}pat <@492432534181773313>'.format(s_id[sid]))):
  835.         await asyncio.sleep(1)
  836.         msg = 'Awwwwww t-thanks a lot for petting me, {0}! :sparkling_heart: :heart_eyes: ^~^'.format(message.author.mention)
  837.         await client.send_message(message.channel, msg)
  838.  
  839.     if (message.content.startswith('+hug <@!492432534181773313>')) or (message.content.startswith('{0}hug <@!492432534181773313>'.format(s_id[sid]))) or (message.content.startswith('{0}hug <@492432534181773313>'.format(s_id[sid]))):
  840.         await asyncio.sleep(1)
  841.         msg = 'Oh~, thanks s-senpai for hug! *she hugs {0} back tightly, smiling and blushing.*'.format(message.author.mention)
  842.         await client.send_message(message.channel, msg)
  843.  
  844.     if (message.content.startswith('+cuddle <@!492432534181773313>')) or (message.content.startswith('{0}cuddle <@!492432534181773313>'.format(s_id[sid]))) or (message.content.startswith('{0}cuddle <@492432534181773313>'.format(s_id[sid]))):
  845.         await asyncio.sleep(1)
  846.         msg = '*She giggles and cuddles {0} back, slightly stroking their back, still giggling.*'.format(message.author.mention)
  847.         await client.send_message(message.channel, msg)
  848.        
  849.     if (message.content.startswith('{0}poke <@!492432534181773313>'.format(s_id[sid]))) or (message.content.startswith('{0}poke <@492432534181773313>'.format(s_id[sid]))):
  850.         await asyncio.sleep(1)
  851.         msg = "*She looks at {0} curiously, and then she pokes {0} back.*".format(message.author.mention)
  852.         await client.send_message(message.channel, msg)
  853.  
  854.     if (message.content.startswith('{0}slap <@!492432534181773313>'.format(s_id[sid]))) or (message.content.startswith('{0}slap <@492432534181773313>'.format(s_id[sid]))):
  855.         await asyncio.sleep(1)
  856.         msg = '*She slaps {0} back, looking angry, annoyed but dissappointed and sad as well...*'.format(message.author.mention)
  857.         await client.send_message(message.channel, msg)
  858.  
  859.  
  860.     #dev only functions
  861.  
  862.     #done       STOP
  863.     if (message.content.startswith('{0}stop'.format(s_id[message.server.id]))) or (message.content.startswith('{0}bye'.format(s_id[message.server.id]))):
  864.         cmd = 'stop'
  865.         msg = ''
  866.         log(msg, message.channel, message.author, cmd)
  867.         if (str(message.author.id) == '207505077013839883') or (str(mesasge.author.id) == '296301865627287553'):
  868.             msg = 'G-good b-bye, s-senpai~ :heart:!'
  869.             await client.send_message(message.channel, msg)
  870.             print('Good b-bye Ana s-senpai~ <3')
  871.             await quick_save()
  872.             client.logout()
  873.             save()
  874.             sys.exit(0)
  875.         else:
  876.             msg = 'Insufficient permissions...'
  877.             await client.send_message(message.channel, msg)
  878.  
  879.     #done       RELOAD FILES
  880.     if message.content.startswith('{0}rf'.format(s_id[message.server.id])):
  881.         cmd = 'reload files'
  882.         log(msg, message.channel, message.author, cmd)
  883.         author = str(message.author)
  884.         if author == 'Ana#3140':
  885.             reload_files()
  886.             if success == False:
  887.                 print('Files reloaded successfully...')
  888.             else:
  889.                 print('Reload unsuccessful...')
  890.         else:
  891.             msg = 'Insufficient permissions...'
  892.             await client.send_message(message.channel, msg)
  893.  
  894.     #done       CHANGE GAME STATUS
  895.     if message.content.startswith('{0}game'.format(s_id[message.server.id])):
  896.         cmd = 'game status'
  897.         if (str(message.author.id) == '207505077013839883') or (str(message.author.id) == '296301865627287553'):
  898.             if len(str(message.content)) >6:
  899.                 g = str(message.content)[6:]
  900.                 print(g, str(message.content))
  901.                 me = discord.utils.find(lambda s: s != None, client.servers).me
  902.                 if not me:
  903.                         return
  904.                 elif not me.game:
  905.                         updated_game = discord.Game(name = str(g))
  906.                 else:
  907.                         updated_game = me.game
  908.                         updated_game.name = str(g)
  909.             else:
  910.                 me = discord.utils.find(lambda s: s != None, client.servers).me
  911.                 if not me:
  912.                         return
  913.                 elif not me.game:
  914.                         updated_game = discord.Game(name = random.choice(statuses))
  915.                 else:
  916.                         updated_game = me.game
  917.                         updated_game.name = random.choice(statuses)
  918.             await client.change_presence(game = updated_game)
  919.             print('Changing game to: {0}'.format(str(updated_game)))
  920.            
  921.  
  922.     #done       PATCH CHANGE
  923.     if message.content.startswith('{0}patch set'.format(s_id[message.server.id])):
  924.         author = str(message.author)
  925.         author2 = message.author.id
  926.         cmd = 'patch'
  927.         msg = ''
  928.         patch = ''
  929.         log(msg, message.channel, message.author, cmd)
  930.         if author2 == '207505077013839883':
  931.             try:
  932.                 msg = 'Done!'
  933.                 patch = message.content
  934.                 patch = patch[11:]
  935.                 os.remove('bot_save_files\patch.txt')
  936.                 file = open('bot_save_files\patch.txt', 'w')
  937.                 file.write(str(patch))
  938.                 file.close()
  939.                 version = patch
  940.                 print('Current patch changed to {0}'.format(patch))
  941.                 ctypes.windll.kernel32.SetConsoleTitleW(patch)
  942.                 await client.send_message(message.channel, msg)
  943.             except:
  944.                 print('Something went wrong!')
  945.            
  946.     #WIP        TEST COMMAND
  947.     if message.content.startswith('{0}test'.format(s_id[message.server.id])):
  948.         cmd = 'test'
  949.         msg = type(vc)
  950.         await client.send_message(message.channel, msg)
  951.  
  952.     if message.content.startswith('{0}talk'.format(s_id[sid])):
  953.         if (str(message.author.id) == '207505077013839883'):
  954.             ts = True
  955.             await talk(message)
  956.  
  957.     #MUSIC LOOP
  958.     if message.content.startswith('{0}loop'.format(s_id[message.server.id])):
  959.         if not message.server.id in loop:
  960.             loop[message.server.id] = True
  961.             msg = 'Looping current song!'
  962.             await client.send_message(message.channel, msg)
  963.            
  964.         elif loop[message.server.id] == True:
  965.             loop[message.server.id] = False
  966.             msg = 'Loop of the current song disabled!'
  967.             await client.send_message(message.channel, msg)
  968.            
  969.         elif loop[message.server.id] == False:
  970.             loop[message.server.id] = True
  971.             msg = 'Looping current song!'
  972.             await client.send_message(message.channel, msg)
  973.  
  974.  
  975.     #MUSIC LOOP PLAYLIST
  976.     if message.content.startswith('{0}lp'.format(s_id[message.server.id])):
  977.         if not message.server.id in lp:
  978.             lp[message.server.id] = True
  979.             msg = 'Looping current playlist!'
  980.             await client.send_message(message.channel, msg)
  981.            
  982.         elif lp[message.server.id] == True:
  983.             lp[message.server.id] = False
  984.             msg = 'Loop of the current playlist disabled!'
  985.             await client.send_message(message.channel, msg)
  986.            
  987.         elif lp[message.server.id] == False:
  988.             lp[message.server.id] = True
  989.             msg = 'Looping current playlist!'
  990.             await client.send_message(message.channel, msg)
  991.            
  992.     #MUSIC CONNECT
  993.     if message.content.startswith("{0}p ".format(s_id[message.server.id])):
  994.         channel = message.author.voice.voice_channel
  995.        
  996.         if not message.server.id in loop:
  997.             loop[message.server.id] = False
  998.  
  999.         if not message.server.id in lp:
  1000.             lp[message.server.id] = False
  1001.            
  1002.         if not channel == None:
  1003.             ytdl = YoutubeDL()
  1004.             link = ''
  1005.             if not message.server.id in playlist:
  1006.                 playlist[message.server.id] = []
  1007.             if not message.server.id in cp:
  1008.                 cp[message.server.id] = 'False'
  1009.  
  1010.             link = str(message.content)[3:]
  1011.             if 'https://www.youtube.com/playlist?list=' in link:
  1012.                 troll = 'https://www.youtube.com/playlist?list='
  1013.                 link = link[len(troll):]
  1014.                 results = youtube.playlistItems().list(playlistId=link, part='contentDetails', maxResults = 50).execute()
  1015.                 videoIds = [item['contentDetails']['videoId'] for item in results.get('items', [])]
  1016.                 playlist[sid] += videoIds
  1017.                 link = playlist[sid][0]
  1018.             else:
  1019.                 if 'https://youtu.be/' in link:
  1020.                     link = link.strip('https://youtu.be/')
  1021.                 if 'www.youtube.' in link:
  1022.                     link = link[32:]
  1023.                 if len(link) > 11:
  1024.                     link = link[:11]
  1025.                 playlist[message.server.id].append(link)
  1026.             await client.add_reaction(message, '\U00002705')
  1027.             await music_playlist(message)
  1028.         else:
  1029.             msg = "S-senpai..! You're n-not in a-any voice c-channel!"
  1030.             await client.send_message(message.channel, msg)
  1031.  
  1032.     #MUSIC DISCONENCT
  1033.     if message.content.startswith('{0}dc'.format(s_id[message.server.id])):
  1034.         if client.is_voice_connected(message.server):
  1035.             playlist[message.server.id] = []
  1036.             cp[message.server.id] = 'False'
  1037.             players[message.server.id].stop()
  1038.             loop[message.server.id] = False
  1039.             lp[message.server.id] = False
  1040.             cpsong[message.server.id] = ''
  1041.             msg = 'Bai baaaaai~'
  1042.             await client.send_message(message.channel, msg)
  1043.            
  1044.             await voice_list[sid].disconnect()
  1045.            
  1046.         else:
  1047.             msg = "S-senpai..! B-but I.. I'm n-not connected y-yet! :flushed:"
  1048.             await client.send_message(message.channel, msg)
  1049.  
  1050.     #MUSIC PLAYLIST
  1051.     if message.content.startswith('{0}playlist'.format(s_id[message.server.id])):
  1052.         mes = str(message.content).strip('{0}playlist'.format(s_id[message.server.id]))
  1053.         if 'del' in mes:
  1054.             mes = mes.strip(' del ')
  1055.             try:
  1056.                 try:
  1057.                     num = int(mes)
  1058.                 except:
  1059.                     print('Couldn\'t convert mes into num')
  1060.                 if not 0 < num <= len(playlist[sid]):
  1061.                     msg =  'B-but s-senpai!! T-that\'s not a... r-right n-number!!'
  1062.                     await client.send_message(message.channel, msg)
  1063.                 else:
  1064.                     del(playlist[message.server.id][num-1])
  1065.                     msg = 'Done..!'
  1066.                     await client.send_message(message.channel, msg)
  1067.             except:
  1068.                 msg = 'O-oh senpai..! I\'m s-sorry, b-but something went w-wrong!'
  1069.                 await client.send_message(message.channel, msg)
  1070.                
  1071.         elif 'delete' in mes:
  1072.             mes = mes.strip(' delete ')
  1073.             try:
  1074.                 try:
  1075.                     num = int(mes)
  1076.                 except:
  1077.                     print('Couldn\'t convert mes into num')
  1078.                 if not 0 < num <= len(playlist[sid]):
  1079.                     msg =  'S-senpai..!! W-wrong number! :flushed:'
  1080.                     await client.send_message(message.channel, msg)
  1081.                 else:
  1082.                     del(playlist[message.server.id][num-1])
  1083.                     msg = 'Done..!'
  1084.                     await client.send_message(message.channel, msg)
  1085.             except:
  1086.                 msg = 'O-oh senpai..! I\'m s-sorry, b-but something went w-wrong!'
  1087.                 await client.send_message(message.channel, msg)
  1088.         elif 'clear' in mes:
  1089.             try:
  1090.                 playlist[sid] = []
  1091.                 playlist[sid].append(cpsong[sid])
  1092.                 msg = 'Cleared playlist! Current song will keep playing.'
  1093.             except Exception as e:
  1094.                 msg = 'Something went wrong!\n{0}'.format(e)
  1095.             await client.send_message(message.channel, msg)
  1096.         else:
  1097.             await music_playlist_print(message)
  1098.  
  1099.  
  1100.     #MUSIC CURRENTLY PLAYING
  1101.     if message.content.startswith('{0}cp'.format(s_id[sid])):
  1102.         msg = '***Currently playing:***\n*{0}*  **Duration:** {1}'.format(info[sid]['title'], datetime.timedelta(seconds=info[sid]['duration']))
  1103.         if loop == True:
  1104.             msg += '\n**Loop of current song is** ***enabled!***'
  1105.         await client.send_message(message.channel, msg)
  1106.  
  1107.  
  1108.     #MUSIC SKIP
  1109.     if (message.content.startswith('{0}skip'.format(s_id[sid]))) or (message.content.startswith('{0}next'.format(s_id[sid]))):
  1110.         await music_skip(message)
  1111.     return None
  1112.        
  1113.  
  1114. async def music_playlist(message):
  1115.     global vc, cp, playlist, urllist, client
  1116.  
  1117.     if playlist[message.server.id] != []:
  1118.         url = playlist[message.server.id][0]
  1119.     else:
  1120.         return
  1121.    
  1122.     if (cp[message.server.id] == 'False') and (playlist[message.server.id] != []):
  1123.         await music_bot(url, message)
  1124.        
  1125.  
  1126. async def music_bot(url, message):
  1127.     global vc, cp, playlist, urllist, loop, ytdl, cpsong, info, client, cpsong_two, voice_list
  1128.     sid = message.server.id
  1129.    
  1130.     if not message.server.id in cpsong:
  1131.         cpsong[sid] = ''
  1132.     if not sid in cpsong_two:
  1133.         cpsong_two[sid] = ''
  1134.     if not sid in voice_list:
  1135.         voice_list[sid] = None
  1136.        
  1137.        
  1138.     cpsonglocal = {}
  1139.     timethingy = str(timeit.timeit())
  1140.    
  1141.     cpsong_two[sid] = url
  1142.     cpsong[sid] = timethingy
  1143.     cpsonglocal[sid] = timethingy
  1144.     if not client.is_voice_connected(message.server):
  1145.         while playlist[sid] != []:
  1146.  
  1147.             channel = message.author.voice.voice_channel
  1148.             vc = await client.join_voice_channel(channel)
  1149.             voice_list[sid] = vc
  1150.             musicplayer = await voice_list[sid].create_ytdl_player(url, before_options=" -reconnect 1 -reconnect_streamed 1"
  1151.                                                                            " -reconnect_delay_max 5")
  1152.             players[sid] = musicplayer
  1153.             musicplayer.start()
  1154.             cp[sid] = 'True'
  1155.            
  1156.             info[sid] = ytdl.extract_info(url, download = False)
  1157.            
  1158.             await asyncio.sleep(int(info[sid]['duration'])-1)
  1159.             if cpsong[sid] == cpsonglocal[sid]:
  1160.                 cp[sid] = 'False'
  1161.                 await loop_check(url, message)
  1162.             else:
  1163.                 return
  1164.                 print('no')
  1165.                
  1166.     elif client.is_voice_connected(message.server):
  1167.         while playlist[sid] != []:
  1168.             vc = client.voice_client_in(message.server)
  1169.             voice_list[sid] = vc
  1170.             musicplayer = await voice_list[sid].create_ytdl_player(url, before_options=" -reconnect 1 -reconnect_streamed 1"
  1171.                                                                            " -reconnect_delay_max 5")
  1172.             players[sid] = musicplayer
  1173.             musicplayer.start()
  1174.             cp[sid] = 'True'
  1175.            
  1176.             info[sid] = ytdl.extract_info(url, download = False)
  1177.            
  1178.             await asyncio.sleep(int(info[sid]['duration'])-1)
  1179.             if cpsong[sid] == cpsonglocal[sid]:
  1180.                 cp[sid] = 'False'
  1181.                 await loop_check(url, message)
  1182.             else:
  1183.                 return
  1184.                 print('no')
  1185.                    
  1186.    
  1187. async def loop_check(url, message):
  1188.     global loop, playlist, urllist, lp, client
  1189.  
  1190.     if lp[message.server.id] == True:
  1191.  
  1192.         playlist[message.server.id].append(url)
  1193.         del(playlist[message.server.id][0])
  1194.    
  1195.         await music_playlist(message)
  1196.        
  1197.     else:
  1198.    
  1199.         if loop[message.server.id] == True:
  1200.             await music_bot(url, message)
  1201.         elif loop[message.server.id] == False:
  1202.             del(playlist[message.server.id][0])
  1203.             await music_playlist(message)
  1204.  
  1205. async def music_skip(message):
  1206.     global players, playlist, urllist, cp, urls, client
  1207.     sid = message.server.id
  1208.  
  1209.     if 'DJ' in message.server.roles:
  1210.         print('SKIP TEST 1')
  1211.         if 'DJ' in message.author.roles:
  1212.  
  1213.             print('SKIP TEST 2')
  1214.             cp[message.server.id] = 'False'
  1215.             players[message.server.id].stop()
  1216.             playlist[message.server.id] = playlist[message.server.id][len(urls[message.server.id])+7:]
  1217.             msg = 'Skipping current song...'
  1218.             await client.send_message(message.channel, msg)
  1219.             await music_playlist(message)
  1220.         else:
  1221.             msg = 'Insufficent permission!'
  1222.             await client.send_message(message.channel, msg)
  1223.             print('SKIP TEST 3')
  1224.     else:
  1225.         if playlist[sid] == []:
  1226.             msg = '***There is no song playing at the moment! Queue some using {0}p url!***'.format(s_id[sid])
  1227.             await client.send_message(message.channel, msg)
  1228.             return
  1229.         else:
  1230.             if lp[sid] == True:
  1231.            
  1232.                 playlist[message.server.id].append(playlist[message.server.id][0])
  1233.                 del(playlist[message.server.id][0])
  1234.                
  1235.             else:
  1236.                 del(playlist[message.server.id][0])
  1237.             cp[message.server.id] = 'False'
  1238.             players[message.server.id].stop()
  1239.             msg = 'Skipping current song...'
  1240.             await client.send_message(message.channel, msg)
  1241.             await music_playlist(message)
  1242.  
  1243. async def music_playlist_print(message):
  1244.     global playlist, youtube, s_id, lp, client
  1245.     sid = message.server.id
  1246.     if not sid in playlist:
  1247.         msg = '**There are no songs in queue at the moment! Queue some using {0}p url!**'.format(s_id[sid])
  1248.         await client.send_message(message.channel, msg)
  1249.     else:
  1250.         urls = playlist[sid]
  1251.         ids = ','.join(urls)  
  1252.         msg = '***Current playlist:***\n'
  1253.  
  1254.         results = {}
  1255.         while results == {}:
  1256.             try:
  1257.                 results = youtube.videos().list(id=ids, part='snippet').execute()
  1258.             except:
  1259.                 print('Youtube results unsucessful, retrying...')
  1260.         msg += '\n'.join(
  1261.             '**{0}**: *{1}*'.format(i, item['snippet']['title'])
  1262.             for i, item in
  1263.             enumerate(results.get('items', []), start=1))
  1264.         if lp[sid] == True:
  1265.             msg += '\n**Loop of the playlist is** ***__enabled!__***'
  1266.         msg += ' \n**You can remove a song from queue by using {0}playlist delete <number_in_queue>!**'.format(s_id[sid])
  1267.         if not '1' in msg:
  1268.             msg = '**There are no songs in queue at the moment! Queue some using {0}p url!**'.format(s_id[sid])
  1269.         await send_message(message, msg)
  1270.     return
  1271.        
  1272. async def send_message(message, msg, *args, **kwargs):
  1273.     global lp, s_id, client
  1274.     sid = message.server.id
  1275.     if len(msg) > 1800:
  1276.         first2k = msg[:1800]
  1277.         last_nl = first2k.rfind('\n')
  1278.         firstMsg = msg[:last_nl]
  1279.         rest = msg[last_nl:]
  1280.         if lp[sid] == True:
  1281.             firstMsg += '\n**Loop of the playlist is** ***__enabled!__***'
  1282.         firstMsg += ' \n**You can remove a song from queue by using {0}playlist delete <number_in_queue>!**'.format(s_id[sid])
  1283.     else:
  1284.         firstMsg = msg
  1285.  
  1286.     await client.send_message(message.channel, firstMsg, *args, **kwargs)
  1287.  
  1288.        
  1289. async def miku_reaction(message):
  1290.     global miku_names, client
  1291.     for i in miku_names:
  1292.         if i in message.content:
  1293.             await asyncio.sleep(0.37)
  1294.             if not 'love' in message.content:
  1295.                 msg = random.choice(miku_message).format(message.author.mention)
  1296.             else:
  1297.                 msg = 'I l-love you t-too, s-senpai..! S-so much..! :flushed: *She hugs {0} tightly, blushing red, smiling.*'.format(message.author.mention)
  1298.             await client.send_message(message.channel, msg)
  1299.             return
  1300.  
  1301. async def talk(message):
  1302.     global ts
  1303.     while ts:
  1304.         msg = input()
  1305.         if msg == 'talk':
  1306.             ts = False
  1307.             break
  1308.         else:
  1309.             await client.send_message(message.channel, msg)
  1310.            
  1311.  
  1312. statuses = ["with Lily", "with Ana", "with Yuno", "with Eri", "with Honoka", "with Nico", "with Nico", "with Nico Nico Niii~",
  1313.             "with Maki", "with herself", "with her toys", "with Nozomi", "with Kotori", "with Umi", "with Rin", "with Hanayo",
  1314.             "with Chika", "with Riko", "with Kanan", "with Dia", "with You-chan", "with Yoshiko", "with Yohanne", "with Hanamaru zuraaa~",
  1315.             "with Mari", "with Ruby", "with Taiga", "with her phone", "with Toastie", "with Ado-kun", "with adorable Ana-chan",
  1316.             "with Mashiro", "with Yuzu", "with Sprii", "with Katalina", "with her creator", "with Angela", "with her hair", "with Aqours", "with µ's",
  1317.             "with Luka", "Doki Doki Literature Club", "with Natsuki..?", "with Yuri", "with Sayori", "with Monika", "with Hana", "with her friends",
  1318.             "with Faerlynn", "nothing... Weird...", "with Satou", "with Shio", "with Livvy", "as Mercy", "as Ana", "as Brigitte", "as Pharah", "as D.Va",
  1319.             "as Mei", "as Sombra", "as Ashe", "as Moira", "as Symmetra", "as Tracer", "as Zarya", "as Miku", "as Luka", "as Athena", "as Echo",
  1320.             "as Efi", "with Katniss", "never have I ever", "with Kyō", "with Evitel", "with Taliesin", "with Kwoon-kun", "with awesome Kwoon"]
  1321.  
  1322.  
  1323. async def task_loop(client):
  1324.     while True:
  1325.         me = discord.utils.find(lambda s: s != None, client.servers).me
  1326.         if not me:
  1327.                 return
  1328.         elif not me.game:
  1329.                 updated_game = discord.Game(name = random.choice(statuses))              
  1330.         else:
  1331.                 updated_game = me.game
  1332.                 updated_game.name = random.choice(statuses)              
  1333.         await client.change_presence(game = updated_game)
  1334.         await asyncio.sleep(300 + random.randrange(150))
  1335.  
  1336. async def chat_log_loop(client):
  1337.     while log_enable:
  1338.         global chat_log
  1339.         temp = ''
  1340.         #print('Saving chat log...')
  1341.         t = open("bot_save_files/chat_log.txt", 'r')
  1342.         temp = t.read()
  1343.         t.close()
  1344.         file = open("bot_save_files/chat_log.txt", 'w')
  1345.         file.write(temp)
  1346.         file.write(chat_log)
  1347.         file.close()
  1348.         chat_log = ''
  1349.         #print('Log saved!')
  1350.        
  1351.         await asyncio.sleep(120)
  1352.  
  1353. async def quick_save():
  1354.     if log_enable == True:
  1355.         global chat_log
  1356.         temp = ''
  1357.         #print('Saving chat log...')
  1358.         if
  1359.         t = open("bot_save_files/chat_log.txt", 'r', encoding = 'utf8')
  1360.         temp = t.read()
  1361.         t.close()
  1362.         file = open("bot_save_files/chat_log.txt", 'w', encoding = 'utf8')
  1363.         file.write(temp)
  1364.         file.write(chat_log)
  1365.         file.close()
  1366.         chat_log = ''
  1367.         #print('Log saved!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement