Low-Level Modules¶
This is the general module API – the lower-level stuff, the stuff that UModule interfaces with.
Naming¶
Module filenames must be in the format of psm_yourmodulenamehere.py
preferrably all lowercase.
Module classes must be in the format of PSModule_yourmodulenamehere
,
with both yourmodulenamehere’s being the same case.
For example, I may name my example module psm_example.py
, with the
class name PSModule_example
.
Class¶
All modules must extend PSModule
Class Variables¶
You should implement class variables:
VERSION
= (number), up to you.
Additionally, the default __init__
sets several useful class
variables for you to use in your module:
parent
= object (received from__init__
, your parent server- object, e.g., TS6Protocol()).
config
= object (received from__init__
, the same- configuration object used in the parent server object).
logchan
= string (is set in__init__
, channel from config- where your bot users reside if you use one).
log
= object (is set in__init__
, file/stdout logger (usage:- log.error(msg)|log.info(msg)…etc, see python logging lib for details).
dbp
= object (is set in__init__
, is the parent’s database- pointer) – NB you should always make your own database if your module needs one.
Commands¶
There is only one sort of ‘command’ in the general module API. In UModule, these are called admin commands (acmds), and we will refer to them as such here.
acmd¶
Admin Commands are actual pypsd commands. To create
an acmd_something.py library, simply add the functions you wish, and
return the (function, usagestring) as a tuple from getCommands()
ACL flags, and Permissions¶
Each acmd has ‘ACL flags’ that you need to specify. This is essentially how the permissions in PyPsd currently work:
We can have 52 ACL flags, from a-z and A-Z.
When someone creates a module, they choose a character (a-zA-Z)
that nobody else has picked yet, and that is essentially their module’s ‘access control’ mode character. For instance, for my new Twitter module, I might pick 'r'
.
After you pick your character, make sure your commands have it in the ‘permission’ entry, as such:
def getCommands(self):
return (
('disable', {
'permission' : 'r',
'callback' : self.cmd_disable,
'usage' : '- Disable Twitter functionality'}),
)
This means that users will need to have 'r'
in their ACL flags list to run the twitter.disable
acmd.
Examples of ACL flags lists:
- IAmAGod:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
- EverythingButShutdown:
bcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
- Power:
efinopstuwxyzABCDEFGHIJKLMQRSTUVW
- KindaOkay:
ioqswyzCDEKQSTU
- MidnightShiftGuy:
ghvwDFRTVZ
- TheTwitterGuy:
r
It may also be useful to give different commands in the same module different flags. For instance, you may want to let someone restart your module, but not shut it down completely.
ACL flags list¶
Here’s a list of what different flags are used to control:
r
: Core - Shutting down, and reloading PyPsd itselfm
: Core – Module loading, unloading, and reloadingl
: Core – Channel and user lookupsa
: ACL – Removing and adding ACL flags from usersb
: Bouncer – Blacklists based on CIDR blacklistsb
: ProxyBridge – Scan users for proxies, and take actiond
: Debugger – Debugging PyPsd, log searching and terminal commandsd
: DNS Blacklist – Controlling a DNS blackliste
: eRepublik – Online, global strategy gamee
: e-Sim – Another online game, like eRepublike
: Internets – Controls access to all of Interents’ admin commandsj
: LimitServ – Controls number of users in channels?j
: Ninja – Keeps privmsgs from being posted heaps of timesj
: Quotes – Keeping a local quote databasej
: Trivia – Running trivia gamesr
: DynLogLevel – Changing PyPsd’s logging levelr
: WALLOPS – Redirects WALLOPS to a channels
: NetStats – Keeps network statisticsv
: CTCP – CTCP info collecting and blacklistingw
: WikiMonitor – Monitors Wikisx
: Xray – Scans nicks, channel names, etc given provided regexesA
: AKILL – AKILLing users, removing AKILLsB
: ListBots – Lists important bots for usersD
: Deaf – TODOM
: HTTP Monitor – Monitors HTTPN
: NetAdmin – Sends RAW IRC messages. Be very afraidN
: ProxyBridge – Reloading Proxybridge’s config informationN
: UIDfix – Fixing modules’ UIDs, low-level scary scary