Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discord]: bot not listening in room? #121

Closed
huang-jy opened this issue Dec 27, 2019 · 17 comments · Fixed by #123
Closed

[Discord]: bot not listening in room? #121

huang-jy opened this issue Dec 27, 2019 · 17 comments · Fixed by #123
Labels
bug Something isn't working discord discord remote specific enhancement New feature or request

Comments

@huang-jy
Copy link

Report

Bot seemingly not listening on room in Discord

(Appreciate Discord is still showing as WIP, so if this is something that is still being worked on, please feel free to close this issue)

What did you do?

Followed https://target.github.io/flottbot-docs/basics/discord/ to setup bot and got it added to a test server.

It shows up as online, and I can directly interact with the bot and it responds to rules (such as the hello.yml one in the example docs)

However, the bot does not seem to respond to triggers on the room it is sitting in. For example, if I use the trigger hello in a DM, it responds happily. But if I do it in the room, it doesn't.

I also added the announce.yml example (/~https://github.com/target/flottbot/blob/master/config-example/rules/announce.yml) and when I run it on a DM, I see this on the bot's logs:

time="2019-12-27T11:12:23Z" level=debug msg="Found rule match 'announce' for input 'announce test'"
time="2019-12-27T11:12:23Z" level=debug msg="Room 'general' does not exist"
time="2019-12-27T11:12:23Z" level=error msg="Could not find any of the rooms specified in 'output_to_rooms' while 'direct_message_only' is set to false. Please check rule 'announce'"

Trying different variations (e.g. '#general', 'general', "general") didn't help. It's like the bot can't see the channel, even though it is inside the server.

What did you expect to happen?

The bot should respond to triggers on the channel, unless otherwise excluded

What happened instead?

The bot did not listen to triggers on the channel

Screenshots

N/A

Your Environment

  • Flottbot version: Docker image target/flottbot:latest
  • OS: Linux
  • OS version: 19
  • Bot YAML (see below)
  • Rule YAML (see below) if applicable
chat_application: discord
discord_token: [CUT]

name: bfbot
debug: true

hello.yml

# metadata
name: hello
active: true
respond: hello
format_output: "what's up?" # message to send to your user when they say hello
direct_message_only: false
help_text: hello
include_in_help: true

announce.yml

# meta
name: announce
active: true
# trigger and args
respond: announce
args:
  - message
# response
format_output: "${message}"
direct_message_only: false
output_to_rooms:
  - general
  - 'general'
  - '#general'
  
# help
help_text: announce <text>
include_in_help: true

Additional context

N/A

@wass3r
Copy link
Collaborator

wass3r commented Dec 28, 2019

Thanks for the report. We'll take a look and see what's going on.

@wass3r wass3r added bug Something isn't working discord discord remote specific enhancement New feature or request and removed bug Something isn't working labels Dec 30, 2019
@wass3r
Copy link
Collaborator

wass3r commented Dec 30, 2019

Did some digging and it looks like it's a two-part issue.

  1. Bot not responding in channel. This is a bug.
  2. Bot is not able to send message to specific channels via output_to_rooms. This is a side effect of discord being in WIP as you pointed out.

I have a fix for 1. and I'll see how much headway I can make on 2.

@huang-jy
Copy link
Author

Brilliant, thank you. :)

@huang-jy
Copy link
Author

huang-jy commented Feb 3, 2020

I've pulled the changes into my local repo and it still doesn't seem to work. I can see the changes in the code (e.g. the bit about the User Server Message ID), but my bot still won't respond on the channel.

@wass3r
Copy link
Collaborator

wass3r commented Feb 3, 2020

Interesting, I saw you commented on the docs site about whether the docker run command needed to be updated to pass in the new variable. Safe to presume that you did that with your test?

PS: also, thanks for testing!

@huang-jy
Copy link
Author

huang-jy commented Feb 3, 2020

Yup, did, which is why I realised it wasn't being passed in, hence my doc comment.

The variables seen inside the docker container (for me) are:

PATH
HOSTNAME
DISCORD_SERVER_ID
SLACK_TOKEN
DISCORD_TOKEN
HOME

I pass in:

