rext package

Module contents

Basic package for the Rext program.

Defines all the basic Objects and functionality.

class Bot(zelf, *args, **kwargs)[source]

Bases: rext.Dispatcher

Base Bot class.

announce(zelf, *args, **kwargs)[source]
begin(zelf, *args, **kwargs)[source]
connect(zelf, *args, **kwargs)[source]
do_one(zelf, *args, **kwargs)[source]
exit(zelf, *args, **kwargs)[source]
get_prompt(zelf, *args, **kwargs)[source]
join_channels(zelf, *args, **kwargs)[source]
set_cfg(zelf, *args, **kwargs)[source]
class ConsoleBot(zelf, *args, **kwargs)[source]

Bases: rext.Bot

boot(zelf, *args, **kwargs)[source]
do_one(zelf, *args, **kwargs)[source]
get_prompt(zelf, *args, **kwargs)[source]
say(zelf, *args, **kwargs)[source]
class Dispatcher(zelf, *args, **kwargs)[source]

Bases: rext.Object

The Dispatcher is the object to delegate the workload to the Runners. Runners get instantiated when needed.

cleanup(zelf, dojoin=False)[source]

Remove idle Runners.

dispatch(zelf, *args, **kwargs)[source]

dispatch an event (object) onto a runner if matching command is found.

do_func(zelf, *args, **kwargs)[source]

Execute command/event pair if command is registered.

execute(zelf, *args, **kwargs)[source]

Execute a command, event pair. If the “threaded” attribute is set, dispatch to a Runner.

exit(zelf, name=None)[source]

Stop the Runners running in this Dispatcher.

is_alive(zelf, *args, **kwargs)[source]

Check whether there are any Runners running.

make_new(zelf, *args, **kwargs)[source]

Create a Runner, try for idle Runners already available first.

put(zelf, *args, **kwargs)[source]

Put load to the Runner, create a new Runner if necessary.

register(zelf, *args, **kwargs)[source]

register a callback type with corresponding callback function.

exception Error[source]

Bases: builtins.BaseException

Basic Exception used in the Rext program.

exception FileNotFoundError[source]

Bases: rext.Error

Exception thrown when file is not found.

class IRCBot(zelf, *args, **kwargs)[source]

Bases: rext.Bot

action(zelf, printto, what, event=None, *args, **kwargs)[source]
bind(zelf)[source]
broadcast(zelf, txt)[source]
cc = '.'
close(zelf)[source]
connect(zelf, reconnect=True)[source]
ctcp(zelf, printto, what)[source]
ctcpreply(zelf, printto, what)[source]
delop(zelf, channel, who)[source]
do_one(zelf, *args, **kwargs)[source]
donick(zelf, nick, setorig=False, save=False, whois=False)[source]
doop(zelf, channel, who)[source]
getchannelmode(zelf, channel)[source]
handle_366(zelf, *args, **kwargs)[source]
handle_433(zelf, event)[source]
handle_513(zelf, event)[source]
handle_ctcp(zelf, event)[source]
handle_invite(zelf, event)[source]
handle_notice(zelf, event)[source]
handle_ping(zelf, event)[source]
handle_privmsg(zelf, event)[source]
join(zelf, channel, password=None)[source]
join_channels(zelf, *args, **kwargs)[source]
logon(zelf)[source]
marker = '\r\n'
names(zelf, channel)[source]
notice(zelf, printto, what)[source]
part(zelf, channel)[source]
ping(zelf, *args, **kwargs)[source]
pong(zelf, *args, **kwargs)[source]
privmsg(zelf, printto, what)[source]
quit(zelf, reason='https://pikacode.com/bthate/z2')[source]
read_some(zelf, *args, **kwargs)[source]
say(zelf, *args, **kwargs)[source]
send(zelf, txt)[source]
settopic(zelf, channel, txt)[source]
voice(zelf, channel, who)[source]
who(zelf, who)[source]
whois(zelf, who)[source]
class Looper(zelf, *args, **kwargs)[source]

Bases: rext.Object

A Looper calls a function every x seconds.

func_do(zelf, *args, **kwargs)[source]
start(zelf, *args, **kwargs)[source]
exception NoJSON[source]

Bases: rext.Error

Exception thrown incase no JSON could be decoded/encoded.

exception NoTarget[source]

Bases: rext.Error

Exception thrown incase of missing argument attribute.

exception NotSet[source]

Bases: rext.Error

Exception thrown when a attribute is not set.

class Object[source]

Bases: builtins.dict

THE Basic Object on which the rest of the Rext program is based.

announce(zelf, *args, **kwargs)[source]

announce to all the running bots.

check_notwanted(zelf, *args, **kwargs)[source]

function to check whether an objects is not desired, first argument is a dict that has the attributes to be matched.

check_wanted(zelf, *args, **kwargs)[source]

function to check whether an objects is desired, first argument is a dict that has the attributes to be matched.

clear(zelf)[source]

clear the object’s ready state.

define(zelf, *args, **kwargs)[source]

set a attribute on this object.

dump(zelf, *args, **kwargs)[source]

create a JSON string ready to be saved to disk.

exec_str(zelf, *args, **kwargs)[source]

execute a string as a command.

first(zelf, *args, **kwargs)[source]

return the first object where the key and/or value matches.

get_args(zelf, *args, **kwargs)[source]

get the arguments of the txt attribute.

