Skip to content

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

Notifications You must be signed in to change notification settings

iurysza/twitter-telegram-bot

Repository files navigation

Twitter video downloader bot

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

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()
}

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages