コード例 #1
0
ファイル: txlist.py プロジェクト: M1keH/python-tipbot-v2
    def __init__(self, bot):
        self.bot = bot
        self.rpc = rpc.Rpc()

        # parse the config file
        config = parsing.parse_json('config.json')
        self.currency_symbol = config["currency_symbol"]
        self.stakeflake = config["stake_bal"]
        self.treasurer = config["treasurer"]
        self.donate = config["donation"]
        self.game_id = config["game_bal"]
        self.coin_name = config["currency_name"]
        self.bot_name = config["description"]

        # parse the embed section of the config file
        embed_config = parsing.parse_json('config.json')["embed_msg"]
        self.thumb_embed = embed_config["thumb_embed_url"]
        self.footer_text = embed_config["footer_msg_text"]
        self.embed_color = int(embed_config["color"], 16)

        # parse the getstakingstatus from rpc wallet
        stake_info = self.rpc.getstakingstatus()
        self.is_enabled = stake_info["enabled"]
        self.staking_status = stake_info["staking"]
        self.have_errors = stake_info["errors"]
        self.difficulty = stake_info["difficulty"]
        self.weight = stake_info["weight"]
        self.net_staking_weight = stake_info["netstakeweight"]
        self.expected_time = stake_info["expectedtime"]
コード例 #2
0
ファイル: tip.py プロジェクト: sotblad/Curium-Discord-Tips
    async def tip(self, ctx, user: discord.Member, amount: float):
        """Tip a user coins"""
        snowflake = ctx.message.author.id
        self.tipfee = parsing.parse_json('config.json')["tipfee"]
        self.owner = parsing.parse_json('config.json')["owner"]
        tip_user = user.id
        if snowflake == tip_user:
            await self.bot.say(
                "{} **:warning:You cannot tip yourself!:warning:**".format(
                    ctx.message.author.mention))
            return

        if amount <= 0.0:
            await self.bot.say(
                "{} **:warning:You cannot tip <= 0!:warning:**".format(
                    ctx.message.author.mention))
            return

        mysql.check_for_user(snowflake)
        mysql.check_for_user(tip_user)

        balance = mysql.get_balance(snowflake, check_update=True)

        if (float(balance) + float(self.tipfee)) < amount:
            await self.bot.say(
                "{} **:warning:You cannot tip more CRU than you have!:warning:**"
                .format(ctx.message.author.mention))
        else:
            mysql.add_tip(snowflake, tip_user, amount)
            mysql.add_tip(snowflake, self.owner, self.tipfee)
            await self.bot.say(
                "{} **Tipped {} {} CRU! :money_with_wings:**".format(
                    ctx.message.author.mention, user.mention, str(amount)))
コード例 #3
0
 def __init__(self, bot):
     self.bot = bot
     config = parsing.parse_json('config.json')
     self.coin_name = config["currency_name"]
     self.bot_name = config["description"]
     embed_config = parsing.parse_json('config.json')["embed_msg"]
     self.thumb_embed = embed_config["thumb_embed_url"]
     self.footer_text = embed_config["footer_msg_text"]
     self.embed_color = int(embed_config["color"], 16)
コード例 #4
0
 def __init__(self):
     config = parsing.parse_json('config.json')["mysql"]
     self.__host = config["db_host"]
     self.__port = int(config.get("db_port", 3306))
     self.__db_user = config["db_user"]
     self.__db_pass = config["db_pass"]
     self.__db = config["db"]
     self.__connected = 1
     self.__setup_connection()
     self.txfee = parsing.parse_json('config.json')["txfee"]
コード例 #5
0
ファイル: tip.py プロジェクト: M1keH/python-tipbot-v2
    def __init__(self, bot):
        self.bot = bot
        config = parsing.parse_json('config.json')
        self.currency_symbol = config["currency_symbol"]
        self.donation_id = config["donation"]

        #parse the embed section of the config file
        embed_config = parsing.parse_json('config.json')["embed_msg"]
        self.thumb_embed = embed_config["thumb_embed_url"]
        self.footer_text = embed_config["footer_msg_text"]
        self.embed_color = int(embed_config["color"], 16)