get_clean(zelf, *args, **kwargs)[source]

return a cloned object, with only the proper keys used.

get_cmnd(zelf, *args, **kwargs)[source]

determine the command in the zelf.txt attribute, if present.

get_days(zelf, *args, **kwargs)[source]

get the number of days relative to the objects creation time.

get_filetime(zelf, *args, **kwargs)[source]

get timestamp related filename.

get_keys(zelf, *args, **kwargs)[source]

return the keys of this object, skipping the unwanted keys e.g those that start with a “_”.

get_parsed(zelf, *args, **kwargs)[source]

parse the txt attribute, so command can be determined.

get_rest(zelf, *args, **kwargs)[source]

get the rest of the txt arguments (words) e.g. minus the first word (the command).

get_root(zelf, *args, **kwargs)[source]

return the root dir of the Rext program.

get_slice(zelf, *args, **kwargs)[source]

args: list of keywords to slice the dict.

get_timed(zelf, *args, **kwargs)[source]

retrieve the creation time of an object.

get_url_file(zelf, *args, **kwargs)[source]

get the url of the object’s file so that it can be retrieved when API server is running.

get_url_show(zelf, *args, **kwargs)[source]

return url that gives a readable representation of the object’s JSON file.

last(zelf, *args, **kwargs)[source]

return the last object where the key and/or value matches.

load(zelf, *args, **kwargs)[source]

load a JSON file into this object.

make_path(zelf, *args, **kwargs)[source]

return workdir path and create the workdir if necessary.

make_signature(zelf, sig=None)[source]

create a signature of the data contained in this object.

obj_iter(zelf, *args, **kwargs)[source]

iterate over the pure keys (not starting with “_”).

objects(zelf, *args, **kwargs)[source]

return a list of all object’s in the workdir.

pretty(zelf)[source]

return a nice formatted JSON string of this object.

read(zelf, *args, **kwargs)[source]

read the JSON file from disk.

ready(zelf)[source]

signal the object into the ready state.

register(zelf, *args, **kwargs)[source]

register a value in a list on this object.

reply(zelf, *args, **kwargs)[source]

send reply to object’s origin.

save(zelf, *args, **kwargs)[source]

save this object’s JSON onto disk.

say(zelf, *args, **kwargs)[source]

output text through the _target attribute (the bot that received the object).

selected(zelf, *args, **kwargs)[source]

return a list of desired objects, first argument is a dict giving the desired attributes.

selector(zelf, *args, **kwargs)[source]

boolean function to see if this objects has the desired attributes.

show(zelf)[source]

return a list of key,value pairs of this object’s attributes.

sync(zelf, *args, **kwargs)[source]

sync this object’s JSON to disk.

to_full(zelf, *args, **kwargs)[source]

return full JSON dump of this object.

to_json(zelf, *args, **kwargs)[source]

return the JSON string representation of this object.

wait(zelf, sec=180.0)[source]

wait for the object to be put in a ready state.

class Plugins(zelf, *args, **kwargs)[source]

Bases: rext.Object

Object to register Plugins with.

do_init(zelf, *args, **kwargs)[source]

Call the init function of all plugin or a specific one if argument is given.

exit(zelf, *args, **kwargs)[source]

close all plugins by calling there shutdown() function.

get_names(zelf, plugsdir)[source]

Return plugnames from the plugin directory.

load_mod(zelf, plugname, pdir='', force=False)[source]

load a plugin;’s module.

load_package(zelf, modname)[source]

Load the plugins package.

load_plugs(zelf, path)[source]

Load plugins from the plugin directory.

plug_init(zelf, *args, **kwargs)[source]

Initialize a plugin, use the init() function provided in the plugin, if available.

plug_shutdown(zelf, plugname)[source]

Shutdown a plugin by calling the shutdown() function, if provided.

reload(zelf, plugname, force=False)[source]

Reload (unload, load) a plugin.

exception RemoteDisconnect[source]

Bases: rext.Error

Exception thrown when the connection is disconnected.

class Runner(zelf, *args, **kwargs)[source]

Bases: threading.Thread

The working unit of the Rext program, arguments are function, objects pairs pushed to the Runner.

exit(zelf, *args, **kwargs)[source]

stop the Runner by setting the status to an empty string.

put(zelf, *args, **kwargs)[source]

put arguments/kwargs to the Runner.

class XMPPBot(zelf, *args, **kwargs)[source]

Bases: rext.Bot

announce(zelf, *args, **kwargs)[source]
connect(zelf)[source]
do_one(zelf, *args, **kwargs)[source]
exception(zelf, ex)[source]
handle_connected(zelf, *args, **kwargs)[source]
handle_disconnected(zelf, *args, **kwargs)[source]
handle_failedauth(zelf, error, *args)[source]
handle_failure(zelf, ex, *args, **kwargs)[source]
handle_message(zelf, data, *args, **kwargs)[source]
handle_presence(zelf, data, *args, **kwargs)[source]
loop(zelf, *args, **kwargs)[source]
say(zelf, *args, **kwargs)[source]
session_start(zelf, event)[source]
boot(*args, **kwargs)[source]

The boot() function is needed to get the Rext program properly initialized. Use it at the beginning of your program.

irc_parse(obj, *args, **kwargs)[source]
shutdown()[source]

The shutdown() function is used to close the Rext program in a apropiate manner.

Table Of Contents