Skip to content

Commit

Permalink
Add Readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
LikiPiki committed Dec 14, 2021
1 parent b6d6f43 commit bd71f72
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
9 changes: 9 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Telegram bot for ["Фронтенд Юность"](https://t.me/frontend_u) chat

## Building
```bash
gradle build
```

## Authors:
@immorte, @likipiki
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Wed May 06 02:55:56 MSK 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
18 changes: 16 additions & 2 deletions src/main/kotlin/Commands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ import com.github.kotlintelegrambot.Bot
import com.github.kotlintelegrambot.entities.InlineQuery
import com.github.kotlintelegrambot.entities.inlinequeryresults.InlineQueryResult
import com.github.kotlintelegrambot.entities.inlinequeryresults.InputMessageContent
import com.github.kotlintelegrambot.entities.Message
import com.github.kotlintelegrambot.entities.Update
import com.github.kotlintelegrambot.entities.ChatId
import com.github.kotlintelegrambot.entities.User
import services.soundcloud.AllPodcasts
import services.telegram.Message
import services.telegram.Service
import services.telegram.Message as ServiceMessage

/**
* The inline query mode, which provide podcast sharing to the chats
*/
fun handleInlineQuery(bot: Bot, iq: InlineQuery, podcastsTitles: AllPodcasts?) {
val queryText = iq.query.toLowerCase()
if (queryText.isBlank() || queryText.isEmpty() || podcastsTitles == null) return
Expand All @@ -17,7 +24,7 @@ fun handleInlineQuery(bot: Bot, iq: InlineQuery, podcastsTitles: AllPodcasts?) {
id = podcast.title,
title = podcast.title,
inputMessageContent = InputMessageContent.Text(
Message.podcastMessage(podcast, true),
ServiceMessage.podcastMessage(podcast, true),
parseMode = Service.PARSE_MODE
),
description = "Найдено"
Expand All @@ -26,3 +33,10 @@ fun handleInlineQuery(bot: Bot, iq: InlineQuery, podcastsTitles: AllPodcasts?) {

bot.answerInlineQuery(iq.id, list)
}

/*
* Spam bots checker and banner
*/
fun handleNewChatMembers(bot: Bot, update: Update, message: Message, newChatMembers: List<User>) {
bot.sendMessage(chatId = ChatId.fromId(message.chat.id), text = "Привет додя!")
}
3 changes: 3 additions & 0 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ fun main() = runBlocking {
dispatch {
inlineQuery { bot, iq ->
handleInlineQuery(bot, iq, soundCloudWatcher.allPodcastsTitles)
};
newChatMembers { bot, update, message, newChatMembers ->
handleNewChatMembers(bot, update, message, newChatMembers)
}
}
}
Expand Down

0 comments on commit bd71f72

Please sign in to comment.