コード例 #1
0
ファイル: misc.py プロジェクト: PotatoTheTurtle/DiscordBot
    async def server(self, ctx: commands.Context):
        """
        :return: max 2000 characters for an embedded message (that is kinda gay and fagish)
        """
        ip = basewrapper.Base().get_config_vars("GMOD_ADDRESS")
        port = basewrapper.Base().get_config_vars("GMOD_PORT")
        url = basewrapper.Base().get_config_vars("GMOD_URL")
        address = (ip, int(port))
        info = None
        try:
            try:
                with valve.source.a2s.ServerQuerier(address) as server:
                    info = server.info()

            except valve.source.NoResponseError:
                print("Master server request timed out!")

            embed = discord.Embed(title=f'{info.values["server_name"]}')
            embed.add_field(
                name='Players',
                value=
                f'{info.values["player_count"]} / {info.values["max_players"]}',
                inline=True)
            embed.add_field(name='Gamemode',
                            value=f'{info.values["game"]}',
                            inline=True)
            embed.add_field(name='Map',
                            value=f'{info.values["map"]}',
                            inline=True)
            embed.set_footer(text=f"Join server! {url}")
            await self.client.say(embed=embed)
        except:
            await self.client.say(
                f"{ctx.message.author.mention} Server either down or restarting. Please try again later."
            )
コード例 #2
0
ファイル: spotify.py プロジェクト: PotatoTheTurtle/DiscordBot
    async def setplaylist(self, ctx: commands.Context, *, msg: str):
        """
            Set your playlist ID
        """

        data = basewrapper.Base().jsondata(ctx.message.author, msg)
        jl = basewrapper.Json().json_load(JSON_FILE, "r")

        for j in jl:
            author = str(ctx.message.author)
            if j[author]["name"] == author:
                basewrapper.Base().warning_logger(
                    f"User data already exists: {j}")
                j[author]["playlist_link"] = msg
                basewrapper.Base().info_logger(
                    f"{self.client.user.id} - Playlist set!")
                await self.client.say(
                    f"{ctx.message.author.mention} Playlist set!")
                return

        jl.append(data)

        basewrapper.Json().json_write(JSON_FILE, "w+", jl)
        basewrapper.Base().info_logger(
            f"{self.client.user.id} - Playlist set!")
        await self.client.say(f"{ctx.message.author.mention} Playlist set!")
コード例 #3
0
 def __init__(self, client: commands.Bot):
     self.client = client
     self.c_reddit = praw.Reddit(
         client_id=basewrapper.Base().get_config_vars("R_C_ID"),
         client_secret=basewrapper.Base().get_config_vars("R_C_S"),
         password=basewrapper.Base().get_config_vars("R_PASSWORD"),
         user_agent=basewrapper.Base().get_config_vars("R_USERAGENT"),
         username=basewrapper.Base().get_config_vars("R_USERNAME"))
コード例 #4
0
ファイル: misc.py プロジェクト: PotatoTheTurtle/DiscordBot
    def steamcommuinityid(self, name):
        steam_api = basewrapper.Base().get_config_vars("steamapi")
        url = r"http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/"
        payload = {"key": steam_api, "vanityurl": name}

        r = requests.get(url, params=payload)
        steam_comunity_id = r.json()["response"]["steamid"]
        basewrapper.Base().info_logger(steam_comunity_id)
        return steam_comunity_id
コード例 #5
0
 async def logchannel(self, ctx, channel: discord.TextChannel):
     await Storage(str(ctx.guild.id)).set("log_channel_id", channel.id)
     basewrapper.Base().info_logger(
         f"{ctx.message.author} - Set log channel")
     await ctx.send(f"{ctx.message.author.mention} Channel set!")
     channel = self.client.get_channel(int(channel.id))
     await channel.send("This is now the log channel!")
