Working hello world

master
Drew Bednar 4 years ago
parent b03b858611
commit e9fbaa2fc5

2
.gitignore vendored

@ -138,3 +138,5 @@ dmypy.json
# Cython debug symbols
cython_debug/
# Pycharm
.idea/

@ -1,3 +1,25 @@
# runcible-metabot
A Keybase chat bot for use in Drone.io pipelines for notifications.
## Instructions
There is an official Docker Image for Keybase clients
https://hub.docker.com/r/keybaseio/client
[New bot signup workflow](https://gist.github.com/androiddrew/df2e13d63dfd5b4e1d8f19c063ce6654)
## Docker
### Building the image
Run from the root directory
```
docker build -f ./docker/Dockerfile -t runcible/runcible-metabot .
```
### Running the container
```
docker run --rm -e KEYBASE_USERNAME="spoonbot" -e KEYBASE_PAPERKEY="$KEYBASE_PAPERKEY" -it runcible/runcible-metabot
```

@ -0,0 +1,18 @@
FROM keybaseio/client:5.7.0-20210126121847-cfdcb9f95f-python-slim
LABEL maintainer="Drew Bednar <drew@runcible.io>"
# Set the working dir
WORKDIR /app
# Copy over requirements
COPY requirements.txt /app
# Install any needed dependencies
RUN pip install --trusted-host pypi.python.org -r requirements.txt
# Copy over the code now
COPY metabot/ /app
RUN chown -R keybase:keybase /app
# Run bot.py when the container launches
CMD ["python3", "-m","bot.py"]

@ -0,0 +1,5 @@
FROM keybaseio/client
ENV KEYBASE_SERVICE=1
COPY bot.sh /bot.sh
RUN chmod +x /bot.sh
CMD /bot.sh

@ -0,0 +1,13 @@
# Samplebot
```
docker build -t runcible/samplebot .
```
```
docker run --rm \
-e KEYBASE_USERNAME="spoonbot" \
-e KEYBASE_PAPERKEY="$KEYBASE_PAPERKEY" \
-e KEYBASE_SERVICE="1"\
-e CHAT_TARGET="androiddrew" -it runcible/samplebot
```

@ -0,0 +1,3 @@
#!/usr/bin/env bash
MSG="sending at $(date)"
keybase chat send $CHAT_TARGET "$MSG"

@ -0,0 +1,43 @@
###################################
# WHAT IS IN THIS EXAMPLE?
#
# This bot listens to two channels for a special text message. When
# it sees this message, it replies in the same channel with a response.
# This also shows sending and receiving unicode characters.
###################################
import asyncio
import logging
import os
import pykeybasebot.types.chat1 as chat1
from pykeybasebot import Bot
logging.basicConfig(level=logging.DEBUG)
class Handler:
async def __call__(self, bot, event):
if event.msg.content.type_name != chat1.MessageTypeStrings.TEXT.value:
return
if event.msg.content.text.body == "🌴ping🌴":
channel = event.msg.channel
await bot.chat.send(channel, "🍹PONG!🍹")
listen_options = {
"filter-channels": [
{"name": "spoonbot,androiddrew"},
# {
# "name": "runcibleio",
# "topic_name": "general",
# "members_type": "team",
# },
]
}
bot = Bot(
username="spoonbot", paperkey=os.environ["KEYBASE_PAPERKEY"], handler=Handler()
)
asyncio.run(bot.start(listen_options))

@ -0,0 +1 @@
pykeybasebot

@ -0,0 +1,26 @@
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile requirements.in
#
dataclasses-json==0.3.8
# via pykeybasebot
marshmallow-enum==1.5.1
# via dataclasses-json
marshmallow==3.10.0
# via
# dataclasses-json
# marshmallow-enum
mypy-extensions==0.4.3
# via typing-inspect
pykeybasebot==0.2.1
# via -r requirements.in
stringcase==1.2.0
# via dataclasses-json
typing-extensions==3.7.4.3
# via
# pykeybasebot
# typing-inspect
typing-inspect==0.6.0
# via dataclasses-json
Loading…
Cancel
Save