Scioly.org:Bots

From Wiki - Scioly.org
Jump to: navigation, search

Bots on Scioly.org are automated tools that browse the forums, wiki, and Discord to help users perform operations and assist in site operations. The main bot currently on the site is User:Pi-Bot, developed by User:Pepperonipi. New bots must be approved before they can be put into use.

Developing a Bot

To develop a bot, there are many technologies and languages you can use. Please remember to be very careful with each language/framework/library you experiment with, as you can easily make havoc on server resources or on the forums/wiki/chat themselves. Users who do this may be temporarily or permanently suspended - to avoid this please try your code in small iterations.

Forums

To interact with the forums, recommended technologies are technologies that can obtain and/or interact with HTML, as there is no official API for the forums to interact with.

Python

Example Python modules to assist with this include:

Here is example code for retrieving the current number of posts on the forums:

from bs4 import BeautifulSoup
import requests

content = requests.get("https://scioly.org/forums/index.php").content.decode("UTF-8")
bs = BeautifulSoup(content, 'html.parser')
print(bs.select_one(".statistics strong:nth-child(1)").string)
#Prints: 401782

Wiki

Interacting with the wiki can be done through a variety of packages provided by developers. A list of libraries/frameworks provided to assist with interacting with the wiki in a variety of pages can be found here.

Python

A popular library for interacting with MediaWiki wikis in Python is Pywikibot. The library can be installed through pip install pywikibot. Additionally, you can download the entire Pywikibot package (which includes documentation files & commonly-used scripts) here.

After you install the packages required to run Pywikibot, you must authenticate your bot so it can actually edit/browse the wiki using its account. Instructions for this can be found here.

An example of using the library is shown below. This file allows you to obtain information about a user in MediaWiki:

import pywikibot
site = pywikibot.Site()
name = input("Enter username: ")        # enter in a username
user = pywikibot.User(site, name)
print("User: ", user)                   # get user
print("Edit Count: ", user.editCount()) # get user's edit count
print("Gender: ", user.gender())        # get user's gender

Discord

Similar to interacting with the wiki and forums, there are many available libraries/frameworks you can use to interact with the Scioly.org Discord, some of which can be found here. To test the bot, you can make a new Discord server and add the bot there.

Python

A popular library for interacting with Discord through Python is discord.py on GitHub. An example of using the library is shown below:

import discord

client = discord.Client()

@client.event
async def on_ready():
    print(f'Logged in as {client.user}')

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('?hello'):
        await message.channel.send('Hello, world!')

client.run('BOT TOKEN')

Bot Approval Process

Main page: Scioly.org:Bots/Requests for approval

To view or make a new bot approval request, please see the page linked in the line above.

List of Bots

Username Icon Developer Join Date Areas Aliases Actions Source Code
User:Pi-Bot Pi-Bot Red Icon.png User:Pepperonipi 2/10/20
  • Discord
  • Forums
  • Wiki
  • Serves chat commands on Discord
  • Graphs Scilympiad results into Template:Final results table
  • Runs wiki stylist, which completes the following actions:
    • Changes {{PAGENAME}} into the original page name on non-template pages
pi-bot on GitHub