コード例 #6
0
async def on_message(message):
    if message.author == client.user:
        return

    #if message.content.startswith(f"-convo"):
            #results = await client.

    if "f**k" in message.content.lower():
        """
            Idea by Nickishero
        """
        await client.send_message(message.channel, f"{message.author.mention} This is a christian server!")
        return

    if "scuffed" in message.content.lower():
        await client.delete_message(message)
        await client.send_message(message.channel, f"{message.author.mention} Scuffed networks is fake and gay!")
        return

    if r"https://discord.gg/" in message.content.lower():
        await client.delete_message(message)
        await client.send_message(message.channel, f"{message.author.mention} No advertizing other discord servers! (If you belive this message is an error, then contact PotatoTurtle#1337)")
        return

    if r"https://discord" in message.content.lower():
        await client.delete_message(message)
        await client.send_message(message.channel, f"{message.author.mention} No advertizing other discord servers! (If you belive this message is an error, then contact PotatoTurtle#1337)")
        return

    if r"discord.gg" in message.content.lower():
        await client.delete_message(message)
        await client.send_message(message.channel, f"{message.author.mention} No advertizing other discord servers! (If you belive this message is an error, then contact PotatoTurtle#1337)")
        return


    if message.content.startswith(f"<@{client.user.id}>"):
        basewrapper.Base().info_logger(message.content)
        results = await client.clever_response(message.content[22:])
        await client.send_message(message.channel, f"{message.author.mention} {results}")
        basewrapper.Base().info_logger("Cleverbot: " + results)
        return

    await client.process_commands(message)
コード例 #7
0
    async def reddit(self, ctx: commands.Context, *, subreddit: str):
        reddit_posts = []
        for post in self.c_reddit.subreddit(subreddit).hot(limit=45):
            if post.url.__contains__(".png" or ".jpg" or ".gifv" or ".gif"):
                reddit_posts.append(post.url)

        basewrapper.Base().info_logger(f"Get Reddit post: {subreddit}")
        await self.client.say(
            f"{ctx.message.author.mention} Random post from r/{subreddit}: {random.choice(reddit_posts)}"
        )
コード例 #8
0
ファイル: misc.py プロジェクト: PotatoTheTurtle/DiscordBot
 async def suggestion(self, ctx: commands.Context, *, suggestion: str):
     try:
         basewrapper.Database().write_suggestion(
             f"{ctx.message.author}: {suggestion}")
         await self.client.say(
             f"{ctx.message.author.mention} Thanks for the suggestion! :3")
     except Exception as e:
         basewrapper.Base().info_logger(f"Error: {e}")
         await self.client.say(
             f"{ctx.message.author.mention} Problem occured while adding suggestion, please try again later."
         )
コード例 #9
0
ファイル: misc.py プロジェクト: PotatoTheTurtle/DiscordBot
    async def steam(self, ctx: commands.Context, *, url):
        try:
            name = url.content[30:]
            steam_community_id = self.steamcommuinityid(name)
            steamdata = self.steamdata(steam_community_id)

            basewrapper.Base().info_logger(f"Searched for {name} steam info.")
            await self.client.say(
                f"{ctx.message.author.mention} Steam info for {name}: \n"
                f"```Steam playername: {steamdata['profile']['playername']} \n"
                f"Steam Profile detailed: {steamdata['profile']['steamidurl']} \n"
                f"Steam Profile: https://steamcommunity.com/id/{name} \n"
                f"SteamID: {steamdata['profile']['steamid']} \n"
                f"SteamID3: {steamdata['profile']['steam3']} \n"
                f"Bans: Vac Ban {self.value_converter_decorator(steamdata['profile_status']['vac'], 'Yes', 'No')} - Trade Ban {self.value_converter_decorator(steamdata['profile_status']['tradeban'], 'Yes', 'No')} - Community Ban {self.value_converter_decorator(steamdata['profile_status']['communityban'], 'Yes', 'No')}```"
            )

        except Exception as e:
            await self.client.say(
                f"{ctx.message.author.mention} No account found!")
            basewrapper.Base().info_logger(
                f"Error found, possibly no account found:  {e}")
