Example #1
0
    def cmd_gencmd(self, players, msg, channel):
        """Generate a command list based on currently loaded plugins in markdown."""
        if len(msg) > 1:
            excluded = [s.lower() for s in msg[1:]]
        else:
            excluded = []

        cmds = {}
        for cmd in minqlbot.COMMANDS.commands:
            if cmd.plugin.__class__.__name__ in excluded:  # Skip excluded plugins.
                continue

            if cmd.permission not in cmds:
                cmds[cmd.permission] = [cmd]
            else:
                cmds[cmd.permission].append(cmd)

        out = (
            "### Commands\n"
            "The command system is based on permission levels. A player will have a permission level\n"
            "of **0** by default. A player with level **1** can execute commands for level **1** and\n"
            "below. A level **2** player can execute level **2**, **1** and **0** commands, and so on.\n"
            "\n\n"
            )
        
        for perm in sorted(cmds.keys()):
            out += "*   Permission level **{}**\n\n".format(perm)
            for cmd in sorted(cmds[perm], key=lambda x: x.plugin.__class__.__name__):
                out += "    *   **`{}`**".format(minqlbot.COMMAND_PREFIX + cmd.name[0])
                if len(cmd.name) > 1:  # Aliases?
                    out += " (alternatively "
                    for alias in cmd.name[1:]:
                        out += "`{}`, ".format(minqlbot.COMMAND_PREFIX + alias)
                    out = out[:-2] + ")"
                out += " from *{}*\n\n".format(cmd.plugin.__class__.__name__)
                
                # Docstring.
                if cmd.handler.__doc__:
                    out += "        {}\n\n".format(cmd.handler.__doc__)

                # Usage
                if cmd.usage:
                    out += "        *Usage*: `{} {}`\n\n" \
                        .format(minqlbot.COMMAND_PREFIX + cmd.name[0], cmd.usage)
        
        out += "*Automatically generated by [minqlbot {}](https://github.com/MinoMino/minqlbot)*" \
            .format(minqlbot.version())

        with open("python\\command_list.md", "w") as f:
            f.write(out)

        channel.reply("^7Command list generated!")
Example #2
0
"""

import os
import sys
import configparser
import re
import traceback
import importlib
import minqlbot

# ====================================================================
#                             CONSTANTS
#      Technically not constants, but yeah. Don't change these.
# ====================================================================

setattr(minqlbot, "__version__", minqlbot.version())

# QL keeps track of teams in terms for integers. The integer = the tuple's index.
setattr(minqlbot, "TEAMS", ("free", "red", "blue", "spectator"))
# Gametypes. The integer = the tuple's index.
setattr(minqlbot, "GAMETYPES", ("Free for All", "Duel", "Race", "Team Deathmatch", "Clan Arena",
    "Capture the Flag", "Overload", "Harvester", "Freeze Tag", "Domination", "Attack and Defend", "Red Rover"))
setattr(minqlbot, "GAMETYPES_SHORT", ("ffa", "duel", "race", "tdm", "ca", "ctf", "ob", "har", "ft", "dom", "ad", "rr"))
# Rulesets. The integer = the tuple's index.
setattr(minqlbot, "RULESETS", ("", "classic", "turbo", "ql"))

# Possible return values for plugins callbacks that control the flow of succeeding callbacks.
setattr(minqlbot, "RET_NONE", 0)
setattr(minqlbot, "RET_STOP", 1)
setattr(minqlbot, "RET_USAGE", 2)
Example #3
0
"""

import os
import sys
import configparser
import re
import traceback
import importlib
import minqlbot

# ====================================================================
#                             CONSTANTS
#      Technically not constants, but yeah. Don't change these.
# ====================================================================

setattr(minqlbot, "__version__", minqlbot.version())

# QL keeps track of teams in terms for integers. The integer = the tuple's index.
setattr(minqlbot, "TEAMS", ("free", "red", "blue", "spectator"))
# Gametypes. The integer = the tuple's index.
setattr(minqlbot, "GAMETYPES",
        ("Free for All", "Duel", "Race", "Team Deathmatch", "Clan Arena",
         "Capture the Flag", "Overload", "Harvester", "Freeze Tag",
         "Domination", "Attack and Defend", "Red Rover"))
setattr(minqlbot, "GAMETYPES_SHORT",
        ("ffa", "duel", "race", "tdm", "ca", "ctf", "ob", "har", "ft", "dom",
         "ad", "rr"))
# Rulesets. The integer = the tuple's index.
setattr(minqlbot, "RULESETS", ("", "classic", "turbo", "ql"))

# Possible return values for plugins callbacks that control the flow of succeeding callbacks.