Skip to content

Commit bd71f72

Browse files
committed
Add Readme file
1 parent b6d6f43 commit bd71f72

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

Readme.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Telegram bot for ["Фронтенд Юность"](https://t.me/frontend_u) chat
2+
3+
## Building
4+
```bash
5+
gradle build
6+
```
7+
8+
## Authors:
9+
@immorte, @likipiki

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Wed May 06 02:55:56 MSK 2020
2-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-all.zip
2+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
33
distributionBase=GRADLE_USER_HOME
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists

src/main/kotlin/Commands.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@ import com.github.kotlintelegrambot.Bot
22
import com.github.kotlintelegrambot.entities.InlineQuery
33
import com.github.kotlintelegrambot.entities.inlinequeryresults.InlineQueryResult
44
import com.github.kotlintelegrambot.entities.inlinequeryresults.InputMessageContent
5+
import com.github.kotlintelegrambot.entities.Message
6+
import com.github.kotlintelegrambot.entities.Update
7+
import com.github.kotlintelegrambot.entities.ChatId
8+
import com.github.kotlintelegrambot.entities.User
59
import services.soundcloud.AllPodcasts
6-
import services.telegram.Message
710
import services.telegram.Service
11+
import services.telegram.Message as ServiceMessage
812

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

2734
bot.answerInlineQuery(iq.id, list)
2835
}
36+
37+
/*
38+
* Spam bots checker and banner
39+
*/
40+
fun handleNewChatMembers(bot: Bot, update: Update, message: Message, newChatMembers: List<User>) {
41+
bot.sendMessage(chatId = ChatId.fromId(message.chat.id), text = "Привет додя!")
42+
}

src/main/kotlin/Main.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ fun main() = runBlocking {
2929
dispatch {
3030
inlineQuery { bot, iq ->
3131
handleInlineQuery(bot, iq, soundCloudWatcher.allPodcastsTitles)
32+
};
33+
newChatMembers { bot, update, message, newChatMembers ->
34+
handleNewChatMembers(bot, update, message, newChatMembers)
3235
}
3336
}
3437
}

0 commit comments

Comments
 (0)