DISCORD_SERVER_ID
SLACK_TOKEN
DISCORD_TOKEN

via docker run

and the bot still doesn't seen the #general room.

@wass3r
Copy link
Collaborator

wass3r commented Feb 3, 2020

But the bot is responsive (ie. it shows as online) and accepts commands.. is the issue limited to #general?

@wass3r wass3r reopened this Feb 3, 2020
@huang-jy
Copy link
Author

huang-jy commented Feb 3, 2020

Yes, the bot shows as online, responds to commands when you interact with it directly, but doesn't respond to room triggers or room mentions (yet shows as online inside the room), also the bot doesn't seem to realise it is inside the room, since when I try to use the announce trigger and make it send to the room, it says it can't find it -- like it doesn't even know it's already in there.

@wass3r
Copy link
Collaborator

wass3r commented Feb 3, 2020

ok, thanks.. i don't recall specifically trying with #general, but the room functionality seemed to work fine for me when i tested, so i will give it a couple more spins to see if i can replicate..

@wass3r
Copy link
Collaborator

wass3r commented Feb 4, 2020

so, i copied your rule verbatim (thanks for providing that) and am not having any issues.. works with just supplying - general for the room. curious, you said you got the changes locally. did you build a new docker image then and run that with the params per the docs? it seems the behavior matches with what i would suspect if the new code wasn't being honored, i think.

@huang-jy
Copy link
Author

huang-jy commented Feb 4, 2020

Yes, I did a git pull and everything. Let me try a clean git checkout

@wass3r
Copy link
Collaborator

wass3r commented Feb 4, 2020

i mean... you followed that by docker build -t <somenameyoupick> -f docker/Dockerfile .? Then, you would run that container instead of target/flottbot:latest.. so the full command would be: docker run --rm --name mybot --env DISCORD_TOKEN=$DISCORD_TOKEN --env DISCORD_SERVER_ID=$DISCORD_SERVER_ID -v "$PWD"/config:/config <somenameyoupick>:latest /flottbot .. replace <somenameyoupick> with whatever you want, of course. you would only have to do that until the updated image is released on dockerhub. in other words target/flottbot:latest still points to the old code

@huang-jy
Copy link
Author

huang-jy commented Feb 4, 2020

Ah, I was still using the image target/flottbot:latest.

@wass3r
Copy link
Collaborator

wass3r commented Feb 4, 2020

Yes, that makes sense. We need to update our release process to publish latest code to the :latest tag at some point. when we tag a release on github it would then push out versioned images (as it does now). so :latest would always match current master branch.

@huang-jy
Copy link
Author

huang-jy commented Feb 4, 2020

And now it works :)
Thanks for the help. Looks like I just needed to build my own docker image with the changes, and use that instead of the target/flottbot:latest I had in my startup script.

For reference:

export DISCORD_TOKEN=XXXXXXX
export SLACK_TOKEN=XXXXXXXX
export DISCORD_SERVER_ID=XXXXXXX

## Use these to pull latest official release
# docker run --rm --name mybot --env DISCORD_SERVER_ID=$DISCORD_SERVER_ID --env SLACK_TOKEN=$SLACK_TOKEN --env DISCORD_TOKEN=$DISCORD_TOKEN -v "$PWD"/config:/config target/flottbot:latest /flottbot

## Use these to use the version you have checked out in repo
docker build -t flottbot -f docker/Dockerfile .
docker run --rm --name mybot --env DISCORD_SERVER_ID=$DISCORD_SERVER_ID --env SLACK_TOKEN=$SLACK_TOKEN --env DISCORD_TOKEN=$DISCORD_TOKEN -v "$PWD"/config:/config flottbot /flottbot

@wass3r
Copy link
Collaborator

wass3r commented Feb 4, 2020

excellent. thanks for your patience! we feel more comfortable cutting a release now. probably in the next day or two. then you'll be able to use target/flottbot:latest! let us know if you encounter anything else. I will close this issue for now again.

@wass3r wass3r closed this as completed Feb 4, 2020
@huang-jy
Copy link
Author

huang-jy commented Feb 4, 2020

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working discord discord remote specific enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants