Telegram API Custom Emoji sending in message - telegram

As described in api doc for telegram - i can send custom emoji in message.
As update i receive somethings like this:
"text": "🌈",
"entities": [
{
"offset": 0,
"length": 2,
"type": "custom_emoji",
"custom_emoji_id": "5404870433939922908"
}
]
But when i'm sending same thing as message i see simple emoji:
{
"chat_id": 123,
"text": "🌈",
"entities": [
{
"offset": 0,
"length": 2,
"type": "custom_emoji",
"custom_emoji_id": "5404870433939922908"
}
]
}
Have no idea what i'm doing wrong. Help, please.
trying to send custom emoji in message through api.

AFAIK custom emoji are a premium feature and bots can't use them.

Related

Transfer control with inline buttons in telegram (bots)

If you have a bot-generated in-line button in a chat, that inline button can be used to take you to a bot.
My question is - is the reverse possible?
Can the bot have an inline button (when directly communicating with it) and it can transfer control to a group where the user and bot are both present
Consider this scenario:
I have a bot that track country names. When added to a group it detects a country name and says “see information about the country”.
When you click the button, the bot takes you to a chat with it (changes wondows and moves you out) and then the bot displays information about the country.
The bot then has a “go back or cancel” inline button.
If you click that button, it should take you BACK to the originating group you came from. Is that possible?
Variation:
Can it move you back to the originating group automatically (without an inline button) but say based on some text you type?
All I got is you wanna to take back your users to their refer place right?
For example you have "Back" button in your channel. If user came from Channel A you want to detect that when it clicks on Back button you want to take it back to Channel A.
No it's not possible. Telegram bots can't track user activity like this. But Telegram do itself. For example if you visit some channels like this:
Channel A => First Post => Go to another channel (Channel B) => Then go to admin profile
If you click Back button triple time you will go to first step which in this case is Channel A
Bot if your bot is in one private group or private channel you can get the link of every message because Telegram added this feature here :
you can now copy links to messages in private groups and channels – just like you could with public messages.
So if user mention your bot's username on any message in private group/channel you can get the link of that message. Here is some example :
{
"ok": true,
"result": [{
"update_id": 954197936,
"message": {
"message_id": 188,
"from": {
"id": 223110107,
"is_bot": false,
"first_name": "Ğąme ",
"last_name": "Ǿver!",
"username": "GameO7er",
"language_code": "en"
},
"chat": {
"id": -1001241538300,
"title": "Game Over Test Group",
"type": "supergroup"
},
"date": 1576312634,
"reply_to_message": {
"message_id": 130,
"from": {
"id": 156878147,
"is_bot": false,
"first_name": "Carlos F",
"username": "#Carlos****",
"language_code": "en"
},
"chat": {
"id": -1001241538300,
"title": "Game Over Test Group",
"type": "supergroup"
},
"date": 1554783715,
"text": "Hello Game Over!"
},
"text": "#Go***bot",
"entities": [{
"offset": 0,
"length": 10,
"type": "mention"
}]
}
}]
}
The link of this message is:
https://t.me/c/1241538300/130
As you can see it will be generate from chat id
"chat": {
"id": -1001241538300,
"title": "Game Over Test Group",
"type": "supergroup"
},
remove -100 from -1001241538300 then you have 1241538300 and contact /c/message_id to end of it.
"date": 1576312634,
"reply_to_message": {
"message_id": 130,
"from": {
"id": 156878147,
"is_bot": false,
"first_name": "Carlos F",
"username": "#Carlos****",
"language_code": "en"
},
and you will have :
https://t.me/c/1241538300/130

Not able to retrieve results from Open TSDB via HTTP

I have set up open TSDB using docker image. I am able to push data to database via HTTP post request.
[{
"metric": "sys.cpu.nice",
"timestamp": 1567764102,
"value": 18,
"tags": {
"host": "web01",
"dc": "lga"
}
},
{
"metric": "sys.cpu.abc",
"timestamp": 1567764602,
"value": 9,
"tags": {
"host": "web02",
"dc": "lga"
}
}
]
Same data is also visible on the portal but I want to retrieve this data form TSDB by API.
I used this but it's not returning actual data.
http://localhost:4242/api/search/lookup?m=sys.cpu.nice{host=*}
{
"type": "LOOKUP",
"metric": "sys.cpu.nice",
"tags": [{
"key": "host",
"value": "*"
}],
"limit": 25,
"time": 6.0,
"results": [],
"startIndex": 0,
"totalResults": 0
}
Could you please help to get data back from the database. I need to send this data to some other system.
Try using the /api/query endpoint
In your case you could try one of the following GET requests:
http://localhost:4242/api/query?m=sum:cmp.sys.db{host=server01,tenant01}&start=1h-ago
http://localhost:4242/api/query?m=zimsum:cmp.sys.db{host=server01,tenant01}&start=1h-ago

How to get channel updates with Telegram robot

I have searched over Telegram API and Bot API docs for days and it seems there is no direct way for a robot to get notified when there is a new update in a channel say a News channel, Sports channel, etc.
The only thing I came up with was:
A hook returns updates for channel only when the robot is an administrator member:
{
"update_id": 673009340,
"message": {
"message_id": 160,
"from": {
"id": 104911111,
"is_bot": false,
"first_name": "Jason",
"username": "jason",
"language_code": "en-US"
},
"chat": {
"id": -252946114,
"title": "jason",
"type": "group",
"all_members_are_administrators": true
},
"date": 1538468757,
"photo": [
{
"file_id": "AgADBAADFa4xG972mVHqJ-CSWQTFky4lnRoABNEgOrZpJU-OyDgFAAEC",
"file_size": 1795,
"width": 90,
"height": 90
},
{
"file_id": "AgADBAADFa4xG972mVHqJ-CSWQTFky4lnRoABB4OwmYVnYcOyTgFAAEC",
"file_size": 32559,
"width": 320,
"height": 320
},
{
"file_id": "AgADBAADFa4xG972mVHqJ-CSWQTFky4lnRoABIZfLEHYC_NVyjgFAAEC",
"file_size": 159833,
"width": 770,
"height": 770
}
]
}
}
I know that I cannot add a robot to a channel that is not owned by me. But, I can add my username jason to almost any channel. So, is there a way I get my jason_bot to be notified when there's a new update available for jason?
Bots cannot interact with channels unless they are one of the administrators of the channel.
If you want to receive updates from some one else's channels you must act as a client user not a bot. If you join the channel as a member, you can easily receive updates. However, you can check for updates of any public channel without being a member. First, you resolve the channel #username and get (id, access_hash) pair. Then, you can access all messages, and manually check against your database if there is something new.

JSON API format in API-Platform

First of all I want to implement JSON API.
I follow tutorial on api platform and just like in example create entities and response is like
{
"links": {
"self": "/api/books"
},
"meta": {
"totalItems": 1,
"itemsPerPage": 30,
"currentPage": 1
},
"data": [
{
"id": "/api/books/1",
"type": "Book",
"attributes": {
"isbn": "9781782164104",
"title": "Persistence in PHP with the Doctrine ORM",
"description": "This book is designed for PHP developers and architects who want to modernize their skills through better understanding of Persistence and ORM.",
"author": "Kévin Dunglas",
"publicationDate": "2013-12-01T00:00:00+01:00",
"_id": 1
},
"relationships": {
"reviews": {
"data": [
{
"type": "Review",
"id": "/api/reviews/1"
}
]
}
}
}
]
}
My api_platform.yaml config
api_platform:
mapping:
paths: ['%kernel.project_dir%/src/Entity']
formats:
jsonapi:
mime_types: ['application/vnd.api+json']
So i have problem with id filed in data. I get id fields in format api/entityName/id but I just want to get number(string), just like in JSON API. So is there some configuration that i miss or is any way to achieve that
It was discussed here.
You need to use Normalizer or create custom getter.
All you need is to send
Accept: application/json
on request header.

how to get linkedin page views count through rest api

In linkedin how can we get the page views count through API. There is no API for this in developer document, if any idea please share.
Try "Get statistics for a company page" using LinkedIn REST API.
https://developer.linkedin.com/docs/company-pages#statistics
"statusUpdateStatistics": {
"viewsByMonth": {
"_total": 1,
"values": [
{
"clicks": 81333,
"comments": 1203,
"date": {
"month": 1,
"year": 2015
},
"engagement": 0.003203537929382338,
"impressions": 32797489,
"likes": 20387,
"shares": 2145
}
]
}

Resources