anhbh310 / gotify2telegram

MIT License
22 stars 4 forks source link

Plugin directory location? #4

Closed moorsey closed 3 months ago

moorsey commented 3 months ago

Morning

I'm struggling with the limited docs from gotify around plugin install.

I am running in docker and have "/app/data" mounted to a folder on my local filesystem. Gotify is running fine with browser notifications

Do I make a folder inside /data called "plugin" then pop the .so file in there? I did try and guessed something might show on the Plugins page via the web, but no joy. Tried "plugins" for the folder name also.

Second question. The readme here says to set a secrets file, what should this be named?

Sorry if I'm way off base, finding it hard to know how to make this work!

Many thanks

anhbh310 commented 3 months ago

Hello @moorsey

When you successfully mount a folder from your host to the container, the Gotify container will automatically create a plugin sub-folder. Then, simply place the .so file into it. Your mounted folder will look like this:

image

If you still cannot set up the plugin, please provide your container log here so I can assist you more easily.

Regarding your second question, secrets need to be set as environment variables. If you set up Gotify using the Docker command, you can add environment variables using the -e option. Here is an example:

docker run -p 80:80 -v /var/gotify/data:/app/data gotify/server 
      -e GOTIFY_HOST=<YOUR_GOTIFY_HOST_VALUE> 
      -e GOTIFY_CLIENT_TOKEN=<YOUR_GOTIFY_CLIENT_TOKEN_VALUE> 
      -e TELEGRAM_CHAT_ID=<YOUR_TELEGRAM_CHAT_ID_VALUE> 
      -e TELEGRAM_BOT_TOKEN=<YOUR_TELEGRAM_BOT_TOKEN_VALUE>
moorsey commented 3 months ago

Thank you very much for pointing me in the right direction on this. Makes more sense.

I had actually mis-typed my path for the mount, so had not seen the auto created directories!

Now have entries in the "Apps" and "Plugins" tabs on Gotify, made my Telegram bot and re-spun the container with environmental entries. Gotify is getting messages, but telegram is not.

Just checking I have the entries right, as I must admit, this took me a while to get my head around also:

-e GOTIFY_HOST=ws://localhost:80 -e GOTIFY_CLIENT_TOKEN=Token copied from the auto created Gotify Plugins tab, Telegram entry -e TELEGRAM_CHAT_ID=ID from the curl API request -e TELEGRAM_BOT_TOKEN=API token ID the botfather gave you

I must have something wrong, becuase as soon as I enable the plugin via the web interface, the container starts using 300% CPU and spams the logs with:

2024-07-08T07:50:01+01:00 | 401 |     122.499µs |             ::1 | GET      "/stream?token=[masked]"
Error #01: you need to provide a valid access token or user credentials to access this api
Cannot connect to websocket: websocket: bad handshake

Thanks again

moorsey commented 3 months ago

Ignore, I needed to create a new client the the GOTIFY_CLIENT_TOKEN of course

Not sure what the plugin token is ever used for in that case?

Anyway, sorted

Another note, if anyone reads this, if your API call is bringing back no data, go back to botfather and change the privacy settings for your new bot, otherwise this won't work. This appears to be the default now

Many thanks @anhbh310

jtitley commented 2 weeks ago

@anhbh310 Can I respectfully ask that the installation instructions get updated to be more thorough? I think that will go a long way to help especially for those new to gotify. I appreciate this work as it is precisely what I was looking for, thank you!

This is what I had to do.

  1. The plugin needs to be installed in the gotify app/plugins directory. On the docker host cd to that directory and sudo wget https://github.com/anhbh310/gotify2telegram/releases/download/v1.1.1/telegram-plugin-linux-amd64.so
  2. The plugin may not be enabled in gotify. Even though the logs recognise the plugin, it won't work if it's disabled. User needs to check and enable in gotify UX under plugins.
  3. There is no need to create an app, it's automatic from the plugin.
  4. The Application sending messages needs to use the token from the automatically created Gotify 2 Telegram app
  5. You should generate a new client specifically for Telegram
  6. GOTIFY_CLIENT_TOKEN= { Token of this new client }
  7. Changing group security does not seem to be necessary

In terms of getting TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID, in telegram MSG @BotFather and create a new bot. Note the token it provides.

Now Create a Group Chat. Go back to the BotFather chat and click on a link for your new bot as if you are going to send a message. But instead, add the bot to a group and select the group you created.

Lastly, navigate to: https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/getUpdates and note the chat_id in the JSON. Use that for TELEGRAM_CHAT_ID

You COULD use a getID bot to get YOUR ID and have a 1:1 conversation with the bot and you, but having a group is nicer because you can add friends to the group, and they will get the updates.

I hope for others this proves helpful.