コード例 #6
0
 def __init__(self, bot):
     self.bot = bot
     self.rpc = rpc.Rpc()
     config = parsing.parse_json('config.json')
     self.currency_symbol = config["currency_symbol"]
     self.stake_id = config["stake_bal"]
     self.coin_name = config["currency_name"]
     self.bot_name = config["description"]
     # parse the embed section of the config file
     embed_config = parsing.parse_json('config.json')["embed_msg"]
     self.thumb_embed = embed_config["thumb_embed_url"]
     self.footer_text = embed_config["footer_msg_text"]
     self.embed_color = int(embed_config["color"], 16)
コード例 #7
0
ファイル: mysql_module.py プロジェクト: Nadro-J/tipbot-v2
 def __init__(self):
     config = parsing.parse_json(
         f'{HOMEPATH}/tipbot-v2/config.json')["mysql"]
     self.__host = config["db_host"]
     self.__port = int(config.get("db_port", 3306))
     self.__db_user = config["db_user"]
     self.__db_pass = config["db_pass"]
     self.__db = config["db"]
     self.__connected = 1
     self.__setup_connection()
     self.txfee = parsing.parse_json(
         f'{HOMEPATH}/tipbot-v2/config.json')["txfee"]
     self.stakeflake = parsing.parse_json(
         f'{HOMEPATH}/tipbot-v2/config.json')["stake_bal"]
