[APP][Pro] Telegram

Not sure, never looked into it. Once I have my Homey I can take a look into it.

You’re the first one that did something like this :slight_smile: Thank you for sharing!

2 Likes

@spkesDE, you might have gotten a message or two from me for crashing my Telegram Notifications app :rofl:

I was looking around in the settings of your app, and I noticed that you store the questions as part of the app settings.

let setting = await Homey.apps.getAppSetting({id:'com.spkes.telegramNotifications',name:'questions'});
console.log(setting);

It all went wrong when I tried to use the setAppSetting :innocent:

DONT USE THIS LINE OF CODE AS IT WILL CRASH TELEGRAM NOTIFICATIONS
await Homey.apps.setAppSetting({id:'com.spkes.telegramNotifications',name:'questions',value:[{"question":"Test","UUID":"The_UUID_as_shown_in_the_app_for_this_question","buttons":["A","B"],"keepButtons":false,"disable_notification":false}]})
DONT USE THIS LINE OF CODE AS IT WILL CRASH TELEGRAM NOTIFICATIONS

I re-installed the app and all is working again :innocent:

1 Like

Yes, i do as a JSON. You fucked up the Json :smiley:

Unable to initialize app SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse ()

Structure should be

    question: string = "";
    UUID: string = "";
    buttons: string[] = [];
    keepButtons: boolean = false;
    disable_notification: boolean = false;
[
  {
    "question": "test",
    "UUID": "asdata45arfsa",
    "buttons": [
      "Yes",
      "No",
      "Maybe"
    ],
    "keepButtons": false,
    "disable_notification": false
  },
  {
    "question": "test",
    "UUID": "asdata45arfsa",
    "buttons": [
      "Yes",
      "No",
      "Maybe"
    ],
    "keepButtons": false,
    "disable_notification": false
  }
]

I know I did :rofl:

After some more fiddling, I can now edit the answers of any question in the Telegram Notification app with a simple flow.

//Arguments {"question":"Test","answers":["A","B"]}
let myArgs = JSON.parse(args[0]);

let question = myArgs.question;
let answers = myArgs.answers;

let setting = await Homey.apps.getAppSetting({id:'com.spkes.telegramNotifications',name:'questions'});

let telegram_json = await JSON.parse(setting);
_.forEach(telegram_json, x => {
        if (x.question==question){
          x.buttons=answers
        }
    });

await Homey.apps.setAppSetting({
    id:'com.spkes.telegramNotifications',
    name:'questions',
    value:JSON.stringify(telegram_json)
    })

Please note, there’s zero error checking, I will add those later.

1 Like

Is it possible to use text-styling in messages? Like bold and italic?

In the app Telegram Bot I use it very often (stars for bold, underscores for italic) to mark important parts of my messages or make clear that is only information. Can’t find the option so far…

I was used to Telegram Bot, but liked the idea of questions of this app, so I installed it and now I f*cked my Telegram Bot :rofl: :rofl:

If the default messages markdown is not working I would have to take a look into. Since I don’t have a Homey Pro currently, it has to wait till I have mine again. Also I have quite a bunch of stuff on my todo list.

Bold => <b>bold</b>, <strong>bold</strong>, **bold**
Italic => <i>italic</i>, <em>italic</em> *italic*
Code => <code>code</code>, `code`
Strike => <s>strike</s>, <strike>strike</strike>, <del>strike</del>, ~~strike~~
Underline => <u>underline</u>
Pre => <pre language="c++">code</pre>,

Edit: Markdown support should be added with the next version. already done, needs testing. (Can’t be done from someone else, since there are some big changes on the telegram api)

2 Likes

Just tested the codes, none of them work, as you mentioned already.
Is it in the test-version allready?

No, local on my pc only since it has to be tested from my side first since it has huge changes on many bits. You have sadly to wait till I get my developer Homey Pro 2023. So hopefully mid/end January

1 Like

@spkesDE,

How much control do we have on the text on the buttons? I have quite a bit of text, and the text is being truncated.

Can we force wordwrap or use large buttons (like the last button) for all the answers?

About Word warp I’m not quite sure. It can be possible but I would have to test it, but my guts says that telegram will not allow it.

What I could offer is to make a option to the questions, where you can select the columns. But I have a quite long todo list with the app, so it will take a couple of weeks.

Edit:
Just a untested version of the change.

1 Like

Hi, thanks for this app.
I don’t know what I’m missing, but I seem not be able to start.
I created a telegram bot and added the token, which lights up green. I wrote my bot /start, but there aren’t any instructions going further in the chat and I can’t find a user to send a message to.

It’s just me using it.
What am I doing wrong here?

Are you writing the bot in private or in a group?
Are you using the test version or the live version?
Could you send me a diagnostic report?

Making good progress to implement all the planned changes :slight_smile:
Running in some issues with Markdown but I’ll find a way

2 Likes

A new test version is available!

Changes:

  • New Design
  • New Settings Page design
  • BLL Support
  • Custom ID’s for questions as @JB2K asked for it :slight_smile:
  • Delete messages by ID (Bot needs the permissions for it though if its a different message sender)
  • The ability to change the columns of buttons for each question (@Hamster requested this! Thank you for the great idea)
  • Added Timestamp to the Message received cards
  • Added a Message is received from chat card
  • Code enhancements :tada:
  • Updated dependencies

Planed:

  • Support for topics
  • MarkdownV2 support

Please report issues at the issues section on Github otherwise in this topic.

5 Likes

Woop Woop

1 Like

Telegram 2.2.0 is now live!

Changes

  • New Design
  • New Settings Page design
  • Custom ID’s for questions
  • Delete messages by ID (Bot needs the permissions for it though if its a different message sender)
  • Delete messages by ID & ChatId
  • The ability to change the columns of buttons for each question
  • Added Timestamp to the Message received cards
  • Added a Message is received from chat card
  • Code improvements
  • Updated dependencies

Breaking Changes

  • BLL support is currently deactivated. Will be reenabled once WebAPI is fixed on the Homey Pro 2023
2 Likes

@spkesDE Homey Pro 2023: I’m trying to send images from an image tag, but it doesn’t work.

Depending on the kind of image tag I’m using, these are the errors:

Image tag from the standard Homey Virtual Camera devices:

Image tag from a Homey Gallery image:

Any idea what the problem could be?

I’ll check this out. Most likely there is no cloud URL.

Could you use the latest test version?

And send a Image Tag card without text! and create a diagnostic report?

I can’t get image tags to work on my HP2023 right now.