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

[telegram] Add action that supports various options #17801

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

lsiepel
Copy link
Contributor

@lsiepel lsiepel commented Nov 24, 2024

Unfortunately the support for method overloads is limited in java. That together with the existing action methods makes it hard to add additional features to the action methods.

For instance, adding silent mode would add a double set of action methods. My proposal is to have one 'fat' method that had all possible combinations. Wether an option is used or not depends on the nullness.

Fixes: #8018 (Send message to multiple chats)
Fixes: #8487 (Send message without notification)
Fixes: #15040 (Send message with thread id)
Fixes: #15069 (Send message as reply to an existing message)

A test jar is here: https://1drv.ms/u/s!AnMcxmvEeupwjvsHyGFM4f3IfgiI-g?e=68LyRl

I would like to get feedback on:

  1. Should the parameter ChatIds be an array or string (comma seperated). The first is the best type but not supported by main UI. So maybe the string is the best user friendly one?
  2. Does the 'fat' method support enough option, or should we add more?
  3. Should we add some placeholders parameters to the method signature to create future compatiblity?

Signed-off-by: Leo Siepel <[email protected]>
Signed-off-by: Leo Siepel <[email protected]>
Signed-off-by: Leo Siepel <[email protected]>
Signed-off-by: Leo Siepel <[email protected]>
@lsiepel lsiepel added the enhancement An enhancement or new feature for an existing add-on label Nov 24, 2024
@lsiepel
Copy link
Contributor Author

lsiepel commented Nov 24, 2024

Unfortunately this action method does not show in main UI, according to @lolodomo this is because the Long[] is not supported. My tests from rule DSL fail:

2024-11-24 21:50:03.954 [ERROR] [.handler.AbstractScriptModuleHandler] - Script execution of rule with UID 'Test-1' failed: 'sendTelegramTo' is not a member of 'org.openhab.core.thing.binding.ThingActions'; line 8, column 3, length 77 in Test

With this test rule on openHAB 4.3.0 M4

rule "Test"
when Item testknop changed
then
		 val chatId = newArrayList()
		 chatIds.add(-123L);  //removed chat id here.
		 
		val telegramAction = getActions("telegram","telegram:telegramBot:lplxvi_bot")
		telegramAction.sendTelegramTo(chatId, "normal message", null, null, null, null)
end

@lsiepel
Copy link
Contributor Author

lsiepel commented Nov 24, 2024

@Skinah FYI
@openhab/add-ons-maintainers please provide some feedback when possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
1 participant