12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import discord
- from youtubesearchpython import VideosSearch
- def on_ready_print(self):
- print("---------")
- print("Logged as")
- print(self.user.name)
- print(self.user.id)
- print("---------")
- async def receive_message_then_send(message, received: str, to_send=""):
- if message.content == received:
- if to_send:
- await message.channel.send(to_send)
- return True
- def get_commands_from_file(filename: str) -> tuple:
- with open(filename, 'r') as file:
- _help_commands = tuple((command.split('\n')[0] for command in file))
- return _help_commands
- def message_is_song_name(message):
- return message.content.split(' ')[0] == '!song'
- def _get_song_name_from_message(message):
- parsed_msg_list = message.content.split(' ')
- song_name = ' '.join(parsed_msg_list[1:])
- if not song_name:
- raise NameError("Song name can't be empty!")
- return song_name
- def _get_movie_id(videos_search):
- return videos_search.result()['result'][0]['id']
- def get_video_url_by_song_name(message):
- url = 'https://www.youtube.com/watch?v='
- song_name = _get_song_name_from_message(message)
- videos_search = VideosSearch(song_name, limit=1)
- video_id = _get_movie_id(videos_search)
- return url + video_id
- def get_embed(url):
- return discord.Embed().set_image(url=url)
- def get_commands_list_to_send(self):
- return "Available commands: \n" + self._help_commands_for_output
- def is_embed(message):
- return message.content == ""
- def in_bot_channel(channel=None, message=None):
- if message:
- channel = message.channel
- return channel.name == 'bot'
|