Beispiel #1
0
    async def _rgb(self, ctx, lid: int, r: int, g: int, b: int):
        """
            Changes light colour
            
            Params:
                ! lid: integer (light id)
                ! r: integer (0 - 255)
                ! g: integer (0 - 255)
                ! b: integer (0 - 255)

            ! = Required, ? = Optional
        """
        self.data = jso.read_json("controller.json")
        conv = Converter(GamutB)

        if self.data['allowDiscordChange'] == True:
            m.changeCol(lid, conv.rgb_to_xy(r, g, b), 254, 254, self.ip,
                        self.user)
            hex = m.rgbToHex(r, g, b)
            colName = m.getColNameByRGB(r, g, b)
            embed = discord.Embed(
                title=f"{colName}",
                description=f"Updated light {lid} to {colName} ({r} {g} {b})")
            embed.set_thumbnail(url=f"{m.getColImage(r, g, b)}")
            await ctx.send(embed=embed)
        else:
            embed = discord.Embed(
                title="Error: 1 (Permission Denied)",
                url="https://auto.avex.dev/errors?id=1",
                description=
                "Sorry, but any remote change, via discord or auto.avex.dev has been disabled! Stay tuned for a change in #status\n\nClick [here](https://avex.dev/errors/1) to view error",
                color=0xff0000)
            await ctx.send(embed=embed)
Beispiel #2
0
    async def _on(self, ctx, lid: int):
        """
           Turns a light on. 

           Params:
               ! lid: integer (light id)

           ! = Required, ? = Optional
        """
        self.data = jso.read_json("controller.json")

        if self.data['allowDiscordChange'] == True:
            m.turnOn(self.ip, self.user, lid)

            embed = discord.Embed(
                title=f"Light {lid} Turned On!",
                url="https://auto.avex.dev",
                description=f"Succesfully turned light {lid} on!",
                color=0x80ff00)
            embed.set_thumbnail(
                url=
                "https://www.assets.signify.com/is/image/PhilipsLighting/80cc70d6f53343cc8baea9b9009d764d?&wid=110&hei=110&$jpglarge$"
            )
            await ctx.send(embed=embed)
        else:
            embed = discord.Embed(
                title="Error: 1 (Permission Denied)",
                url="https://auto.avex.dev/errors?id=1",
                description=
                "Sorry, but any remote change, via discord or auto.avex.dev has been disabled! Stay tuned for a change in #status\n\nClick [here](https://avex.dev/errors/1) to view error",
                color=0xff0000)
            await ctx.send(embed=embed)
Beispiel #3
0
    async def _test(self, ctx, lid: int):
        """
            Turns a light off.

            Params:
                ! lid: integer (light id)

            ! = Required, ? = Optional
        """
        self.data = jso.read_json("controller.json")

        if self.data['allowDiscordChange'] == True:
            m.turnOff(self.ip, self.user, lid)

            embed = discord.Embed(
                title=f"Light {lid} Turned Off!",
                url="https://auto.avex.dev",
                description=f"Succesfully turned light {lid} off!")
            embed.set_thumbnail(
                url=
                "https://images.squarespace-cdn.com/content/v1/59937b8f2994cae8c280ca6c/1504903605561-PYMALOQSSWJRGYEKD8QK/ke17ZwdGBToddI8pDm48kGDpvalPb1SqHoCn1hwN0Y57gQa3H78H3Y0txjaiv_0fDoOvxcdMmMKkDsyUqMSsMWxHk725yiiHCCLfrh8O1z5QHyNOqBUUEtDDsRWrJLTmQPoRzxSr1hzN-vPBHt7YyLLXgctAyUJRqJUUGWVDK_ZzIgvsybGcZEPqUYiXY8im/Yonomi+-+Philips+Hue+A19+Smart+Color+Bulb.jpg"
            )
            await ctx.send(embed=embed)
        else:
            embed = discord.Embed(
                title="Error: 1 (Permission Denied)",
                url="https://auto.avex.dev/errors?id=1",
                description=
                "Sorry, but any remote change, via discord or auto.avex.dev has been disabled! Stay tuned for a change in #status\n\nClick [here](https://avex.dev/errors/1) to view error",
                color=0xff0000)
            await ctx.send(embed=embed)
Beispiel #4
0
from flask import Blueprint, request, render_template, redirect, session, make_response, jsonify
from misc.oauth import Oauth
router = Blueprint("auth", __name__)

import misc.jsonHandler as jh
dev = jh.read_json("mode.json")
dev = dev['dev']


@router.route("/auth", methods=["post"])
def index():
    if request.args.get("code") is None:
        d = {"data": "INVALID"}
        return jsonify(d)
    else:
        code = request.args.get("code")
        access_token = Oauth.get_access_token(code)
        responsee = {"data": access_token}
        return jsonify(responsee)
Beispiel #5
0
import os

import discord
from discord.ext import commands

from misc import jsonHandler as jso

from misc import inject

inject.injectVariables()


dev = jso.read_json("mode.json")
dev = dev['dev']

if dev == True:
    prefix = os.getenv("devPrefix")
    token = os.getenv("devToken")
else:
    prefix = "-"
    token = os.getenv("discordToken")

client = commands.Bot(command_prefix=prefix, case_insensitive=True)
@client.event
async def on_ready():
    print(f"[Client] {client.user} connected to discord!")
    client.load_extension('cogs.LightController')
    client.load_extension('cogs.Colours')
    client.load_extension('cogs.Fun')
    client.load_extension('cogs.Music')
Beispiel #6
0
import os
import requests

import misc.jsonHandler as js

mode = js.read_json('mode.json')
mode = mode['dev']


class Oauth(object):
    client_id = str(os.getenv("clientId"))
    client_secret = str(os.getenv("clientSecret"))
    scope = "identify"
    redirect_url_dev = "http://127.0.0.1:5000/auth"
    redirect_url = "https://avex.dev/auth"
    discord_login_url = "https://discord.com/api/oauth2/authorize?client_id=697115395504603248&redirect_uri=https%3A%2F%2Favex.dev%2Fauth&response_type=code&scope=identify"
    discord_login_url_dev = "https://discord.com/api/oauth2/authorize?client_id=715526745033539615&redirect_uri=http%3A%2F%2F127.0.0.1%3A5000%2Fauth&response_type=code&scope=identify"
    discord_token_url = "https://discordapp.com/api/oauth2/token"
    discord_api_url = "https://discordapp.com/api/"

    @staticmethod
    def get_access_token(code):
        if mode == True:
            payload = {
                'client_id': Oauth.client_id,
                'client_secret': Oauth.client_secret,
                'grant_type': 'authorization_code',
                'code': code,
                'redirect_uri': Oauth.redirect_url_dev,
                'scope': Oauth.scope
            }