コード例 #8
0
ファイル: stats.py プロジェクト: cryptobot123/Helix-tip-bot
    async def stats(self, ctx, amount=1):
        """
        Show stats about HLIX
        """
        channel_name = ctx.message.channel.name
        allowed_channels = parsing.parse_json('config.json')['command_channels'][ctx.command.name]
        if channel_name not in allowed_channels:
            return

        headers={"user-agent" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36"}
        try:
            async with ClientSession() as session:
                async with session.get("", headers=headers) as response:
                    responseRaw = await response.read()
                    priceData = json.loads(responseRaw)
                    for item in priceData:
                        embed= discord.Embed(colour=0x00FF00)
                        embed.set_author(name='HLIX Information', icon_url="https://i.imgur.com/ZnwpZ3r.png")
                        embed.add_field(name="Price (USD)", value="${}".format(item['price_usd:']))
                        embed.add_field(name="Price (BTC)", value="{} BTC".format(item['price_btc:']))
                        embed.add_field(name='\u200b',value='\u200b')
                        embed.add_field(name="Volume (USD)", value="${}".format(item['24h_volume_usd:']))
                        embed.add_field(name="Market Cap", value="${}".format(item['market_cap_usd:']))
                        embed.add_field(name='\u200b',value='\u200b')
                        embed.add_field(name="% 1h", value="{}%".format(item['percent_change_1h:']))
                        embed.add_field(name="% 24h", value="{}%".format(item['percent_change_24h:']))
                        embed.add_field(name="% 7d", value="{}%".format(item['percent_change_7d:']))
                        embed.add_field(name="Circulating Supply", value="{} HLIX".format(item['available_supply:']))
                        embed.add_field(name="Total Supply", value="{} HLIX".format(item['total_supply:']))
                        embed.add_field(name="Maximum Supply", value="500,000,000 HLIX")
                        embed.set_footer(text="", icon_url="https://i.imgur.com/ZnwpZ3r.png")
                    await self.bot.say(embed=embed)
        except:
            await self.bot.say(":warning: Error fetching prices!")
コード例 #9
0
ファイル: tip.py プロジェクト: thebeardbe/discord-bot
    async def tip(self, ctx, user:discord.Member, amount:float):
        """Tip a user coins"""
        channel_name = ctx.message.channel.name
        allowed_channels = parsing.parse_json('config.json')['command_channels'][ctx.command.name]
        if channel_name not in allowed_channels:
            return

        snowflake = ctx.message.author.id

        tip_user = user.id
        if snowflake == tip_user:
            await self.bot.say("{} **:warning:You cannot tip yourself!:warning:**".format(ctx.message.author.mention))
            return

        if amount <= 0.0:
            await self.bot.say("{} **:warning:You cannot tip <= 0!:warning:**".format(ctx.message.author.mention))
            return

        mysql.check_for_user(snowflake)
        mysql.check_for_user(tip_user)

        balance = mysql.get_balance(snowflake, check_update=True)

        if float(balance) < amount:
            await self.bot.say("{} **:warning:You cannot tip more ORE than you have!:warning:**".format(ctx.message.author.mention))
        else:
            mysql.add_tip(snowflake, tip_user, amount)
            await self.bot.say("{} **Tipped {} {} ORE! <:blueore:424722137190760448>**".format(ctx.message.author.mention, user.mention, str(amount)))
コード例 #10
0
 def __init__(self):
     self.txid = txid
     self.config = parsing.parse_json('walletnotify/walletnotify.json')
     ##MySQL
     self.config_mysql = self.config["mysql"]
     self.host = self.config_mysql["db_host"]
     try:
         self.port = int(self.config_mysql["db_port"])
     except KeyError:
         self.port = 3306
     self.db_user = self.config_mysql["db_user"]
     self.db_pass = self.config_mysql["db_pass"]
     self.db = self.config_mysql["db"]
     self.connection = pymysql.connect(host=self.host,
                                       port=self.port,
                                       user=self.db_user,
                                       password=self.db_pass,
                                       db=self.db)
     self.cursor = self.connection.cursor(pymysql.cursors.DictCursor)
     ##RPC
     self.config_rpc = self.config["rpc"]
     self.rpc_host = self.config_rpc["rpc_host"]
     self.rpc_port = self.config_rpc["rpc_port"]
     self.rpc_user = self.config_rpc["rpc_user"]
     self.rpc_pass = self.config_rpc["rpc_pass"]
     self.serverURL = 'http://' + self.rpc_host + ':' + self.rpc_port
     self.headers = {'content-type': 'application/json'}
コード例 #11
0
    def __init__(self, bot):
        self.bot = bot
        config = parsing.parse_json('config.json')
        self.currency_symbol = config["currency_symbol"]
        self.stakeflake = config["stake_bal"]
        self.treasurer = config["treasurer"]
        self.donate = config["donation"]
        self.game_id = config["game_bal"]
        self.coin_name = config["currency_name"]
        self.bot_name = config["description"]
        self.explorer = config["explorer_url"]

        # parse the embed section of the config file
        embed_config = parsing.parse_json('config.json')["embed_msg"]
        self.thumb_embed = embed_config["thumb_embed_url"]
        self.footer_text = embed_config["footer_msg_text"]
        self.embed_color = int(embed_config["color"], 16)
コード例 #12
0
 def __init__(self):
     config = parsing.parse_json('config.json')["rpc"]
     self.rpc_host = config["rpc_host"]
     self.rpc_port = config["rpc_port"]
     self.rpc_user = config["rpc_user"]
     self.rpc_pass = config["rpc_pass"]
     self.serverURL = 'http://' + self.rpc_host + ':' + self.rpc_port
     self.headers = {'content-type': 'application/json'}
コード例 #13
0
ファイル: help.py プロジェクト: Nadro-J/tipbot-v2
 def __init__(self, bot: discord.ext.commands.Bot):
     self.bot = bot        
     bot.remove_command('help')
     config = parsing.parse_json('config.json')        
     self.prefix = config["prefix"]
     self.bot_descr = config["description"]
     self.color = 0x1e7180
     self.error = 0xcc0000
コード例 #14
0
ファイル: game.py プロジェクト: M1keH/python-tipbot-v2
 def __init__(self, bot):
     self.bot = bot
     config = parsing.parse_json('config.json')         
     self.currency_symbol = config["currency_symbol"]
     self.donation_id = config["donation"]
     self.game_id = config["game_bal"]
     self.stake_id = config["stake_bal"]
     self.treasury_id = config["treasurer"]
コード例 #15
0
 def __init__(self, bot):
     self.bot = bot
     soak_config = parsing.parse_json('config.json')['soak']
     config = parsing.parse_json('config.json')
     '''
     soak_max_recipients sets the max recipients for a soak. chosen randomly.
     soak_min_received sets the minimum possible soak received for a user.
     The number of soak recipients will be adjusted to fit these constraints
     if enabled via use_max_recipients and use_min_received
     '''
     self.soak_max_recipients = soak_config["soak_max_recipients"]
     self.use_max_recipients = soak_config["use_max_recipients"]
     self.soak_min_received = soak_config["soak_min_received"]
     self.use_min_received = soak_config["use_min_received"]
     self.soak_minimum = soak_config['min_amount']
     self.currency_symbol = config["currency_symbol"]
     self.prefix = config["prefix"]
コード例 #16
0
    def __init__(self, bot):
        self.bot = bot
        config = parsing.parse_json('config.json')
        self.is_treasurer = config["treasurer"]
        self.explorer = config["explorer_url"]
        self.currency_symbol = config["currency_symbol"]
        self.coin_name = config["currency_name"]
        self.withdrawfee = config["withdraw_fee"]
        self.withdrawmax = config["withdraw_max"]
        self.minwithdraw = config["min_withdrawal"]
        self.bot_name = config["description"]

        #parse the embed section of the config file
        embed_config = parsing.parse_json('config.json')["embed_msg"]
        self.thumb_embed = embed_config["thumb_embed_url"]
        self.footer_text = embed_config["footer_msg_text"]
        self.embed_color = int(embed_config["color"], 16)
コード例 #17
0
    async def withdraw(self, ctx, address: str, amount: float):
        """Withdraw coins from your account to any Helix address"""
        snowflake = ctx.message.author.id
        channel_name = ctx.message.channel.name
        allowed_channels = parsing.parse_json(
            'config.json')['command_channels'][ctx.command.name]
        if channel_name not in allowed_channels:
            return

        if amount <= 0.0:
            await self.bot.say(
                "{} **:warning: You cannot withdraw <= 0! :warning:**".format(
                    ctx.message.author.mention))
            return

        abs_amount = abs(amount)
        if math.log10(abs_amount) > 8:
            await self.bot.say(":warning: **Invalid amount!** :warning:")
            return

        mysql.check_for_user(snowflake)

        conf = rpc.validateaddress(address)
        if not conf["isvalid"]:
            await self.bot.say(
                "{} **:warning: Invalid address! :warning:**".format(
                    ctx.message.author.mention))
            return

        ownedByBot = False
        for address_info in rpc.listreceivedbyaddess(0, True):
            if address_info["address"] == address:
                ownedByBot = True
                break

        if ownedByBot:
            await self.bot.say(
                "{} **:warning: You cannot withdraw to an address owned by this bot! :warning:** Please use tip instead!"
                .format(ctx.message.author.mention))
            return

        balance = mysql.get_balance(snowflake, check_update=True)
        if float(balance) < amount:
            await self.bot.say(
                "{} **:warning: You cannot withdraw more money than you have! :warning:**"
                .format(ctx.message.author.mention))
            return

        txid = mysql.create_withdrawal(snowflake, address, amount)
        if txid is None:
            await self.bot.say(
                "{} your withdraw failed despit having the necessary balance! Please contact the support team"
                .format(ctx.message.author.mention))
        else:
            await self.bot.say(
                "{} **Withdrew {} HLIX!** (http://explorer.helix-crypto.com/tx/{})"
                .format(ctx.message.author.mention, str(amount), txid))
コード例 #18
0
        def update_last_msg(self, user, last_msg_time, content):
            rain_config = parsing.parse_json('config.json')['rain']
            min_num_words_required = rain_config["min_num_words_required"]
            delay_between_messages_required_s = rain_config[
                "delay_between_messages_required_s"]
            user_activity_required_m = rain_config["user_activity_required_m"]

            content_adjusted = helpers.unicode_strip(content)
            words = content_adjusted.split(' ')
            adjusted_count = 0
            prev_len = 0
            for word in words:
                word = word.strip()
                cur_len = len(word)
                if cur_len > 0:
                    if word.startswith(":") and word.endswith(":"):
                        continue
                    if prev_len == 0:
                        prev_len = cur_len
                        adjusted_count += 1
                    else:
                        res = prev_len % cur_len
                        prev_len = cur_len
                        if res != 0:
                            adjusted_count += 1
                if adjusted_count >= min_num_words_required:
                    break

            if last_msg_time is None:
                user["rain_msg_count"] = 0
            else:
                if last_msg_time >= (user_activity_required_m * 60):
                    user["rain_msg_count"] = 0

            is_accepted_delay_between_messages = False
            if user["rain_last_msg_time"] is None:
                is_accepted_delay_between_messages = True
            elif (datetime.datetime.utcnow() - user["rain_last_msg_time"]
                  ).total_seconds() > delay_between_messages_required_s:
                is_accepted_delay_between_messages = True

            if adjusted_count >= min_num_words_required and is_accepted_delay_between_messages:
                user["rain_msg_count"] += 1
                user["rain_last_msg_time"] = datetime.datetime.utcnow()
            user["last_msg_time"] = datetime.datetime.utcnow()

            cursor = self.__setup_cursor(pymysql.cursors.DictCursor)
            to_exec = "UPDATE users SET last_msg_time = %s, rain_last_msg_time = %s, rain_msg_count = %s WHERE snowflake_pk = %s"
            cursor.execute(to_exec,
                           (user["last_msg_time"], user["rain_last_msg_time"],
                            user["rain_msg_count"], user["snowflake_pk"]))

            cursor.close()
            self.__connection.commit()
コード例 #19
0
 def __init__(self):
     config = parsing.parse_json('config.json')["mysql"]
     self.host = config["db_host"]
     try:
         self.port = int(config["db_port"])
     except KeyError:
         self.port = 3306
     self.db_user = config["db_user"]
     self.db_pass = config["db_pass"]
     self.db = config["db"]
     self.connected = 1
     self.my_connection()
コード例 #20
0
ファイル: deposit.py プロジェクト: thebeardbe/discord-bot
    async def deposit(self, ctx):
        """ Display my public wallet address to deposit funds  """
        channel_name = ctx.message.channel.name
        allowed_channels = parsing.parse_json('config.json')['command_channels'][ctx.command.name]
        if channel_name not in allowed_channels:
            return

        user = ctx.message.author
        # Check if user exists in db
        mysql.check_for_user(user.id)
        user_addy = mysql.get_address(user.id)
        await self.bot.say(user.mention + "'s Deposit Address: `" + str(user_addy) + "`" + "\n\nRemember to use !balance to check your balance and not an explorer. The address balance and your actual balance are not always the same!\n\n:warning: DISCLAIMER: This is BETA software! Do not send large amounts of ORE! The developers are not reliable for any lost ORE! :warning:")
コード例 #21
0
    async def invite(self, ctx):
        """
        Get the bot's invite link
        """
        channel_name = ctx.message.channel.name
        allowed_channels = parsing.parse_json(
            'config.json')['command_channels'][ctx.command.name]
        if channel_name not in allowed_channels:
            return

        await self.bot.say(
            ":tada: https://discordapp.com/oauth2/authorize?permissions=0&client_id={}&scope=bot"
            .format(self.bot.user.id))
コード例 #22
0
ファイル: rain.py プロジェクト: sotblad/Curium-Discord-Tips
 def __init__(self, bot):
     self.bot = bot
     rain_config = parsing.parse_json('config.json')['rain']
     '''
     rain_max_recipients sets the max recipients for a rain. chosen randomly.
     rain_min_received sets the minimum possible rain received for a user.
     The number of rain recipients will be adjusted to fit these constraints
     if enabled via use_max_recipients and use_min_received
     '''
     self.rain_max_recipients = rain_config["rain_max_recipients"]
     self.use_max_recipients = rain_config["use_max_recipients"]
     self.rain_min_received = rain_config["rain_min_received"]
     self.use_min_received = rain_config["use_min_received"]
コード例 #23
0
ファイル: wallet_info.py プロジェクト: Nadro-J/tipbot-v2
    def __init__(self, bot):
        self.bot = bot
        self.rpc = rpc.Rpc()

        config = parsing.parse_json('config.json')
        self.bot_name = config["description"]

        # Coin attributes (BitGreen/BITG)
        self.coin_name = config["currency_name"]
        self.currency_symbol = config["currency_symbol"]

        # Wallets
        self.treasurer = config["treasurer"]
        self.stake_bal = config["stake_bal"]
        self.donation = config["donation"]
        self.game_bal = config["game_bal"]
        self.airdrop = config["airdrop"]

        # Parse the embed section of the config file
        embed_config = parsing.parse_json('config.json')["embed_msg"]
        self.thumb_embed = embed_config["thumb_embed_url"]
        self.footer_text = embed_config["footer_msg_text"]
        self.embed_color = int(embed_config["color"], 16)
コード例 #24
0
    async def checksoak(self, ctx):
        """
        Checks if soak is available on the server
        """
        channel_name = ctx.message.channel.name
        allowed_channels = parsing.parse_json('config.json')['command_channels'][ctx.command.name]
        if channel_name not in allowed_channels:
            return

        result_set = mysql.check_soak(ctx.message.server)
        if result_set:
            await self.bot.say("Soaking is enabled! :white_check_mark:")
        else:
            await self.bot.say("Soaking is disabled! :no_entry_sign:")
コード例 #25
0
 def __init__(self):
     config = parsing.parse_json('config.json')["mysql"]
     self.__host = config["db_host"]
     self.__port = int(config.get("db_port", 3306))
     self.__db_user = config["db_user"]
     self.__db_pass = config["db_pass"]
     self.__db = config["db"]
     self.__connected = 1
     self.__setup_connection()
     self.txfee = parsing.parse_json('config.json')["txfee"]
     self.treasurer = parsing.parse_json('config.json')["treasurer"]
     self.stake_bal = parsing.parse_json('config.json')["stake_bal"]
     self.donation = parsing.parse_json('config.json')["donation"]
     self.game_bal = parsing.parse_json('config.json')["game_bal"]
     self.stake_pay = parsing.parse_json('config.json')["stake_pay"]
     self.MIN_CONFIRMATIONS_FOR_DEPOSIT = parsing.parse_json(
         'config.json')["MIN_CONFIRMATIONS_FOR_DEPOSIT"]
コード例 #26
0
ファイル: mysql_module.py プロジェクト: SHNICI/J-Discord
 def __init__(self):
     config = parsing.parse_json('config.json')["mysql"]
     self.host = config["db_host"]
     try:
         self.port = int(config["db_port"])
     except KeyError:
         self.port = 3306
     self.db_user = config["db_user"]
     self.db_pass = config["db_pass"]
     self.db = config["db"]
     self.connection = pymysql.connect(host=self.host,
                                       port=self.port,
                                       user=self.db_user,
                                       password=self.db_pass,
                                       db=self.db)
     self.cursor = self.connection.cursor(pymysql.cursors.DictCursor)
コード例 #27
0
    async def balance(self, ctx):
        """Display your balance"""
        channel_name = ctx.message.channel.name
        allowed_channels = parsing.parse_json('config.json')['command_channels'][ctx.command.name]
        if channel_name not in allowed_channels:
            return
        # Set important variables
        snowflake = ctx.message.author.id

        # Check if user exists in db
        mysql.check_for_user(snowflake)

        balance = mysql.get_balance(snowflake, check_update=True)
        balance_unconfirmed = mysql.get_balance(snowflake, check_unconfirmed = True)

        # Execute and return SQL Query
        await self.do_embed(ctx.message.author, balance, balance_unconfirmed)
コード例 #28
0
    async def soak_info(self, ctx):        
        """Display min soak amount and maximum soak recipients"""
        channel_name = ctx.message.channel.name
        allowed_channels = parsing.parse_json('config.json')['command_channels'][ctx.command.name]
        if channel_name not in allowed_channels:
            return

        if self.use_max_recipients:
            st_max_users = str(self.soak_max_recipients)
        else:
            st_max_users = "<disabled>"

        if self.use_min_received:
            st_min_received = str(self.soak_min_received)
        else:
            st_min_received = "<disabled>"
            
        await self.bot.say(":information_source: Soak info: max recipients {}, min amount receivable {} :information_source:".format(st_max_users, st_min_received))
コード例 #29
0
ファイル: mining.py プロジェクト: CryptoLover705/price-bot
    async def mining(self, ctx):
        """Show mining info"""
        channel_name = ctx.message.channel.name
        allowed_channels = parsing.parse_json('config.json')['command_channels'][ctx.command.name]
        if channel_name not in allowed_channels:
            return

        mining_info = self.rpc.getmininginfo()
        height = mining_info["blocks"]
        difficulty = mining_info["difficulty"]
        network_hs = mining_info["networkhashps"]
        network_Ghs = network_hs/1000000000
        
        embed= discord.Embed(colour=0x00FF00)
        embed.set_author(name='SCT Mining Information', icon_url="https://i.imgur.com/8tS9gkr.png")
        embed.add_field(name="Current Height", value='{}'.format(height))
        embed.add_field(name="Network Difficulty", value='{0:.2f}'.format(difficulty))
        embed.add_field(name="Network Hashrate", value='{0:.2f} GH/s'.format(network_Ghs))
        await self.bot.say(embed=embed)
コード例 #30
0
    async def help(self, ctx):
        """
        Display a useful list of commands
        """
        channel_name = ctx.message.channel.name
        allowed_channels = parsing.parse_json(
            'config.json')['command_channels'][ctx.command.name]
        if channel_name not in allowed_channels:
            return

        desc = ""
        for key in self.bot.commands.keys():
            command = self.bot.get_command(key)
            if command.hidden and not checks.is_owner(ctx):
                continue

            if command.aliases:
                desc += "`${}`".format(
                    command.name) + " - {}\nAliases: `{}`\n".format(
                        command.short_doc, ",".join(command.aliases))
                desc += "\n"

            elif command.short_doc:
                desc += "`${}`".format(command.name) + " - {}\n".format(
                    command.short_doc)
                desc += "\n"

            else:
                desc += "`${}`\n".format(command.name)
                desc += "\n"

        embed = discord.Embed(description=desc)
        embed.set_author(icon_url=self.bot.user.avatar_url,
                         name="SCT-Bot commands!")
        try:
            await self.bot.send_message(ctx.message.author, embed=embed)
            if ctx.message.server is not None:
                await self.bot.say(
                    "{}, I PMed you some helpful info! Make sure to double check that it is from me! :envelope:"
                    .format(ctx.message.author.mention))
        except discord.HTTPException:
            await self.bot.say(
                "I need the `Embed links` permission to send this!")