Exemple #1
0
 def __init__(self, database_connexion):
     self.shared = memcache.Client(['127.0.0.1:11211'], debug=0)
     self.keys = {}  # Osu id : [Key, Discord Id]
     self.shared.set('keys', self.keys)
     self.database_connexion = database_connexion
     self.database_cursor = database_connexion.cursor()
     self.api = OsuApi(constants.Api.osuApiKey, connector=ReqConnector())
Exemple #2
0
def check_for_stats(osu_name):
    cursor.execute("SELECT osuId FROM users WHERE osuName = ?", (osu_name, ))
    osu_id = cursor.fetchall()
    if not osu_id:

        sender.send_message(
            osu_name,
            "Hey ! Nice to meet you, it seems to be your first time here ! Remember that this bot is also available on discord [https://discord.gg/Qsw3yD5 server] [https://discordapp.com/oauth2/authorize?client_id=318357311951208448&scope=bot&permissions=8 add the bot to your server] ! Oh and also, if you need a list of the commands avaiable, type : o!help. GL & HF"
        )

        response = requests.get("https://osu.ppy.sh/api/get_user?k=" +
                                constants.Api.osuApiKey + "&u=" + osu_name,
                                verify=True)
        data = response.json()
        osu_id = data[0]["user_id"]

        cursor.execute("INSERT INTO users (osuId, osuName) VALUES (?, ?)", (
            osu_id,
            osu_name,
        ))
        conn.commit()
        api = OsuApi(constants.Api.osuApiKey, connector=ReqConnector())
        update_stats.update_stats(0, conn, api, username=osu_name)
        return osu_id
    else:
        return osu_id[0][0]
Exemple #3
0
    def __init__(self, bot):
        self.bot = bot
        self.config = confparser.get("config.json")

        self.api = OsuApi(key=self.config.osu_token, connector=ReqConnector())
        self.last_check_datetime = datetime.datetime.utcnow()
        self.tracking_channel = None
        self.tracked_users = self.get_tracked_users()

        self.tracker_task_loop.start()
Exemple #4
0
def update_all_stats(conn, cursor):
    cursor.execute("SELECT osuId FROM users")
    requestResults = cursor.fetchall()
    for osu_id in requestResults:
        print(osu_id[0], end=" ")
        api = OsuApi(constants.Api.osuApiKey, connector=ReqConnector())
        try:
            update_stats(0, conn, api, osuId=osu_id[0])
        except:
            update_stats(0, conn, api, osuId=osu_id[0])
        print("Done")
Exemple #5
0
    def __init__(self, discordClient):

        with open("config.json") as f:
            config = json.loads(f.read())

        self.bot = discordClient
        self.osuApi = OsuApi(config["osu_key"], connector=ReqConnector())
        self.modeMap = {'standard': enums.OsuMode.osu, 'mania': enums.OsuMode.mania}
        self.db = 'guild_settings.db'
        self.table = 'settings'
        self.settings = {'guild_id': 'guild_id',
                        'guild_name': 'guild_name',
                        'commands_disabled': 'commands_disabled',
                        'roll_channel': 'roll_channel',
                        'osu_channel': 'osu_channel',
                        'admin_role': 'admin_role'}
Exemple #6
0
 async def osu(self, ctx, *user):
     username = ''
     i = 0
     for word in user:
         i += 1
         if word == user[-1] and len(user) == i:
             username += str(word)
         else:
             username += str(word) + ' '
     api = OsuApi(osuapikey, connector=ReqConnector())
     results = api.get_user(username)
     userid = results[0].user_id
     thumbnail = "https://s.ppy.sh/a/" + str(userid)
     embed = Embed(title="%s" % (username),
                   description="id:%s" % (userid),
                   color=0xE0FFFF)
     embed.set_thumbnail(url=thumbnail)
     await self.bot.send_message(ctx.message.channel, embed=embed)
     await self.bot.send_message(ctx.message.channel,
                                 "https://osu.ppy.sh/users/%d" % userid)
