mirror of
https://github.com/myned/modufur.git
synced 2024-12-24 22:27:28 +00:00
Prune incomplete, vestigial, and irrelevant code
- Completely removed music cog for now - Halted Google Play Music integration - Removed "periodic_gpm" items from tasks file
This commit is contained in:
parent
9c4223d0f5
commit
fd7c4d44f5
4 changed files with 2 additions and 114 deletions
|
@ -1,57 +0,0 @@
|
||||||
import asyncio
|
|
||||||
import json
|
|
||||||
from datetime import datetime as dt
|
|
||||||
from urllib import parse
|
|
||||||
import re
|
|
||||||
from pprint import pprint
|
|
||||||
|
|
||||||
import discord as d
|
|
||||||
from discord import errors as err
|
|
||||||
from discord.ext import commands as cmds
|
|
||||||
from discord.ext.commands import errors as errext
|
|
||||||
# import gmusicapi as gpm
|
|
||||||
# import googleapiclient as gapic
|
|
||||||
# import apiclient as apic
|
|
||||||
|
|
||||||
from misc import exceptions as exc
|
|
||||||
from misc import checks
|
|
||||||
from utils import utils as u
|
|
||||||
|
|
||||||
|
|
||||||
class Music:
|
|
||||||
|
|
||||||
# def __init__(self, bot):
|
|
||||||
# self.bot = bot
|
|
||||||
#
|
|
||||||
# self.yt_service = apic.discovery.build('youtube', 'v3', developerKey=u.secrets['client_secrets']['client_secret'])
|
|
||||||
#
|
|
||||||
@cmds.group(aliases=['pl'], brief='(G) Play music', description='Play music from YouTube, Soundcloud, or Google Play Music')
|
|
||||||
async def play(self, ctx):
|
|
||||||
print(ctx.invoked_subcommand)
|
|
||||||
#
|
|
||||||
# @play.command(name='youtube', aliases=['you', 'tube', 'yt', 'y'])
|
|
||||||
# async def _play_youtube(self, ctx, *videos):
|
|
||||||
# try:
|
|
||||||
# if not videos:
|
|
||||||
# raise exc.MissingArgument
|
|
||||||
#
|
|
||||||
# vids = []
|
|
||||||
#
|
|
||||||
# for video in videos:
|
|
||||||
# if 'http' in video and 'youtube' in video:
|
|
||||||
# vids.append(parse.parse_qs(parse.urlparse(video).query)['v'][0])
|
|
||||||
# else:
|
|
||||||
# vids.append(video)
|
|
||||||
#
|
|
||||||
# print(vids)
|
|
||||||
#
|
|
||||||
# response = self.yt_service.videos().list(part='snippet', id=','.join(vids)).execute()
|
|
||||||
# pprint(response)
|
|
||||||
#
|
|
||||||
# except exc.MissingArgument:
|
|
||||||
# await ctx.send('**Invalid youtube url or ID**', delete_after=7)
|
|
||||||
# await ctx.message.add_reaction('\N{CROSS MARK}')
|
|
||||||
|
|
||||||
@play.command(name='googleplaymusic', aliases=['googleplay', 'googlemusic', 'playmusic', 'play', 'gpm'])
|
|
||||||
async def _play_googleplaymusic(self, ctx, query):
|
|
||||||
pass
|
|
|
@ -6,7 +6,6 @@ import discord as d
|
||||||
from discord import errors as err
|
from discord import errors as err
|
||||||
from discord.ext import commands as cmds
|
from discord.ext import commands as cmds
|
||||||
from discord.ext.commands import errors as errext
|
from discord.ext.commands import errors as errext
|
||||||
import gmusicapi as gpm
|
|
||||||
|
|
||||||
from misc import exceptions as exc
|
from misc import exceptions as exc
|
||||||
from misc import checks
|
from misc import checks
|
||||||
|
@ -18,16 +17,9 @@ class Post:
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
for task in u.tasks['periodic_gpm']:
|
|
||||||
self.bot.loop.create_task()
|
|
||||||
|
|
||||||
async def _check_posts(self, user, channel):
|
async def _check_posts(self, user, channel):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@cmds.group(aliases=['update', 'up', 'u'])
|
@cmds.group(aliases=['update', 'up', 'u'])
|
||||||
async def updates(self, ctx):
|
async def updates(self, ctx):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@updates.command(name='googleplaymusic', aliases=['googlemusic', 'playmusic', 'music', 'gpm'])
|
|
||||||
async def _updates_googleplaymusic(self, ctx):
|
|
||||||
pass
|
|
||||||
|
|
|
@ -7,12 +7,7 @@ import traceback as tb
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
|
||||||
import discord as d
|
import discord as d
|
||||||
import httplib2
|
|
||||||
import requests_oauthlib as ro
|
|
||||||
from apiclient import http
|
|
||||||
from apiclient.discovery import build
|
|
||||||
from discord.ext import commands as cmds
|
from discord.ext import commands as cmds
|
||||||
from oauth2client.client import flow_from_clientsecrets
|
|
||||||
|
|
||||||
#from run import config
|
#from run import config
|
||||||
from cogs import booru
|
from cogs import booru
|
||||||
|
@ -51,7 +46,7 @@ class Utils:
|
||||||
await ctx.message.add_reaction('\N{TABLE TENNIS PADDLE AND BALL}')
|
await ctx.message.add_reaction('\N{TABLE TENNIS PADDLE AND BALL}')
|
||||||
await ctx.send(ctx.author.mention + ' \N{TABLE TENNIS PADDLE AND BALL} `' + str(round(self.bot.latency * 1000)) + 'ms`', delete_after=5)
|
await ctx.send(ctx.author.mention + ' \N{TABLE TENNIS PADDLE AND BALL} `' + str(round(self.bot.latency * 1000)) + 'ms`', delete_after=5)
|
||||||
|
|
||||||
@cmds.command(aliases=['pre'], brief='List bot prefixes', description='Shows all used prefixes')
|
@cmds.command(aliases=['pre', 'prefixes'], brief='List bot prefixes', description='Shows all used prefixes')
|
||||||
async def prefix(self, ctx):
|
async def prefix(self, ctx):
|
||||||
await ctx.send('**Prefix:** `{}`'.format('` or `'.join(u.settings['prefixes'][ctx.guild.id] if ctx.guild.id in u.settings['prefixes'] else u.config['prefix'])))
|
await ctx.send('**Prefix:** `{}`'.format('` or `'.join(u.settings['prefixes'][ctx.guild.id] if ctx.guild.id in u.settings['prefixes'] else u.config['prefix'])))
|
||||||
|
|
||||||
|
@ -80,44 +75,3 @@ class Utils:
|
||||||
@send.command(name='user', aliases=['u', 'member', 'm'])
|
@send.command(name='user', aliases=['u', 'member', 'm'])
|
||||||
async def send_user(self, ctx, user, *, message):
|
async def send_user(self, ctx, user, *, message):
|
||||||
await d.utils.get(self.bot.get_all_members(), id=int(user)).send(message)
|
await d.utils.get(self.bot.get_all_members(), id=int(user)).send(message)
|
||||||
|
|
||||||
@cmds.command(aliases=['authenticateupload', 'authupload', 'authup', 'auth'], hidden=True)
|
|
||||||
async def authenticate_upload(self, ctx):
|
|
||||||
global youtube
|
|
||||||
flow = flow_from_clientsecrets('client_secrets.json', scope='https://www.googleapis.com/auth/youtube.upload',
|
|
||||||
login_hint='botmyned@gmail.com', redirect_uri='urn:ietf:wg:oauth:2.0:oob')
|
|
||||||
flow.params['access_type'] = 'offline'
|
|
||||||
webbrowser.open_new_tab(flow.step1_get_authorize_url())
|
|
||||||
credentials = flow.step2_exchange(input('Authorization code: '))
|
|
||||||
youtube = build('youtube', 'v3', http=credentials.authorize(http.build_http()))
|
|
||||||
print('Service built.')
|
|
||||||
|
|
||||||
@cmds.command(aliases=['up', 'u', 'vid', 'v'], hidden=True)
|
|
||||||
@cmds.has_permissions(administrator=True)
|
|
||||||
async def upload(self, ctx):
|
|
||||||
global youtube
|
|
||||||
attachments = ctx.message.attachments
|
|
||||||
try:
|
|
||||||
if not attachments:
|
|
||||||
raise exc.MissingAttachment
|
|
||||||
if len(attachments) > 1:
|
|
||||||
raise exc.TooManyAttachments(len(attachments))
|
|
||||||
mime = mimetypes.guess_type(attachments[0].filename)[0]
|
|
||||||
if 'video/' in mime:
|
|
||||||
with tempfile.NamedTemporaryFile() as temp:
|
|
||||||
await attachments[0].save(temp)
|
|
||||||
else:
|
|
||||||
raise exc.InvalidVideoFile(mime)
|
|
||||||
print('https://www.youtube.com/watch?v=' + youtube.videos().insert(part='snippet',
|
|
||||||
body={'categoryId': '24', 'title': 'Test'}, media_body=http.MediaFileUpload(temp.name, chunksize=-1)))
|
|
||||||
except exc.InvalidVideoFile as e:
|
|
||||||
await ctx.send('`' + str(e) + '` **invalid video type**', delete_after=7)
|
|
||||||
except exc.TooManyAttachments as e:
|
|
||||||
await ctx.send('`' + str(e) + '` **too many attachments.** Only one attachment is permitted to upload.', delete_after=7)
|
|
||||||
except exc.MissingAttachment:
|
|
||||||
await ctx.send('**Missing attachment**', delete_after=7)
|
|
||||||
|
|
||||||
@upload.error
|
|
||||||
async def upload_error(self, ctx, error):
|
|
||||||
pass
|
|
||||||
# http.
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import subprocess
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from fractions import gcd
|
from fractions import gcd
|
||||||
import math
|
import math
|
||||||
import gmusicapi as gpm
|
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import discord as d
|
import discord as d
|
||||||
|
@ -82,7 +81,7 @@ def dump(obj, filename, *, json=False):
|
||||||
|
|
||||||
|
|
||||||
settings = setdefault('misc/settings.pkl', default={'del_ctx': [], 'del_resp': [], 'prefixes': {}})
|
settings = setdefault('misc/settings.pkl', default={'del_ctx': [], 'del_resp': [], 'prefixes': {}})
|
||||||
tasks = setdefault('cogs/tasks.pkl', default={'auto_del': [], 'auto_hrt': [], 'auto_rev': [], 'periodic_gpm': []})
|
tasks = setdefault('cogs/tasks.pkl', default={'auto_del': [], 'auto_hrt': [], 'auto_rev': []})
|
||||||
temp = setdefault('temp/temp.pkl', default={'startup': ()})
|
temp = setdefault('temp/temp.pkl', default={'startup': ()})
|
||||||
secrets = setdefault('secrets.json', default={'client_secrets': {'client_id': '', 'client_secret': ''}}, json=True)
|
secrets = setdefault('secrets.json', default={'client_secrets': {'client_id': '', 'client_secret': ''}}, json=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue