I know about ibl.py. I made this Library out of boredom, pretty much.
PLUS: InfiniPy has some neat features - like the endpoint_for function.
import infinipy
USER_ID = 899722893603274793
BOT_ID = 909882795768315986
user = infinipy.fetchUserSync(USER_ID) # Will return infinipy.core.User()
bot = infinipy.fetchBotSync(BOT_ID) # Will return infinipy.core.Bot()
print("Bot Stats:")
print("Votes: "+str(bot.analytica['votes'])
print("User Stats:")
print("Nick: " + user.name + "\nBio: "+ user.about)
Ah yes, the Problem of determining if someone's a Bot or not...
So, let's assume that you want to make a bot that can get Infos using an info command
BUT it must be able to detect wether you specified a User or a Bot.
Well, the infinipy.helpers module added in V0.2 should be able to help you!
In theory, this is the code:
from infinipy.helpers import APISession, endpoint_for
session = APISession("BOT_ID")
obj = session.fetch()
In a Bot maybe like this:
@client.command()
async def iblinfo(ctx,_Id):
session = APISession(_Id)
object = session.fetch()
await ctx.send(object.name)
And that's it for V0.2!
Okay, you want everybody to see how cool your Bot is. That's great!
In V0.3, I have added APISessions to do exactly that!
Whether you're using a script to just post stats there, or want to real-time update your Bot's Statistics on IBL, I gotcha!
For simple Scripts, I recommend to use the SyncAPISession Class:
In theory, usage would look like this:
from infinipy import SyncAPISession
api = SyncAPISession("api_key")
api.postStats(shard_count, server_count)
While in a script, it could look something like this:
from infinipy import SyncAPISession
from dotenv import load_dotenv
import os
from discordbot import botclient
load_dotenv()
api = SyncAPISession(os.environ.get("ibl_api_key"))
api.postStats(bot.shards,len(bot.guilds))
Async is the same, but postStats must be awaited.
This is recommended to post real-time stats, like this:
from infinipy import AsyncAPISession
from dotenv import load_dotenv
import os
load_dotenv()
@bot.event
async def on_guild_join(guild):
api = AsyncAPISession(os.environ.get("ibl_api_key"))
await api.postStats(bot.shards,len(bot.guilds))
Note, that on both Classes you can get the API's response like this:
response = api.session["UPDATE_RESPONSE"]
print(response)
AutoPosters update the Bot's statistics every so and so seconds, kinda like this:
from infinipy.helpers import AutoStatsUpdater
from mycoolbot import bot # Your Bot instance
interval = 120 # Must be >= 120
poster = AutoStatsUpdater(bot,"API_KEY_HERE",interval)
poster.start()
Hope to see you soon!
~ ZeroTwo36