Skip to main content

the python3 bot namespace.

Project description

NAME

BOTLIB - python3 bot library

SYNOPSIS

bot <cmd> [key=value] [key==value]

DESCRIPTION

BOTLIB is a solid, non hackable bot, that runs under systemd as a 24/7 background service and starts the bot after reboot, intended to be programmable in a static, only code, no popen, no imports and no reading modules from a directory.

BOTLIB is programmable, to program the bot you have to have the code available as employing your own code requires that you install your own bot as the system bot. This is to not have a directory to read modules from to add commands to the bot but include the own programmed modules directly into the python code, so only trusted code (your own written code) is included and runnable. Reading random code from a directory is what gets avoided. As experience tells os.popen and __import__, importlib are avoided.

BOTLIB stores it’s data on disk where objects are time versioned and the last version saved on disk is served to the user layer. Files are JSON dumps that are read-only so thus should provide (disk) persistence more chance. Paths carry the type in the path name what makes reconstruction from filename easier then reading type from the object.

Only include your own written code should be the path to “secure”.

INSTALL

pip3 install botlib

CONFIGURATION

configuration is done by calling the config command of the bot.

irc

bot cfg server=<server> channel=<channel> nick=<nick>

(*) default channel/server is #botlib on localhost

sasl

bot pwd <nickservnick> <nickservpass>
bot cfg password=<outputfrompwd>

users

bot cfg users=True
bot met <userhost>

SYSTEMD

$ sudo cp /usr/local/share/botd/botd.service /etc/systemd/system
$ sudo systemctl enable botd --now

use botctl instead of the use bot program

$ sudo botctl cfg server=<server> channel=<channel> nick=<nick>
$ sudo bptctl pwd <nickservnick> <nickservpass>
$ sudo botctl cfg password=<outputfrompwd>
$ sudo botctl cfg users=True
$ sudo botctl met <userhost>

RUNNING

run the bot with the bot command, it will start a shell with the irc bot. use the -c option if you just want the console.

bot [-c]

console

bart@botlib:~$ bot -c
BOT start at Fri Apr 1 20:02:40 2022
> thr
Console.loop(1s) thr(1s)
>

irc

bart@botlib:~$ bot
BOT start at Fri Apr 1 20:00:43 2022
server=localhost port=6667 channel=#botlib nick=botlib cc=!
> thr
Console.loop(8s) IRC.keep(8s) IRC.loop(8s) IRC.output(8s) thr(8s) Fetcher.run(4m52s)
>

COMMANDS

the bot has the following commands.

bart@botlib:~$ bot cmd
cfg,cmd,dlt,dpl,flt,fnd,ftc,met,nam,nck,ops,pwd,rem,rss,thr

here is a short description of the commands.

cmd - shows all commands
cfg - shows the irc configuration, also edits the config
dlt - removes a user from bot
dpl - sets display items for a rss feed
ftc - runs a rss feed fetching batch
fnd - allows you to display objects on the datastore, read-only json files on disk
flt - shows a list of bot registered to the bus
log - logs some text
met - adds a users with there irc userhost
mre - displays cached output, channel wise.
nck - changes nick on irc
ops - tries to have the bot give you operator status (+o)
pwd - combines a nickserv name/password into a sasl password
rem - removes a rss feed by matching is to its url
rss - adds a feed to fetch, fetcher runs every 5 minutes
thr - show the running threads
tdo - adds a todo item, no options returns list of todo’s

PROGRAMMING

git clone https://github.com/bthate/botlib

joe bot/hello.py

from bot.hdl import Commands


def hlo(event):
    event.reply("hello!")


Commands.add(hlo)

COPYRIGHT

BOTLIB is placed in the Public Domain. No Copyright, No License.

AUTHOR

Bart Thate

Project details


Release history Release notifications | RSS feed

This version

160

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

botlib-160.tar.gz (33.5 kB view hashes)

Uploaded source

Built Distribution

botlib-160-py3-none-any.whl (24.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page