An open API service indexing awesome lists of open source software.

https://github.com/iurysza/twitter-telegram-bot

A simple bot to download videos from twitter and send them to telegram
https://github.com/iurysza/twitter-telegram-bot

bot telegram twitter

Last synced: 8 months ago
JSON representation

A simple bot to download videos from twitter and send them to telegram

Awesome Lists containing this project

README

          

## Twitter video downloader bot

A simple bot to download videos from twitter and send them to telegram
```kotlin
fun main() {
val authData = AuthLoader.getAuthDataFrom("auth_data.json")
val filterParams = FilterParams(listOf(authData.twitterUserId),listOf("@MandaProZap"))

val twitterClient = TwitterClient(authData)
val telegramBot = bot { token = authData.telegramToken }

FilteredStatusStream(authData, filterParams) { newStatus ->
twitterClient.getStatusById(newStatus.inReplyToStatusId)
?.mediaEntities
?.mapNotNull { it.videoVariants.firstOrNull()?.url }
?.forEach { url ->
GlobalScope.launch {
FileDownloader.downloadAndWriteToFile(url)?.let { videoFile ->
telegramBot.sendVideo(authData.telegramUserId, videoFile)
}
}
}
}.start()
}
```