Exemple #7
0
from SwSpotify import SpotifyClosed, SpotifyNotRunning, spotify
import SwSpotify
from osuapi import OsuApi, ReqConnector
import requests
import json
import obswebsocket, obswebsocket.requests, obswebsocket.events
from threading import Thread
import launchpad_py
from websockets import server
from radke_logging import Logger, loggingLevel
import keyboard
from time import sleep
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
api = OsuApi("346ab1522e56b657ada35ff7075f3553ee3fac24",
             connector=ReqConnector())
lp = launchpad_py.Launchpad()
obs = obswebsocket.obsws()
logger = Logger(True, "espdeck.log", 3)
launchpadEnabled = False
websocketEnabled = False
if (lp.Check(0)):
    launchpadEnabled = True
    lp.Open(0)
    lp.LedCtrlXY(6, 8, 0, 3)
    lp.LedCtrlXY(7, 8, 3, 0)
    lp.LedCtrlXY(8, 8, 3, 0)
    lp.LedCtrlXY(5, 6, 0, 3)
    lp.LedCtrlXY(6, 6, 2, 3)
    lp.LedCtrlXY(7, 6, 0, 3)
    lp.LedCtrlXY(4, 8, 3, 0)
import pandas as pd
import numpy as np
import warnings
warnings.filterwarnings('ignore')
import datetime
from datetime import date
from pyecharts import options as opts
from pyecharts.charts import Bar, Page, Pie, Grid
from pyecharts.faker import Collector, Faker
from pyecharts.globals import ThemeType
from pyecharts.components import Table, Image
from pyecharts.options import ComponentTitleOpts
from pyecharts.commons.utils import JsCode
from osuapi import OsuApi, ReqConnector, OsuMode
import requests
api = OsuApi("13a36d70fd32e2f87fd2a7a89e4f52d54ab337a1", connector=ReqConnector())

user_name = input('Please enter osu! user name:')


#######################  get mapper beatmaps info  #######################

try:
    beatmap_list= api.get_beatmaps(since=None, beatmapset_id=None, beatmap_id=None, username=user_name, mode=None, include_converted=True, beatmap_hash=None, limit=500)    
    df_beatmap = pd.DataFrame()
    for beatmap in beatmap_list:
        df_beatmap_1 = pd.DataFrame( dict(beatmap), index=[0])
        df_beatmap = df_beatmap.append(df_beatmap_1, ignore_index=True)
except:
    print('No results for user name')
    sys.exit()
Exemple #9
0
import requests
from functions import *

from osuapi import OsuApi, ReqConnector

Token_read = open("token.txt")
api_read = open("osuapikey.txt")


TOKEN = Token_read.readline()
apicode = api_read.readline()

import json


api = OsuApi(apicode, connector=ReqConnector())

client = commands.Bot(command_prefix = 'f!')

def restart_program():
    """Restarts the current program.
    Note: this function does not return. Any cleanup action (like
    saving data) must be done before calling this function."""
    python = sys.executable
    os.execl(python, python, * sys.argv)


@client.event
async def on_ready():
    ready_message = "Logged in as" + client.user.name + "\n ID:" + client.user.id
    print(ready_message)
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
from osuapi import OsuApi, ReqConnector
import requests
from pprint import pprint

# Easy way to test card designs
osuapi = OsuApi("your key", connector=ReqConnector())

rank = "C"


def create_card(map_id=131891):
    raw = "Hidden spunout nofail"
    score_mods = raw.split(" ")

    card_name = f"{map_id}{discord_id}"
    map_object = osuapi.get_beatmaps(mode=0, beatmap_id=map_id, limit=30)[0]
    response = requests.get(f"https://assets.ppy.sh/beatmaps/{map_object.beatmapset_id}/covers/cover.jpg")
    pprint("Grabbed map image")
    file = open(f"cards/{card_name}.png", "wb")
    file.write(response.content)
    file.close()
    img = Image.open(f"cards/{card_name}.png")
    img2 = Image.open(f"bace/cardbace{rank}.png")
    img2.paste(img, (15,55))
    draw = ImageDraw.Draw(img2)
    font = ImageFont.truetype("font/Exo2.0-Regular.otf", 24)
    combo_font = ImageFont.truetype("font/Overpass-Regular.ttf", 70)
    Score_font = ImageFont.truetype("font/Overpass-Regular.ttf", 60)
