示例#1
0
 def __init__(self):
     config = common.getConfig()
     self.masterLogger = common.getMasterLog()
     self.r = praw.Reddit(client_id=config['REDDIT']['client.id'],
                          client_secret=config['REDDIT']['client.secret'],
                          user_agent=config['REDDIT']['user.agent'])
     self.steam = steam.Steam()
     self.ssf = SteamStoreFront()
示例#2
0
    async def server(self, ctx):
        # subcommand to get the server status
        embed = discord.Embed(title='Server Information')

        config = common.getConfig()

        url = f"https://cloud.mongodb.com/api/atlas/v1.0/groups/{config['DATABASE']['groupid']}/processes"

        res = requests.get(url,
                           auth=HTTPDigestAuth(
                               config['DATABASE']['publickey'],
                               config['DATABASE']['privatekey']))

        embed.add_field(name="Python Version",
                        value=platform.python_version(),
                        inline=False)
        embed.add_field(name="OS", value=platform.platform(), inline=False)

        embed.add_field(
            name="Server Uptime",
            value=
            f'{humanize.naturaldelta(datetime.now() - datetime.fromtimestamp(psutil.boot_time()))}',
            inline=False)
        embed.add_field(
            name="CPU",
            value=
            f'{psutil.cpu_percent()}% | Physical [{psutil.cpu_count(logical=False)}] | Logical [{psutil.cpu_count(logical=True)}]',
            inline=False)
        embed.add_field(
            name="RAM",
            value=
            f'{psutil.virtual_memory().percent}% | {round(psutil.virtual_memory().total / (1024.0 **3))} GB',
            inline=False)

        api_res = requests.get(config['COMMON']['api.url']).json()
        if api_res['status'] == 1:
            embed.add_field(name="API Server", value='online', inline=False)
        else:
            embed.add_field(name="API Server", value='offline', inline=False)

        if res.status_code != requests.codes.ok:
            embed.add_field(name="DB Hosts Status",
                            value=f"Down",
                            inline=False)
        else:
            res = res.json()
            string = f"{res['totalCount']} | ["
            temp = ""
            for process in res['results'][::-1]:
                temp = temp + f"{process['typeName'].replace('REPLICA_', '')} | "
            # remove "| "
            temp = temp[:-2]
            string = string + temp + ']'
            embed.add_field(name="DB Hosts Running",
                            value=string,
                            inline=False)

        await ctx.send(embed=embed)
示例#3
0
async def serverStatus(ctx):
    # api url to query data

    config = common.getConfig()

    url = 'https://api.steampowered.com/ICSGOServers_730/GetGameServersStatus/v1/?key=' + config[
        'STEAM']['API_KEY']

    # request the data
    res = requests.get(url).json()

    # getting selected data
    embed = discord.Embed(
        title="CSGO SERVER STATUS",
        # steam url's doesn't work
        #url="steam://rungameid/730",
        #description="[Run Game](steam://rungameid/730)"
    )

    #embed.set_image(url='http://media.steampowered.com/apps/csgo/blog/images/wallpaper_nologo.jpg')

    embed.add_field(
        name="Load",
        value=res['result']['datacenters']['India']['load'].title(),
        inline=True)
    embed.add_field(
        name="Online Players",
        value=f"{res['result']['matchmaking']['online_players']:,}",
        inline=True)
    embed.add_field(
        name="Online Servers",
        value=f"{res['result']['matchmaking']['online_servers']:,}",
        inline=True)
    embed.add_field(
        name="Players Searching",
        value=f"{res['result']['matchmaking']['searching_players']:,}",
        inline=True)
    embed.add_field(name="Average Search Time",
                    value=res['result']['matchmaking']['search_seconds_avg'],
                    inline=True)

    embed.set_footer(text=datetime.today().strftime("%Y-%m-%d %H:%M:%S"))

    await ctx.send(embed=embed)
示例#4
0
import discord
from discord.ext import commands
from cogs.helpers import steam, guild, gamedeals
from common import database, common

config = common.getConfig()
token = config['DISCORD']['token']

bot = commands.Bot(command_prefix=config['DISCORD']['prefix'])

formatter = commands.HelpCommand(show_check_failure=False)

modules_prod = [
    'cogs.status_setup', 'cogs.core_setup', 'cogs.moderation_setup',
    'cogs.csgo_setup', 'cogs.scrape_setup', 'cogs.reddit_setup',
    'cogs.services_setup', 'cogs.fun_setup', 'cogs.price_setup',
    'cogs.cleaner_setup', 'cogs.send_setup', 'cogs.roles_setup'
]

modules_dev = [
    'cogs.status_setup', 'cogs.core_setup', 'cogs.moderation_setup',
    'cogs.services_setup', 'cogs.roles_setup'
    'cogs.send_setup'
]


@bot.event
async def on_ready():
    # if env is not dev the load regular cogs
    if common.getEnvironment() != 'dev':
        db = database.Database()
parser = argparse.ArgumentParser(description='Edurep DB insert script')
parser.add_argument('-a', '--action', nargs=1, help='insert or delete', metavar='action', dest='action')
parser.add_argument('-c', '--config', nargs=1, help='config file', metavar='configfile', dest='configfile')
parser.add_argument('-i', '--identifier', nargs=1, help='record identifier', metavar='identifier', dest='identifier')
parser.add_argument('-p', '--path', nargs=1, help='record path', metavar='path', dest='path')

args = parser.parse_args()

action = args.action[0]
identifier = args.identifier[0]
path = args.path[0]

""" Validating input """
if args.configfile:
	configfile = args.configfile[0]
	if not os.path.isfile(configfile):
		parser.error('Invalid config file: ' + configfile)
else:
	configfile = "metadateerrobot.cfg"

if action != "insert" and action != "delete":
	parser.error('Action should be insert or delete: ' + action)

""" get config for source """
try:
	config = common.getConfig(configfile,"metadata")
except:
	parser.error('Invalid source: ' + source)

Update = metadata.UpdateMetadata(config,action,identifier,path)
示例#6
0
 def __init__(self):
     config = common.getConfig()
     self.r = praw.Reddit(client_id=config['REDDIT']['client.id'], client_secret=config['REDDIT']['client.secret'], user_agent=config['REDDIT']['user.agent'])
示例#7
0
    configfile = args.configfile[0]
    if not os.path.isfile(configfile):
        parser.error('Invalid config file: ' + configfile)
else:
    configfile = "metadateerrobot.cfg"

if args.part:
    part = args.part[0]

    if args.action:
        action = args.action[0]
    else:
        parser.error('Input a valid action')

    # get common config
    config = common.getConfig(configfile,'common')

    # get config for part
    try:
        config.update(common.getConfig(configfile,part))
    except:
        parser.error('Invalid part: ' + part)

    # load and start process class
    try:
        process = common.importFrom(part,'process')
        P = process.Process(config,action)
    except:
        print("Cannot load module for part: " + part)
        print "Unexpected error: ", exc_info()[0]
        exit()