You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
1.6 KiB

# bwb
bot with bot.
## Usage
Install with `pip install --upgrade bwb`.
5 years ago
```text
# Import one of:
from bwb.tanner import bwb
from bwb.jason import bwb
from bwb.tdev import bwb
from bwb.molly import bwb
```
### Handshaking
On boot up, send `000000handshake` to BWB chat.
When you see a `000000handshake`:
5 years ago
```text
secret = bwb.init()
await client.send_message(BWB, '000000handshake ' + secret)
```
When you see a `000000handshake [secret data]`:
5 years ago
```text
bwb.init(secret_data)
await client.send_message(BWB, bwb.wrap('🤝'))
```
When you see and authed '🤝', reply with *unauthed* '🤝'.
### Interaction
Run every incoming message through `bwb.parse()` since it's inexpensive. This will decrypt and remove base58 encoding. If the command is invalid, `text` will be `None`.
Example:
5 years ago
```text
if text.startswith('!'):
...
else:
authed, text = bwb.parse(text)
5 years ago
if not text: return
```
Use `bwb.wrap()` to auth and encode outgoing commands.
Params:
5 years ago
```text
wrap(text, target=None, b58=False, enc=False)
```
Examples:
5 years ago
```text
out = bwb.wrap('ping') # broadcast all bots
out = bwb.wrap('ping', target=TANNER) # auth for Tannerbot
out = bwb.wrap('ping', target=JASON, enc=True) # base58 encrypt
out = bwb.wrap('ping', target=MOLLY, b58=True) # base58
```
## Development
### Setup
Clone the repo.
To test your changes:
5 years ago
```text
pip install --upgrade ~/path/to/bwb
```
### Deployment
Install setuptools:
5 years ago
```text
python3 -m pip install --user --upgrade setuptools wheel
```
* Increment version number in `setup.py`
Build and upload:
5 years ago
```text
bash build-upload.sh
```