Exemple #11
0
from osuapi import OsuApi, ReqConnector
from flaskext.markdown import Markdown
from functools import wraps
import binascii
import requests
import logging
import random
import redis
import json
import math
import os

app = Flask(__name__)
app.config['SECRET_KEY'] = os.environ.get("SECRET_KEY")
md = Markdown(app)  #for a markdown work, e.g FAQ
osu_api = OsuApi(os.environ.get("osu"), connector=ReqConnector())
Redis = os.environ.get('Redis')
OAUTH2_CLIENT_ID = os.environ.get('OAUTH2_CLIENT_ID')
OAUTH2_CLIENT_SECRET = os.environ.get('OAUTH2_CLIENT_SECRET')
OAUTH2_REDIRECT_URI = os.environ.get('OAUTH2_REDIRECT_URI',
                                     'http://localhost:5000/confirm_login')
API_BASE_URL = os.environ.get('API_BASE_URL', 'https://discordapp.com/api')
AUTHORIZATION_BASE_URL = API_BASE_URL + '/oauth2/authorize'
AVATAR_BASE_URL = "https://cdn.discordapp.com/avatars/"
ICON_BASE_URL = "https://cdn.discordapp.com/icons/"
DEFAULT_AVATAR = "https://discordapp.com/assets/1cbd08c76f8af6dddce02c5138971129.png"
DOMAIN = os.environ.get('VIRTUAL_HOST', 'localhost:5000')
TOKEN_URL = API_BASE_URL + '/oauth2/token'
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
headers = {"Authorization": os.environ.get("NUREVAM_TOKEN")}
Exemple #12
0
from oauth2client.service_account import ServiceAccountCredentials
from pprint import pprint
from osuapi import OsuApi, ReqConnector
from PIL import Image, ImageFont, ImageDraw
from datetime import datetime, timezone
from discord.ext import commands, tasks
import credentials

claim_reset_time = 1615139154
TestKey = credentials.TestKey
liveKey = credentials.liveKey



# osu api key
osuapi = OsuApi(credentials.osu, connector=ReqConnector())