コード例 #10
0
ファイル: misc.py プロジェクト: PotatoTheTurtle/DiscordBot
    def steamdata(self, steam_comunity_id):
        url = r"https://api.steamid.uk/request.php"
        steam_id = basewrapper.Base().get_config_vars("steamid")
        payload = {
            "api": steam_id,
            "player": steam_comunity_id,
            "request": 36,
            "format": "json"
        }

        r = requests.get(url, params=payload)
        steamdata = r.json()
        return steamdata
コード例 #11
0
    async def clear(self, ctx, *, number):
        number = int(
            number
        ) + 2  # Converting the amount of messages to delete to an integer

        loading_message = await ctx.send(
            f"<a:load:730508658982780968> Deleting {number - 2} messages.")

        def is_loading_message(obj):
            return loading_message.id != obj.id

        await ctx.channel.purge(limit=number, check=is_loading_message)

        await loading_message.edit(
            content=f":white_check_mark: {number -2} messages removed.")
        await loading_message.delete(delay=2.3)
        basewrapper.Base().info_logger(f"Cleared {number - 2} messages")
コード例 #12
0
ファイル: misc.py プロジェクト: PotatoTheTurtle/DiscordBot
    async def clear(self, ctx: commands.Context, *, number):
        number = int(
            number
        ) + 1  # Converting the amount of messages to delete to an integer
        messages = []
        async for x in self.client.logs_from(ctx.message.channel,
                                             limit=number):
            messages.append(x)

        msg = await self.client.say(
            f"<a:loadring:550693379567255552> Deleting {number - 1} messages.")

        for x in messages:
            await self.client.delete_message(x)

        await self.client.edit_message(
            msg, f":white_check_mark: {number -1} messages removed.")
        asyncio.sleep(2.3)
        await self.client.delete_message(msg)
        basewrapper.Base().info_logger(f"Cleared {number - 1} messages")
コード例 #13
0
ファイル: misc.py プロジェクト: PotatoTheTurtle/DiscordBot
 async def ping(self, ctx: commands.Context):
     basewrapper.Base().info_logger(f"{ctx.message.author} - Ping!")
     await self.client.say(f"{ctx.message.author.mention} Pong!")
コード例 #14
0
 async def ping(self, ctx):
     basewrapper.Base().info_logger(f"{ctx.message.author} - Ping!")
     await ctx.send(f"{ctx.message.author.mention} Pong!")
コード例 #15
0
 def __init__(self, client: commands.Bot):
     self.clever = CleverWrap(basewrapper.Base().get_config_vars("CLEVER"))
     self.client = client
     client.clever_response = self.clever_response
コード例 #16
0
ファイル: spotify.py プロジェクト: PotatoTheTurtle/DiscordBot
from discord.ext import commands
from commands import basewrapper
import spotipy
from spotipy.oauth2 import SpotifyClientCredentials
import json
import random

JSON_FILE = basewrapper.Base().get_config_vars("JSON_FILE")
client_secret = basewrapper.Base().get_config_vars("S_C_SECRET")
client_id = basewrapper.Base().get_config_vars("S_C_ID")


class Spotify(object):
    def __init__(self, client: commands.Bot):
        self.client = client

    def spotify_playlists(self, name):
        client_credentials_manager = SpotifyClientCredentials(
            client_id=client_id, client_secret=client_secret)
        sp = spotipy.Spotify(
            client_credentials_manager=client_credentials_manager)
        user = '******'
        playlist_id = self.get_playlist_id(name, JSON_FILE, "r")
        playlists = sp.user_playlist_tracks(user, playlist_id=playlist_id)
        return playlists

    def spotify_playlist_random_song(self, name):
        playlists = self.spotify_playlists(name)

        songs = {}
        for song in playlists["tracks"]["items"]: