2019-09-10 02:32:11 +00:00
|
|
|
# bwb
|
|
|
|
|
|
|
|
bot with bot.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
Install with `pip install --upgrade bwb`.
|
|
|
|
|
2019-09-10 02:37:14 +00:00
|
|
|
```text
|
2019-09-10 02:32:11 +00:00
|
|
|
# Import one of:
|
|
|
|
from bwb.tanner import bwb
|
|
|
|
from bwb.jason import bwb
|
|
|
|
from bwb.tdev import bwb
|
|
|
|
from bwb.molly import bwb
|
|
|
|
```
|
|
|
|
|
|
|
|
### Handshaking
|
|
|
|
|
2019-09-11 04:31:44 +00:00
|
|
|
Boot up:
|
2019-09-10 02:32:11 +00:00
|
|
|
|
2019-09-10 02:37:14 +00:00
|
|
|
```text
|
2019-09-11 04:31:44 +00:00
|
|
|
client.send_message(BOT_WITH_BOT, '000000init ' + bwb.init())
|
2019-09-10 02:32:11 +00:00
|
|
|
```
|
|
|
|
|
2019-09-11 04:31:44 +00:00
|
|
|
On `000000init [data]`:
|
2019-09-10 02:32:11 +00:00
|
|
|
|
2019-09-10 02:37:14 +00:00
|
|
|
```text
|
2019-09-11 04:31:44 +00:00
|
|
|
client.send_message(BOT_WITH_BOT, '000000handshake ' + bwb.handshake(data))
|
2019-09-10 02:32:11 +00:00
|
|
|
```
|
|
|
|
|
2019-09-11 04:31:44 +00:00
|
|
|
On `000000handshake [data]`:
|
|
|
|
|
|
|
|
```text
|
|
|
|
client.send_message(BOT_WITH_BOT, bwb.wrap('secret ' + bwb.secret(data)))
|
|
|
|
bwb.set_otp(bwb.init_secret)
|
|
|
|
```
|
|
|
|
|
|
|
|
On _OTP authed_ `123456secret [data]`:
|
|
|
|
|
|
|
|
```text
|
|
|
|
bwb.set_secret(data)
|
|
|
|
client.send_message(BOT_WITH_BOT, bwb.wrap('🤝'))
|
|
|
|
```
|
|
|
|
|
|
|
|
On _OTP authed_ `123456🤝`:
|
|
|
|
|
|
|
|
```text
|
|
|
|
client.send_message(BOT_WITH_BOT, '🤝')
|
|
|
|
```
|
2019-09-10 02:32:11 +00:00
|
|
|
|
|
|
|
### Interaction
|
|
|
|
|
2019-09-10 03:07:39 +00:00
|
|
|
Run every incoming message through `bwb.parse()` since it's inexpensive. This will decrypt and remove base58 encoding.
|
|
|
|
|
|
|
|
Once decoded, send it through `bwb.check_auth()` which will return `True` or `False` if the code is valid.
|
2019-09-10 02:32:11 +00:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
2019-09-10 02:37:14 +00:00
|
|
|
```text
|
2019-09-10 03:07:39 +00:00
|
|
|
text = bwb.parse(text)
|
2019-09-10 02:32:11 +00:00
|
|
|
if text.startswith('!'):
|
|
|
|
...
|
2019-09-10 03:07:39 +00:00
|
|
|
elif text.startswith('000000'):
|
|
|
|
text = text[6:]
|
|
|
|
elif bwb.check_auth(text):
|
|
|
|
authed = True
|
|
|
|
text = text[6:]
|
2019-09-10 02:32:11 +00:00
|
|
|
else:
|
2019-09-10 03:07:39 +00:00
|
|
|
return
|
2019-09-10 02:32:11 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Use `bwb.wrap()` to auth and encode outgoing commands.
|
|
|
|
|
|
|
|
Params:
|
|
|
|
|
2019-09-10 02:37:14 +00:00
|
|
|
```text
|
2019-09-10 02:32:11 +00:00
|
|
|
wrap(text, target=None, b58=False, enc=False)
|
|
|
|
```
|
|
|
|
|
|
|
|
Examples:
|
2019-09-10 02:37:14 +00:00
|
|
|
```text
|
2019-09-10 02:32:11 +00:00
|
|
|
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:
|
|
|
|
|
2019-09-10 02:37:14 +00:00
|
|
|
```text
|
2019-09-10 02:32:11 +00:00
|
|
|
pip install --upgrade ~/path/to/bwb
|
|
|
|
```
|
|
|
|
|
|
|
|
### Deployment
|
|
|
|
|
|
|
|
Install setuptools:
|
|
|
|
|
2019-09-10 02:37:14 +00:00
|
|
|
```text
|
2019-09-10 02:32:11 +00:00
|
|
|
python3 -m pip install --user --upgrade setuptools wheel
|
|
|
|
```
|
|
|
|
|
|
|
|
* Increment version number in `setup.py`
|
|
|
|
|
|
|
|
Build and upload:
|
|
|
|
|
2019-09-10 02:37:14 +00:00
|
|
|
```text
|
2019-09-10 02:32:11 +00:00
|
|
|
bash build-upload.sh
|
|
|
|
```
|