I have an array of User IDs which I've set as admins and I would like to print them to clients when they call the /admins command.
The main issue is that I couldn't see or find a way to print a placeholder entity (it's mention in this case) which opens a chat window with the IDs I've specified.
Remember that when you post #username in a chat, Telegram simply binds it as a mention to the referenced user and it jumps on a chat window when you click on it. I wonder if there is an equivalent for #123456789, where the number represents the User ID.
if you create/send a message from a bot, you can set parse_mode to HTML, then send text/caption with HTML anchor tag same this:
for contact me, just click here
but if you want to send message as user, you can just use userName prefixed by #, and creating manual link to tg://user?id=123 or type plain text like tg://user?id=123, don't work in Telegram now. yes; just in iOS (less than 15% of Telegram user) that work since 2013!
Related
Is it possible to open a specific account with a preloaded text like this:
tg://resolve?domain={USER_NAME}&text=Hi, default message
https://t.me/{USER_NAME}?text=Hi, default message
There isn't (yet) a option to open a chat for a specific user, however, you can open the Telegram app, with an preloaded text, the user get's the option to pick a recipient from there chat list;
Use the following url;
tg://msg_url?url=Hi%21%20I%27m%20an%20example%21
Where;
url is the preloaded message (or link) (url-encoded)
After pressing the link, Telegram will ask for a recipent (picture).
If the user selects a chat from the sidebar, the preloaded text will be filled in the chat box (picture)
Im just learning AppMaker and I have followed along the tutorial on sending email https://developers.google.com/appmaker/tutorials/call-scripts/
It works as expected so I decided to bring it to another level by integrating it into my sign up form.
-- ISSUE OUTLINE --
A user enters their name and email in a standard signup form.
This is saved as expected this data is presented on the follow up page I created (see screenshot below)
When the admin clicks on the blue email button it opens up the email box (see attached image) and the users email is pulled into the To: box as expected (I have pulled the email by binding it to the text field).
The admin then sends the email which is sent as expected but then the form clears the To: field deleting it from the users entry.
-- QUESTION --
Can anyone advise on a solution it would be greatly appreciated :-)
Screenshot:
In the tutorial you mentioned, there is 'clearEmailForm' function that is called in case of successful sending email. I think you can delete code, that clears 'to' field:
/**
* Clears the entire email form
*/
function clearEmailForm(){
var formWidgets = app.pages.Email.descendants;
...
formWidgets.To.value = ""; // Delete this line
...
}
Many Telegram bots (e.g., #youtube) have a button you can click on to forward messages sent by the bot. When the user clicks on this button, Telegram opens a contact list that lets the user choose who to forward the message to.
How can I send a button like this? The closest thing I can find is forwardMessage but that expects chat_id target ID as a required parameter. But I won't have this target ID until the user selects who they want to forward to.
If you want to share your content to specific chats, you have 2 options:
Option 1
If your bot has inline_mode enabled you can share content via a button that opens a inline_query in the chat selected. Basically, this is how #youtube bot works. To use this method you need to send an inline button with switch_inline_query as a field (documentation).
Example in Javascript:
bot.sendMessage(msg.chat.id, 'Share:', {
reply_markup: {
inline_keyboard: [[{
text: 'Share with your friends',
switch_inline_query: 'share'
}]]
}
})
This is the same example I use in my bot #livecoinbot, set a bitcoin address and use the share button.
Option 2
You can create a normal inline button or just simply send a link in a normal message, that will prompt the telegram client to share the content. Here is how you do it:
https://t.me/share/url?url=[url-to-send-here]&text=[text]
Example: Click here
I am trying to build a bot that sends messages which embed a couple of standard replies which can be sent just by tapping on them.
Each link would contain a space - e.g. "/ack 20134" & "/pass 20134"
So tapping on the first link causes the text "/ack 20134" to be sent back to the bot.
How do I embed this into the message that I send from the bot to the client in text, HTML or Markup?
set that element (button text for example) text field to "/ack 20134" .Then when user hit the button this command will send to your bot. you can use inline keyboards and set its data incallback_data to this value. But you cannont use it a text message because space separates two fields(embeds just "/ack" i.e. command part. user can hit it but your bot just receives "/ack".)
For text messages there is another option: do not use space(e.g. "/ack20134" without space) and your bot's would receive "/ack20134", then you must parse commands part)
On my site, users can recieve notifications on different events (such as a new comments on a user's post). Users can view these notifications on a special page in their profile. I want when a user come to that page that he can distinguish new ("unread") notifications. Namely, I want the following behavior:
When a user comes to a notifications page, any notification that has never before been shown on that page, is highlighted.
If a user leaves that page and comes later, only the new notifications (that has appeared in the meantime) are highlighted.
Each notification is highlighted for as long as the user stays on the page.
If a new notification appears while the user is on page, it is immediately loaded and shown and highlighted.
If a notification changes and/or is removed while the user stays on the page, the page reflects this change (preferably keeping the highlight status).
I start with having a Notifications collection that has a read field showing whether this notification is "read" (i.e. has already been shown). Now I can highlight only notifications that has read set to false. However, it will not get the required behavior in a simple way.
The main problem is point 3, because I must somehow mark that the notification has been read, but have this mark be taken into account only on the next visit to page.
For example, I might try to set notification's read field to true on template render (for example, in Template.notification.rendered), but it will immediately force notification template update and the highlighting will be removed.
So the particular problem is how to keep the initial value of read property and not redraw the template on this property change?
(I thought also of different approach such as relying on some user-side event such as user leaving the page, and updating read only then, but this does not seem to be reliable.)
For now, I have implemented the following solution:
//// html
<template name='notification'>
<li class="list-group-item {{notificationClass}}">
...
</li>
</template>
//// coffee
Template.notification.helpers
notificationClass: ->
if (this.read && UI._templateInstance().wasRead)
undefined # no highlight
else
"list-group-item-info" # highlight
Template.notification.rendered = ->
this.wasRead = this.data.read
this.data.markAsRead() # ultimately updates the collection
that is, on rendered event I set the template property to remember whether this notification was read initially. This template property does not change as long as the template exists (and even if notification data changes, the template property is there). In template helper, instead of directly accessing the notification read property, I check template property.
This seems to work, but looks too complicated for me. So:
Are there any major disadvantages in this approach? For example, can template's rendered code be re-executed while a user stays on the page?
Is there some better approach for my problem?