Skip to content

Commit

Permalink
more correction to instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Feb 28, 2018
1 parent 537d351 commit 71609aa
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
24 changes: 15 additions & 9 deletions chatbot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,32 @@ python -m grpc_tools.protoc -I../pbx --python_out=. --grpc_python_out=. ../pbx/m

### Using Docker

1. Follow [instructions](../docker/README.md) to build and run dockerized Tinode chat server up to an including step 3.
1. Follow [instructions](../docker/README.md) to build and run dockerized Tinode chat server up to an including _step 4_.

2. In step 4 add the following parameter to the command line `--vol botdata:/botdata`. It will create and mount a volume `botdata` where Tino's (chatbot's) credentials are stored.
2. In the _step 5_ add the following parameter to the command line: `--volume botdata:/botdata`. It will create and mount a volume `botdata` where Tino's (chatbot's) credentials are stored.
```
docker run --rm --name tinode-init-db --network tinode-net --volume botdata:/botdata tinode-init-db
```

3. Run Tinode server with the following command:
3. In the _step 6_ add the following parameter to the command line: `--env PLUGIN_PYTHON_CHAT_BOT_ENABLED=true`. For instance, for MySQL the buld command will like like this:
```
$ docker run -p 6060:18080 -d --name tinode-srv --network tinode-net --env PLUGIN_PYTHON_CHAT_BOT_ENABLED=true tinode-srv
$ docker build --tag=tinode-srv --build-arg TARGET_DB=mysql tinode-server
```

4. If this folder is `chat/chatbot`, then the Dockerfile is located in `chat/docker/chatbot` folder; `cd ../docker` and build the chat bot image
4. Run the Tinode server according to _step 7_.


5. If this folder is `chat/chatbot`, then the Dockerfile is located in `chat/docker/chatbot` folder; `cd ../docker` and build the chat bot image
```
$ docker build --tag=tinode-bot chatbot
```

5. Run the chatbot
6. Run the chatbot
```
$ docker run -d --name tinode-bot --network tinode-net --vol botdata:/botdata tinode-bot
$ docker run -d --name tinode-bot --network tinode-net --volume botdata:/botdata tinode-bot
```

6. Test that the bot is functional by pointing your browser to [http://localhost:6060/x/](http://localhost:6060/x/), login and talk to user `Tino`. The user should respond to every message with a random quote.
7. Test that the bot is functional by pointing your browser to [http://localhost:6060/x/](http://localhost:6060/x/), login and talk to user `Tino`. The user should respond to every message with a random quote.


### Building from Source
Expand All @@ -58,7 +64,7 @@ nohup python chatbot.py --login-basic=alice:alice123 &
```
Run `python chatbot.py -h` for more options.

If you are using python 2.7, keep in mind that `condition.wait()` [is buggy](https://bugs.python.org/issue8844). It ignores SIGINT. As a consequence of this bug the bot cannot be terminated with a SIGINT. It has to be stopped with a SIGKILL.
If you are using python 2.7, keep in mind that `condition.wait()` [is forever buggy](https://bugs.python.org/issue8844). As a consequence of this bug the bot cannot be terminated with a SIGINT. It has to be stopped with a SIGKILL.

You can use cookie file to store credentials. Sample cookie files are provided as `basic-cookie.sample` and `token-cookie.sample`. Once authenticated the bot will attempt to store the token in the cookie file, `.tn-cookie` by default. If you have a cookie file with the default name, you can run the bot with no parameters:
```
Expand Down
9 changes: 9 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@

8. Test the installation by pointing your browser to [http://localhost:6060/x/](http://localhost:6060/x/).

## Optional

### Resetting the data

If you want to reset the data in the database, shut down the server container
```
$ docker stop tinode-srv
Expand All @@ -70,3 +74,8 @@ then repeat step 5 then restart the server
```
$ docker start tinode-srv
```

### Running the chatbot

See [instructions](../chatbot/).

3 changes: 1 addition & 2 deletions docker/init-db/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ RUN go get -tags $TARGET_DB github.com/tinode/chat/tinode-db \

COPY config.template /
COPY entrypoint.sh /
COPY credentials.sh /

RUN chmod +x /entrypoint.sh
RUN chmod +x /credentials.sh
RUN chmod +x /go/src/github.com/tinode/chat/tinode-db/credentials.sh

RUN mkdir /botdata

Expand Down
2 changes: 1 addition & 1 deletion docker/init-db/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ done < /config.template
/go/bin/tinode-db --reset --config=/config --data=/go/src/github.com/tinode/chat/tinode-db/data.json | grep "usr;tino;" > /botdata/tino-password

# Convert Tino's authentication credentials into a cookie file.
/credentials.sh < /botdata/tino-password > /botdata/.tn-cookie
/go/src/github.com/tinode/chat/tinode-db/credentials.sh < /botdata/tino-password > /botdata/.tn-cookie

0 comments on commit 71609aa

Please sign in to comment.