@@ -3,6 +3,7 @@ package com.github.livingwithhippos.unchained_bot
33import com.github.kotlintelegrambot.bot
44import com.github.kotlintelegrambot.dispatch
55import com.github.kotlintelegrambot.dispatcher.message
6+ import com.github.kotlintelegrambot.entities.ChatId
67import com.github.kotlintelegrambot.entities.ParseMode
78import com.github.kotlintelegrambot.extensions.filters.Filter
89import com.github.kotlintelegrambot.logging.LogLevel
@@ -125,24 +126,24 @@ class BotApplication : KoinComponent {
125126 dispatch {
126127
127128 message(helpCommandFilter and userFilter) {
128- bot.sendMessage(chatId = message.chat.id, text = helpMessage, parseMode = ParseMode .MARKDOWN )
129+ bot.sendMessage(chatId = ChatId .fromId( message.chat.id) , text = helpMessage, parseMode = ParseMode .MARKDOWN )
129130 }
130131
131132 message(startCommandFilter and userFilter) {
132133
133- val result = bot.sendMessage(chatId = update. message!! .chat.id, text = " Bot started" )
134+ val result = bot.sendMessage(chatId = ChatId .fromId( message.chat.id) , text = " Bot started" )
134135
135136 scope.launch {
136137 val user = getUser()
137138 if (user != null ) {
138139 val welcome = " Welcome back, ${user.username} \n " +
139140 " You have ${user.premium / 60 / 60 / 24 } days of premium " +
140141 " and ${user.points} points remaining."
141- bot.sendMessage(chatId = message.chat.id, text = welcome)
142+ bot.sendMessage(chatId = ChatId .fromId( message.chat.id) , text = welcome)
142143 } else
143144 // close the bot?
144145 bot.sendMessage(
145- chatId = message.chat.id,
146+ chatId = ChatId .fromId( message.chat.id) ,
146147 text = " Couldn't load your real debrid data\n Check your private api key."
147148 )
148149 }
@@ -162,10 +163,10 @@ class BotApplication : KoinComponent {
162163 " premium: ${user.premium / 60 / 60 / 24 } days\n " +
163164 " expiration: ${user.expiration} "
164165
165- bot.sendMessage(chatId = message.chat.id, text = information)
166+ bot.sendMessage(chatId = ChatId .fromId( message.chat.id) , text = information)
166167 } else
167168 bot.sendMessage(
168- chatId = message.chat.id,
169+ chatId = ChatId .fromId( message.chat.id) ,
169170 text = " Couldn't load your real debrid user data\n Check your private api key."
170171 )
171172 }
@@ -186,7 +187,7 @@ class BotApplication : KoinComponent {
186187 " *Link:* ${downloadItem.download} "
187188
188189 bot.sendMessage(
189- chatId = message.chat.id,
190+ chatId = ChatId .fromId( message.chat.id) ,
190191 text = itemMessage,
191192 parseMode = ParseMode .MARKDOWN
192193 )
@@ -201,7 +202,7 @@ class BotApplication : KoinComponent {
201202 " Added torrent with id ${addedMagnet.id} , check its status with /torrents"
202203
203204 bot.sendMessage(
204- chatId = message.chat.id,
205+ chatId = ChatId .fromId( message.chat.id) ,
205206 text = magnetMessage
206207 )
207208
@@ -213,18 +214,18 @@ class BotApplication : KoinComponent {
213214 val loaded = downloadTorrent(link)
214215 if (loaded)
215216 bot.sendMessage(
216- chatId = message.chat.id,
217+ chatId = ChatId .fromId( message.chat.id) ,
217218 text = " Uploading torrent to Real Debrid. Check its status with /torrents"
218219 )
219220 }
220221 else -> bot.sendMessage(
221- chatId = message.chat.id,
222+ chatId = ChatId .fromId( message.chat.id) ,
222223 text = " Wrong or missing argument.\n Usage: /unrestrict [url|magnet|torrent file link]"
223224 )
224225 }
225226 } else
226227 bot.sendMessage(
227- chatId = message.chat.id,
228+ chatId = ChatId .fromId( message.chat.id) ,
228229 text = " Wrong or missing argument.\n Usage: /unrestrict [url|magnet|torrent file link]"
229230 )
230231 }
@@ -244,15 +245,15 @@ class BotApplication : KoinComponent {
244245 """ .trimIndent()
245246
246247 bot.sendMessage(
247- chatId = message.chat.id,
248+ chatId = ChatId .fromId( message.chat.id) ,
248249 text = streamsMessage,
249250 parseMode = ParseMode .MARKDOWN
250251 )
251252 }
252253 }
253254 } else
254255 bot.sendMessage(
255- chatId = message.chat.id,
256+ chatId = ChatId .fromId( message.chat.id) ,
256257 text = " Wrong or missing argument.\n Usage: /stream [real debrid file id]"
257258 )
258259 }
@@ -262,13 +263,13 @@ class BotApplication : KoinComponent {
262263 // todo: restrict link to real debrid urls?
263264 if (args.isNotEmpty() && args[0 ].isNotBlank() && args[0 ].isWebUrl()) {
264265 bot.sendMessage(
265- chatId = message.chat.id,
266+ chatId = ChatId .fromId( message.chat.id) ,
266267 text = " Starting download"
267268 )
268269 " wget -P $downloadsPath $wgetArguments ${args[0 ]} " .runCommand()
269270 } else
270271 bot.sendMessage(
271- chatId = message.chat.id,
272+ chatId = ChatId .fromId( message.chat.id) ,
272273 text = " Wrong or missing argument.\n Usage: /download [unrestricted link]"
273274 )
274275 }
@@ -284,7 +285,7 @@ class BotApplication : KoinComponent {
284285 }
285286 } catch (e: NumberFormatException ) {
286287 bot.sendMessage(
287- chatId = message.chat.id,
288+ chatId = ChatId .fromId( message.chat.id) ,
288289 text = " Couldn't recognize number, defaulting to 5.\n Usage: /torrents [number, default 5]"
289290 )
290291 }
@@ -312,7 +313,7 @@ class BotApplication : KoinComponent {
312313 stringBuilder.append(" \n " )
313314 }
314315 bot.sendMessage(
315- chatId = message.chat.id,
316+ chatId = ChatId .fromId( message.chat.id) ,
316317 text = stringBuilder.toString(),
317318 parseMode = ParseMode .MARKDOWN
318319 )
@@ -331,7 +332,7 @@ class BotApplication : KoinComponent {
331332 }
332333 } catch (e: NumberFormatException ) {
333334 bot.sendMessage(
334- chatId = message.chat.id,
335+ chatId = ChatId .fromId( message.chat.id) ,
335336 text = " Couldn't recognize number, defaulting to 5.\n Usage: /downloads [number, default 5]"
336337 )
337338 }
@@ -346,7 +347,7 @@ class BotApplication : KoinComponent {
346347 stringBuilder.append(" \n " )
347348 }
348349 bot.sendMessage(
349- chatId = message.chat.id,
350+ chatId = ChatId .fromId( message.chat.id) ,
350351 text = stringBuilder.toString(),
351352 parseMode = ParseMode .MARKDOWN
352353 )
0 commit comments