Skip to content
Zeitocrab edited this page Jul 25, 2018 · 6 revisions

PyRoar documentation

If you're familiar with the Python discord.py API, this should be a breeze! It uses a lot of similar concepts.

This is very heavily object-oriented. In places where a simple string will suffice, check the wiki to see if it's supported.

To start off with, make sure to:

import pyroar, asyncio

Then, create your PSBot() object. If you want to connect to your own server, pass this in to the bot - PSBot('yourserver.psim.us').

bot = PSBot()

Note: For convenience's sake, bot will always be used to refer to the PSBot() object you have created - this is essentially assuming you have done bot = PSBot().

At the end of your code, you'll want to connect to the server - you do this like this:

bot.connect(<account>, password=<password>)

<account> doesn't have to be an account object (this isn't true, it does, but I should make it so it doesn't soon enough) - it can just be a string of the account name.

Then, add in the account's <password> seperately - the password is not attached to your account for security purposes and general logic - the password is only used in connection.


Events

The main part of this library is events. Events are fairly simple: when something happens, e.g. a person PMs you, you run the some code! Events can range from the bot connecting to the server, to the bot receiving a message in a chatroom.

To create code that should be executed when the event is received, use this notation:

@bot.event
async def <eventName>(bot, <other_parameters>):
    print("Code here!")

IMPORTANT: must be the exact name given to the event - a list of events and their names can be found here (insert link sometime).

<other_parameters> can also be found under each event - the bot will always be passed as the first parameter, but you can call it whatever you want (for convenience, give it the same name as your bot, so you know it's the same thing).

Also, remember bot is assumed to be your PSBot().

An explanation on what happens when you create an event: @bot.event is a decorator that adds your function to a dictionary containing all of the event names and their respective functions. When the bot recognises an event, it looks up the event name and executes the function found.

<Bulbapedia Pyroar Image

Clone this wiki locally