選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
Tanner Collin 6e96b6cee4 Let users initialize bwb object with ID themselves 5年前
bwb Let users initialize bwb object with ID themselves 5年前
.gitignore Initial commit 5年前
README.md Let users initialize bwb object with ID themselves 5年前
build-upload.sh Add README and build script 5年前
license.txt Initial commit 5年前
setup.py Let users initialize bwb object with ID themselves 5年前

README.md

bwb

bot with bot.

Usage

Install with pip install --upgrade bwb.

from bwb import bwb
bwb = bwb.bwb(TELEGRAM_ID)

Handshaking

Boot up:

client.send_message(CHAT_ID, '000000init ' + bwb.init())

On 000000init [data]:

event.respond('000000handshake ' + bwb.handshake(data))

On 000000handshake [data]:

event.respond(bwb.wrap('secret ' + bwb.secret(data), handshake=True))

On Handshake OTP authed 123456secret [data]:

bwb.set_secret(data)
event.respond(bwb.wrap('🤝'))

On OTP authed 123456🤝:

event.respond('🤝')

Interaction

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.

Example:

text = bwb.parse(text)
if text.startswith('!'):
    ...
elif text.startswith('000000'):
    text = text[6:]
elif bwb.check_auth(text, handshake=True):
    handshake_authed = True
    text = text[6:]
elif bwb.check_auth(text):
    authed = True
    text = text[6:]
else:
    return

Use bwb.wrap() to auth and encode outgoing commands.

Params:

wrap(text, handshake=False, target=None, b58=False, enc=False)

Examples:

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:

pip install --upgrade ~/path/to/bwb

Deployment

Install setuptools:

python3 -m pip install --user --upgrade setuptools wheel
  • Increment version number in setup.py

Build and upload:

bash build-upload.sh