示例#1
0
async def statuschecker(stat):
    global STARTTIME
    uptimebot = datetime.now() - STARTTIME
    uptime_hours = uptimebot.seconds // 3600  # (60 * 60)
    uptime_mins = uptimebot.seconds // 60 % 60
    uptime_secs = uptimebot.seconds % 60
    uptimeSTR = (f"{uptimebot.days} " + msgRep.DAYS +
                 f", {uptime_hours:02}:{uptime_mins:02}:{uptime_secs:02}")
    uptimemachine = uptime()
    uptime_machine_converted = timedelta(seconds=uptimemachine)
    uptime_machine_array = str(uptime_machine_converted).split(" days, ")
    # The package uses "days" when days up is equal or above 2,
    # which f***s up math.
    if len(uptime_machine_array) == 1:
        uptime_machine_array = str(uptime_machine_converted).split(" day, ")
    if len(uptime_machine_array) < 2:
        uptime_machine_days = 0
        uptime_machine_time = uptime_machine_array[0].split(":")
    else:
        uptime_machine_days = uptime_machine_array[0]
        uptime_machine_time = uptime_machine_array[1].split(":")
    uptime_machine_hours = uptime_machine_time[0]
    if int(uptime_machine_hours) < 10:
        uptime_machine_hours = "0" + uptime_machine_hours
    uptime_machine_minutes = uptime_machine_time[1]
    uptime_machine_seconds = uptime_machine_time[2].split(".")[0]
    uptimeMacSTR = (f"{uptime_machine_days} " + msgRep.DAYS +
                    f", {uptime_machine_hours}:{uptime_machine_minutes}:"
                    f"{uptime_machine_seconds}")
    commit = None
    try:
        commit = await getGitReview()
    except:
        pass
    rtt = pinger("1.1.1.1")  # cloudfare's
    reply = f"**{msgRep.SYSTEM_STATUS}**\n\n"
    reply += msgRep.UBOT + "`" + PROJECT + "`" + "\n"
    reply += msgRep.VER_TEXT + "`" + VERSION + "`" + "\n"
    if commit:
        reply += msgRep.COMMIT_NUM + "`" + commit + "`" + "\n"
    reply += msgRep.SAFEMODE + f"{msgRep.ON if SAFEMODE else msgRep.OFF}\n"
    reply += msgRep.LANG + f"{getBotLang()} ({getBotLangCode().upper()})\n"
    if rtt:
        reply += msgRep.RTT + "`" + str(rtt) + "`" + "\n"
    else:
        reply += msgRep.RTT + "`" + msgRep.ERROR + "`" + "\n"
    reply += msgRep.BOT_UPTIMETXT + uptimeSTR + "\n"
    reply += msgRep.MAC_UPTIMETXT + uptimeMacSTR + "\n"
    reply += "\n"
    reply += msgRep.TELETON_VER + "`" + str(version.__version__) + "`" + "\n"
    reply += msgRep.PYTHON_VER + "`" + str(python_version()) + "`" + "\n"
    reply += msgRep.GITAPI_VER + "`" + git.vercheck() + "`" + "\n"
    reply += msgRep.CASAPI_VER + "`" + cas.vercheck() + "`" + "\n"
    await stat.edit(reply)
    return
示例#2
0
async def ping(args):
    commandParser = str(args.message.message).split(' ')
    if len(commandParser) != 2:
        await args.edit(msgRep.BAD_ARGS)
    else:
        dns = commandParser[1]
        try:
            duration = pinger(dns)
        except Exception as e:
            log.warning(e)
            await args.edit(msgRep.INVALID_HOST)
            return
        await args.edit(msgRep.PINGER_VAL.format(dns, duration))
    return
示例#3
0
async def rtt(message):
    rtt = pinger(DEFAULT_ADD)
    await message.edit(msgRep.PING_SPEED + rtt)
    return
示例#4
0
async def rtt(message):
    rtt = pinger("1.0.0.1")
    await message.edit(msgRep.PING_SPEED + rtt)
    return