# Google api scope
scope = ["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets', 'https://www.googleapis.com/auth/drive.file', 'https://www.googleapis.com/auth/drive']

# Google api credentials
creds = ServiceAccountCredentials.from_json_keyfile_name("credentials.json", scope)

# Google sheets client
client = gspread.authorize(creds)


# Get the different sheets
spreadsheet = client.open("OsuTowerDB")
p_sheet = spreadsheet.get_worksheet(0)
c_sheet = spreadsheet.get_worksheet(1)
Exemple #13
0
import discord, random, os, string, requests
from discord.ext import commands
from discord.ext.commands import Bot

from osuapi import OsuApi, ReqConnector

osu_key = 'OSU_API_KEY_GOES_HERE'
bot_key = 'DISCORD_BOT_KEY_GOES_HERE'

api = OsuApi(osu_key, connector=ReqConnector())
bot = commands.Bot(command_prefix='dosu ')

# If you're going to use the emojis that were pre-assigned to this bot, DM @boop#1692 to get you bot added to the server.
# Also, A little credit pls <3


def changeToEmoji(letter):
    value = ''
    if letter == "A":
        value = "<:A_:463922386647908382>"
    elif letter == "S":
        value = '<:S_:463922496081625100>'
    elif letter == "SH":
        value = "<:S_:463922547382288385>"
    elif letter == "X":
        value = "<:SS:463922656668811265>"
    elif letter == "XH":
        value = "<:SS:463922701925613569>"
    elif letter == "B":
        value = "<:B_:464028170434248705>"
    elif letter == 'C':
Exemple #14
0
import re
import pyoppai
import constants
import recommendation
import update_stats
from datetime import datetime
import requests
from osuapi import OsuMode, BeatmapStatus, OsuApi, ReqConnector
from userlink_key import userlink

client = commands.Bot(command_prefix=commands.when_mentioned_or(
    constants.Settings.commandPrefix))
client.remove_command("help")
commandPrefix = constants.Settings.commandPrefix

api = OsuApi(constants.Api.osuApiKey, connector=ReqConnector())
LogFile = open(constants.Paths.logsFile, "a")

mainChannel = None
logsChannel = None
botOwner = None
Refresh = True
databasePath = constants.Paths.beatmapDatabase

conn = sqlite3.connect(constants.Paths.beatmapDatabase)
cursor = conn.cursor()

userlink = userlink(conn)


def return_user_rank(discordId):
Exemple #15
0
data_info.OAUTH2_CLIENT_ID = secret['OAUTH2_CLIENT_ID']
data_info.OAUTH2_CLIENT_SECRET = secret['OAUTH2_CLIENT_SECRET']
data_info.OAUTH2_REDIRECT_URI = secret.get('OAUTH2_REDIRECT_URI', 'http://localhost:5000/confirm_login')
data_info.API_BASE_URL = 'https://discordapp.com/api'
data_info.AUTHORIZATION_BASE_URL = data_info.API_BASE_URL + '/oauth2/authorize'
data_info.AVATAR_BASE_URL = "https://cdn.discordapp.com/avatars/"
data_info.ICON_BASE_URL = "https://cdn.discordapp.com/icons/"
data_info.DEFAULT_AVATAR = "https://discordapp.com/assets/1cbd08c76f8af6dddce02c5138971129.png"
data_info.DOMAIN = secret.get('VIRTUAL_HOST', 'localhost:5000')
data_info.TOKEN_URL = data_info.API_BASE_URL + '/oauth2/token'
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
data_info.headers = {"Authorization": "Bot " + secret["nurevam_token"]}
data_info.anilist_token = secret["anilist_token"]
data_info.anilist_id = secret["anilist_id"]
utils.data_info = data_info
osu_api = OsuApi(secret["osu"], connector=ReqConnector())

files_cogs = db.smembers("Website:Cogs")
blueprint_lib = {}

data_info.last_path = None  #getting last path so we can redirect it easily after login.
#loading cogs within dirty way, so I can test other files without need to edit this (when push to server)
for x in files_cogs:
    lib = importlib.import_module("cogs.{}".format(x))
    blueprint_lib[x] = lib
    app.register_blueprint(lib.blueprint, url_prefix="/"+x)
    lib.db = app.db
app.blueprint_lib = blueprint_lib
log.info("Loading done, {}".format(blueprint_lib.keys()))

lib = importlib.import_module("non-cogs.profile")
Exemple #16
0
 def __init__(self, client):
     self.client = client
     self.database = self.client.database
     self.api = OsuApi(self.database.get_osu_api_key(),
                       connector=ReqConnector())
from osuapi import OsuApi, ReqConnector, enums
import aiohttp, asyncio, sys, os, datetime, pprint, shelve
from threading import Lock
import OSDLBot_storage
api = OsuApi(os.environ.get('OSU_API_KEY'), connector=ReqConnector())
lock = Lock()


class MatchNotFoundError(Exception):
    pass


class PlayerNotFound(Exception):
    pass


class Map():
    def __init__(self, map_id):
        self.map = api.get_beatmaps(beatmap_id=map_id)[0]
        self.id = self.map.beatmap_id
        self.title = self.map.title


class Game():
    def __init__(self, game_api):
        self.is_v2 = game_api.scoring_type == enums.ScoringType.score_v2
        self.map = Map(game_api.beatmap_id)
        self.mods = game_api.mods

        #init player scores dict {Player: score}
        self.player_scores = {}
Exemple #18
0
load_dotenv()
REDKEY = str(os.getenv('REDKEY'))
REDSEC = str(os.getenv('REDSEC'))
REDPASS = str(os.getenv('REDPASS'))
OSUKEY = str(os.getenv('OSUKEY'))
DISCKEY = str(os.getenv('DISCKEY'))
GIFKEY = str(os.getenv('GIFKEY'))

reddit = praw.Reddit(client_id=REDKEY,
                     client_secret=REDSEC,
                     username='******',
                     password=REDPASS,
                     user_agent='disc')

api = OsuApi(OSUKEY, connector=ReqConnector())
x = '.'
client = commands.Bot(command_prefix=x)
client.remove_command('help')


@client.event
async def on_ready():
    await client.change_presence(status=discord.Status.do_not_disturb,
                                 activity=discord.Game('.help for commands!'))
    print("WE live boys can i get a pogU in the chat")


@client.command()
async def help(ctx):
    await ctx.send(f"""