telegram-typings
telegram-typings copied to clipboard
SOVA-71 Upgrade typings to Bot API 4.4
https://core.telegram.org/bots/api
IssueHunt Summary
Backers (Total: $5.00)
-
sergeysova ($5.00)
Become a backer now!
Or submit a pull request to get the deposits!
Tips
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on IssueHunt to raise funds.
IssueHunt has been backed by the following sponsors. Become a sponsor
@sergeysova has funded $5.00 to this issue.
- Submit pull request via IssueHunt to receive this reward.
- Want to contribute? Chip in to this issue via IssueHunt.
- Checkout the IssueHunt Issue Explorer to see more funded issues.
- Need help from developers? Add your repository on IssueHunt to raise funds.
const nodes = document.getElementsByTagName('h4')
const types = Array.from(nodes).filter((node) => node.innerText.match(/^(?:[A-Z][a-z]+)+$/))
const methods = Array.from(nodes).filter((node) => node.innerText.match(/^[a-z]+(?:[A-Z][a-z]+)+$/))
types.map((el) => {
let comment = ''
let props = ''
let next = el
while (next.nextElementSibling.tagName === 'P') {
comment += next.innerText
next = next.nextElementSibling
}
const tableEl = next.nextElementSibling.tagName === 'TABLE' ? next.nextElementSibling : null
if (tableEl) {
props = Array.from(tableEl.children[1].children).map((tr) => {
const arr = Array.from(tr.children)
return arr.length
? arr[2].innerText.length > 72
? `
/**${arr[2].innerText.replace(/(.{1,72}\s)\s*?/g, '\n * $1')}
*/
${arr[0].innerText}${arr[2].innerText.startsWith('Optional.') ? '?' : ''}: ${arr[1].innerText.replace(/Array of (\w+)/, '$1[]')},
`
: `\n /** ${arr[2].innerText} */\n ${arr[0].innerText}${arr[2].innerText.startsWith('Optional.') ? '?' : ''}: ${arr[1].innerText.replace(/Array of (\w+)/, '$1[]')},\n`
: ''
}).join('')
}
return `
/**
* ${comment.replace(/(.{1,72}\s)\s*?/g, '\n * $1')}
*/
export type ${el.innerText} = {${props}}
`}).join('') + '\n\n' +
methods.map((el) => {
let comment = ''
let props = ''
let next = el
while (next.nextElementSibling.tagName === 'P') {
comment += next.innerText
next = next.nextElementSibling
}
const tableEl = next.nextElementSibling.tagName === 'TABLE' ? next.nextElementSibling : null
if (tableEl) {
props = Array.from(tableEl.children[1].children).map((tr) => {
const arr = Array.from(tr.children)
return arr.length
? arr[3].innerText.length > 72
? `
/**
* ${arr[3].innerText.replace(/(.{1,72}\s)\s*?/g, '\n * $1')}
*/
${arr[0].innerText}${arr[2].innerText === 'Optional' ? '?' : ''}: ${arr[1].innerText.replace(/Array of (\w+)/, '$1[]')},
`
: `\n /** ${arr[3].innerText} */\n ${arr[0].innerText}${arr[2].innerText === 'Optional' ? '?' : ''}: ${arr[1].innerText.replace(/Array of (\w+)/, '$1[]')},\n`
: ''
}).join('')
}
return `
/**
* ${comment.replace(/(.{1,72}\s)\s*?/g, '\n * $1')}
*/
export type ${el.innerText} = {${props}}
`}).join('')