Package: nuqql-based
nuqql-basednuqql-based is a basic network daemon library that implements the nuqql
interface. It can be used as a dummy backend fornuqql, e.g., for testing or as a basis for
the implementation of other nuqql backends.Other backends using nuqql-based:nuqql-slixmppd: a backend for the
XMPP (Jabber) protocolnuqql-matrixd: a backend for the
Matrix protocolnuqql-matrixd-nio: a backend
for the Matrix protocolDependencies:daemon(optional): for daemonize
supportSetupYou can install nuqql-based, for example, with pip for your user only with the
following command:$pipinstall--usernuqql-basedIf you prefer to check out this repository with git and work with the
repository directly, you can install nuqql-based for your user in editable mode
with the following command:$pipinstall--user-e.UsageCreating a nuqql backend with the nuqql-based library consists of the steps in
the following boilerplate code:fromnuqql_based.basedimportBasedfromnuqql_based.callbackimportCallback# create a new backendBACKEND_NAME="myBackend"BACKEND_VERSION="0.1"based=Based(BACKEND_NAME,BACKEND_VERSION)# set callbackscallbacks=[# based events(Callback.BASED_CONFIG,based_config),(Callback.BASED_INTERRUPT,based_interrupt),(Callback.BASED_QUIT,based_quit),# nuqql messages(Callback.QUIT,stop),(Callback.ADD_ACCOUNT,add_account),(Callback.DEL_ACCOUNT,del_account),(Callback.SEND_MESSAGE,send_message),(Callback.SET_STATUS,set_status),(Callback.GET_STATUS,get_status),(Callback.CHAT_LIST,chat_list),(Callback.CHAT_JOIN,chat_join),(Callback.CHAT_PART,chat_part),(Callback.CHAT_SEND,chat_send),(Callback.CHAT_USERS,chat_users),(Callback.CHAT_INVITE,chat_invite),]based.set_callbacks(callbacks)based.start()You can omit the callbacks you do not need in thecallbackslist. In addition
to the code above, you need to implement the callbacks you specify in yourcallbackslist.The parameters passed to all callbacks are: the account, the callback and a
callback-specific parameter tuple. The following example shows thesend_messagecallback:asyncdefsend_message(account,callback,params):"""Send a message to another user."""dest,msg=params# do something with the message...return""The callbacks are only used for commands coming from nuqql. You must handle
backend-specific events like receiving messages from other users in your
backend code and optionally pass them to nuqql-based. The following example
shows how incoming messages from other users can be passed to nuqql-based withMessage.message()andreceive_msg():fromnuqql_based.messageimportMessagedefreceive(account,timestamp,sender,destination,text):"""Receive message from other user."""msg=Message.message(account,timestamp,sender,destination,text)account.receive_msg(msg)Changesv0.3.0:Switch to asyncio and increase required Python version to >= 3.7Remove copy of the buddy list from Account and rename callbackUPDATE_BUDDIEStoGET_BUDDIESto match new behaviourAdd callbacks:HELP_WELCOME: welcome/help message for clientsHELP_ACCOUNT_ADD: help text for adding accountsAdd configuration option for filtering own messagesv0.2.0:Use only one log fileAdd "push-accounts" to configuration/command line argumentsAdd more info messages and extend output of "help" commandChange callback parameter from account id to AccountAdd testsCleanups and fixesv0.1:First release.