Make the user start redirected to the channel
How is the code to set this when the start starts the user is asked to join the channel first? https://api.telegram.org/bot[TOKEN]/getChatMember?chat_id=@[channelname]&user_id=[user_id
This is my start code
bot.start(async(ctx)=>{
msg = ctx.message.text
let msgArray = msg.split(' ')
console.log(msgArray.length);
let length = msgArray.length
msgArray.shift()
let query = msgArray.join(' ')
user ={
first_name:ctx.from.first_name,
userId:ctx.from.id
}
//welcoming message on /start and if there is a query available we can send files
if(length == 1){
ctx.reply(`${ctx.from.first_name} \n\nSaya akan menyimpan file untuk Anda dan memberikan tautan yang dapat dibagikan, saya juga dapat membuat file tersedia untuk semua pengguna. Bot mendukung pencarian dan <a href="t.me/mdtohtmlbot">HTML</a>.`,{
parse_mode:'HTML',
reply_markup:{
inline_keyboard:[
[{text:'Pencarian',switch_inline_query:''},{text:'Tautan',callback_data:'POP'}],
[{text:'Owner 1', url: 'https://t.me/aa'},{text:'Owner 2', url: 'https://t.me/aa'}],
[{text:'Gabung Channel', url: 'https://t.me/aa}]
]
}
})
}else{
file = await saver.getFile(query).then((res)=>{
console.log(res);
if(res.type=='video'){
ctx.replyWithVideo(res.file_id,{caption: `${res.caption} \n\n<b>Selamat menikmati.</b>`,
parse_mode:'HTML'})
}else if(res.type=='photo'){
ctx.replyWithPhoto(res.file_id,{caption: `${res.caption} \n\n<b>Selamat menikmati.</b>`,
parse_mode:'HTML'})
}else{
ctx.replyWithDocument(res.file_id,{caption: `${res.caption} \n\n<b>Selamat menikmati.</b>`,
parse_mode:'HTML'})
}
})
}
//saving user details to the database
saver.saveUser(user)
})
I think it may help you: issue #645
This is other library 😅
How is the code to set this when the start starts the user is asked to join the channel first? https://api.telegram.org/bot[TOKEN]/getChatMember?chat_id=@[channelname]&user_id=[user_id
This is my start code
bot.start(async(ctx)=>{ msg = ctx.message.text let msgArray = msg.split(' ') console.log(msgArray.length); let length = msgArray.length msgArray.shift() let query = msgArray.join(' ') user ={ first_name:ctx.from.first_name, userId:ctx.from.id } //welcoming message on /start and if there is a query available we can send files if(length == 1){ ctx.reply(`${ctx.from.first_name} \n\nSaya akan menyimpan file untuk Anda dan memberikan tautan yang dapat dibagikan, saya juga dapat membuat file tersedia untuk semua pengguna. Bot mendukung pencarian dan <a href="t.me/mdtohtmlbot">HTML</a>.`,{ parse_mode:'HTML', reply_markup:{ inline_keyboard:[ [{text:'Pencarian',switch_inline_query:''},{text:'Tautan',callback_data:'POP'}], [{text:'Owner 1', url: 'https://t.me/aa'},{text:'Owner 2', url: 'https://t.me/aa'}], [{text:'Gabung Channel', url: 'https://t.me/aa}] ] } }) }else{ file = await saver.getFile(query).then((res)=>{ console.log(res); if(res.type=='video'){ ctx.replyWithVideo(res.file_id,{caption: `${res.caption} \n\n<b>Selamat menikmati.</b>`, parse_mode:'HTML'}) }else if(res.type=='photo'){ ctx.replyWithPhoto(res.file_id,{caption: `${res.caption} \n\n<b>Selamat menikmati.</b>`, parse_mode:'HTML'}) }else{ ctx.replyWithDocument(res.file_id,{caption: `${res.caption} \n\n<b>Selamat menikmati.</b>`, parse_mode:'HTML'}) } }) } //saving user details to the database saver.saveUser(user) })
If what you want to check is if the user after doing /start and that you send him a message with the link to the channel. You can use the event "chat_member" for check when the user is join to the channel.
But also you can check if the user is member of this channel using bot.getChatMember('Channel Id or alias @...', 'userId').
Your bot need to be a admin in the channel that you want to check.