Zaeem20 / danbot-status-py

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

danbot-status

travis-ci

DanBot Status is a module built in python for getting all statistical services used by DanBotHost.

Changelog

  • v0.0.1: Initial release
  • v0.0.2: Converted the module to a Asynchronous Package
  • v0.1.1: Added Support for Synchronous and Asynchronous Programming

Installation

pip install danbot-status --> For Windows

pip3 install danbot-status --> For Linux

Usage

import danbotstatus --> Importing Module in Python

Classes

danbotstatus.SynchronousStatus() --> For Synchronous Coding danbotstatus.AsynchronousStatus() --> For Asynchronous Coding

Errors

danbotstatus.APIError() -> Thrown when the API is not responding or is down

danbotstatus.NodeError() -> Thrown when the Node is not available

danbotstatus.NodeNegaiveError() -> Thrown when the Node value passed is a negative value

danbotstatus.LavaError() -> Thrown when the Lava node is not available

danbotstatus.LavaNegativeError() -> Thrown when the Lava node value passed is a negative value

Basic Example Of danbotstatus in Asynchronous Environment In Discord Bot (discord.py)

This method needs the module discord.py

import discord
from danbotstatus import AsynchronousStatus
dbs = AsynchronousStatus()
bot = discord.Client()

@bot.event
async def on_ready():
    print("Logged In as " + bot.user )
    
    
@bot.event
async def on_message(message):
    if message.content == 'check all node status':
        nodestats = await dbs.getallnodestats()
        await message.channel.send(nodestats)
        
bot.run("TOKEN")

Basic Example Of danbotstatus in Synchronous Environment In Flask (Flask)

This method needs the module discord.py

from flask import Flask
from danbotstatus import SynchronousStatus
dbs = SynchronousStatus()
app = Flask(__name__)

@app.route('/')
def index():
    return {'status': "alive"}
    
    
@app.route('/allnodestats')
def nodestats():
    ns = dbs.getallnodestats()
    return ns
        
if __name__ == '__main__':
    app.run()

Basic Functions in the module (SynchronousStatus)

pssst, this is not an example , this just shows the functions the module has

from danbotstatus import SynchronousStatus
dbhs = danbotstatus.SynchronousStatus()
allnodestats = dbhs.getallnodestats()   # Gets All Node Status
allstats = dbhs.getallstats()   # Gets All Status including nodestatus and misc
allawait sysinfo = dbhs.getallsysinfo()   # Gets All Node System Informations
lavastats = dbhs.getlavastatus(int)  #Gets a particular lava status, Replace int by number. For example: lavastats = dbhs.getlavastatus(1)  gives Lava1 information
misc = dbhs.getmiscstatus()  # Gets misc status
leaderboard = dbhs.leaderboard()  # Gets Leaderboard 
nodestats = dbhs.getnodestatus(int) # Gets a particular node status
sysinfo = dbhs.getsysinfo(int) # Gets a particular node information, Replace int by node number
print(allnodestats)   # Returns data in dictionary
print(allstats)        # Returns data in dictionary
print(allsysinfo)        # Returns data in dictionary
print(lavastats)         # Returns data in bool from --> True if its online, False if its offline
print(leaderboard)  #Returns data in list
print(nodestats)    # Returns data in dictionary
print(sysinfo) # Returns data in dictionary

Basic Functions in the module (AsynchronousStatus)

pssst, this is not an example , this just shows the functions the module has

from danbotstatus import AsynchronousStatus
dbhs = AsynchronousStatus()
allnodestats = await dbhs.getallnodestats()   # Gets All Node Status
allstats = await dbhs.getallstats()   # Gets All Status including nodestatus and misc
allawait sysinfo = await dbhs.getallsysinfo()   # Gets All Node System Informations
lavastats = await dbhs.getlavastatus(int)  #Gets a particular lava status, Replace int by number. For example: lavastats = dbhs.getlavastatus(1)  gives Lava1 information
misc = await dbhs.getmiscstatus()  # Gets misc status
leaderboard = await dbhs.leaderboard()  # Gets Leaderboard 
nodestats = await dbhs.getnodestatus(int) # Gets a particular node status
sysinfo = await dbhs.getsysinfo(int) # Gets a particular node information, Replace int by node number
print(allnodestats)   # Returns data in dictionary
print(allstats)        # Returns data in dictionary
print(allsysinfo)        # Returns data in dictionary
print(lavastats)         # Returns data in bool from --> True if its online, False if its offline
print(leaderboard)  #Returns data in list
print(nodestats)    # Returns data in dictionary
print(sysinfo) # Returns data in dictionary

Thank You.

Module Built By Viney. Any Queries or Issue, feel free to make an Issue in the issue tab of Github. This project is welcome to receive any contributions by submitting in PR's

About

License:MIT License


Languages

Language:Python 100.0%