Comments (3)
You can parse the message to HTML and then extract links using regexp or the Cheerio DOM parser.
Example:
import {HTMLParser} from 'telegram/extensions/html';
import * as cherrio from 'cheerio';
const html = HTMLParser.unparse(message, entities);
const $ = cherrio.load(html);
// => Work with DOM like jQuery to extract your links
// => $("a:contains('Your Anchor')").attr("href");
from gramjs.
See Message entities
from gramjs.
switch (history.className) {
case "messages.ChannelMessages":
for (const message of history.messages) {
switch (message.className) {
case "Message":
for (const entity of message.entities || []) {
switch (entity.className) {
case "MessageEntityUrl":
const url = message.rawText.slice(entity.offset, entity.offset + entity.length)
console.log(url)
break
}
}
}
}
}
from gramjs.
Related Issues (20)
- getChatHistory - Exceeding 100 Messages Limit in Chat History Retrieval?
- How to listen to new messages on a specific channel? HOT 1
- Idea: add fool protection in "start" function to avoid accidental ban for flood
- Re-connectiong an authorized user with string session does not work
- Π‘an't get messages using offsetDate that were sent before being added to the telegram group
- EventHandler triggered by some channels and not from some others HOT 1
- Option useIPV6 not working
- Implement requestSimpleWebView HOT 1
- The account gets banned immediately after running the sample code HOT 3
- Support http links in parseUsername? HOT 1
- TIME_INVALID and other time_ms related errors returned for InputGroupCallStream HOT 1
- How to reduce inbound or outbound data transfer
- RPCError: 400: FILTER_ID_INVALID (caused by messages.UpdateDialogFilter) HOT 1
- [Disconnecting...] multiple times??
- How to get the information of the telegram group using name? HOT 1
- How to create a public group using this? HOT 1
- How to kick a user from a group. HOT 1
- NewMessage event not working for majority of channels all of a sudden HOT 7
- How to open webview app HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gramjs.