@@ -91,7 +91,7 @@ const delay = (delayInms) => {
9191bot . on ( "my_chat_member" , async function ( myChatMember : any ) {
9292 try {
9393 const lang_code = myChatMember ?. from ?. language_code
94- console . log ( myChatMember )
94+
9595 if ( throttled ( myChatMember . from . id ) )
9696 return
9797 if ( myChatMember . new_chat_member . status === "left" ) {
@@ -101,7 +101,7 @@ bot.on("my_chat_member", async function(myChatMember: any) {
101101 }
102102
103103 const settings = validate ( myChatMember . chat , lang_code ) ;
104- console . log ( 'HMMMMMM' )
104+
105105 if ( myChatMember . chat . type === "channel" ) {
106106 await delay ( 2000 ) ;
107107 if ( myChatMember . new_chat_member . status === "administrator" ) {
@@ -128,37 +128,10 @@ bot.on("my_chat_member", async function(myChatMember: any) {
128128 }
129129} ) ;
130130
131- /* Forward messages to Susie for appeal
132- // include "member" in allowed updates to work
133-
134- bot.on("message", async function (msg: TelegramBot.Message) {
135- if (msg.chat.type !== "private")
136- return;
137- console.log(msg)
138- })
139- */
140- //invite_url only present in private groups
141- // include "chat_member" in allowed updates to work
142- /*
143- bot.on("chat_member", async function (msg: any) {
144- if (msg.new_chat_member){
145- if(msg.invite_link?.creator?.is_bot){
146- const options = {can_send_messages: false, can_send_media_messages: false, can_send_polls: false, can_send_other_messages: false, can_add_web_page_previews: false, can_change_info: false, can_pin_messages: false};
147- bot.restrictChatMember(msg.chat.id, msg.new_chat_member.id, options)
148- }
149- else{
150- const options = await bot.getChat(msg.chat.id).permissions
151- bot.restrictChatMember(msg.chat.id, msg.new_chat_member.id, options)
152- }
153- }
154- })
155- */
156-
157-
158131bot . on ( "new_chat_members" , async function ( chatMemberUpdated : any ) {
159132 if ( ! chatMemberUpdated . new_chat_member ?. id )
160133 return ;
161- console . log ( chatMemberUpdated )
134+
162135 if ( ! hasStarted ( chatMemberUpdated . chat . id ) || throttled ( chatMemberUpdated . new_chat_member ?. id ) || chatMemberUpdated . chat . type !== "supergroup" )
163136 return ;
164137
@@ -224,14 +197,11 @@ bot.on('callback_query', async function onCallbackQuery(callbackQuery: TelegramB
224197 console . log ( e )
225198 }
226199 } else if ( Number ( calldata [ 0 ] ) === 5 ) {
227- console . log ( calldata )
228- console . log ( callbackQuery . from . id )
229200 if ( callbackQuery . from . id !== Number ( calldata [ 1 ] ) )
230201 return ;
231202 const penalized = checkHistory ( callbackQuery . message . chat , callbackQuery . from . id )
232203 const permissions = await queue . add ( async ( ) => { try { const val = ( await bot . getChat ( callbackQuery . message . chat . id ) ) . permissions
233204 return val } catch ( e ) { console . log ( e ) } } )
234- console . log ( permissions )
235205 if ( ! permissions )
236206 return
237207 if ( ! penalized )
@@ -247,8 +217,6 @@ bot.on('callback_query', async function onCallbackQuery(callbackQuery: TelegramB
247217 start . callback ( queue , db , settings , bot , String ( botId ) , callbackQuery . message , [ ] , batchedSend , true )
248218 }
249219 } else if ( Number ( calldata [ 0 ] ) === 7 ) {
250- console . log ( callbackQuery . from . id )
251- console . log ( Number ( calldata [ 1 ] ) )
252220 if ( callbackQuery . from . id !== Number ( calldata [ 1 ] ) )
253221 return ;
254222 setWarn ( db , 'telegram' , String ( callbackQuery . message . chat . id ) , Number ( calldata [ 2 ] ) )
@@ -453,9 +421,7 @@ const checkHistory = (chat: TelegramBot.Chat, userid: number): boolean => {
453421
454422 const timestamp_forgiven = getForgiveness ( db , 'telegram' , String ( chat . id ) , String ( userid ) )
455423 const warnings = getWarn ( db , 'telegram' , String ( chat . id ) )
456- console . log ( 'hmmm1' )
457424 const settings = validate ( chat ) ;
458- console . log ( 'hmmm2' )
459425 let calculateHistory = [ ]
460426 if ( settings . federation_id )
461427 calculateHistory = getFederatedBanHistory ( db , 'telegram' , String ( userid ) , settings . federation_id , true , timestamp_forgiven )
@@ -488,8 +454,6 @@ const checkHistory = (chat: TelegramBot.Chat, userid: number): boolean => {
488454 else
489455 calculateHistoryActive = getLocalBanHistory ( db , 'telegram' , String ( userid ) , String ( chat . id ) , false , timestamp_forgiven )
490456
491- console . log ( 'wtf' )
492- console . log ( calculateHistoryActive )
493457 ban_level = Math . max ( calculateHistoryActive . length - warnings , 0 )
494458 if ( ban_level > 0 ) {
495459 var max_timestamp = 0
@@ -505,7 +469,7 @@ const checkHistory = (chat: TelegramBot.Chat, userid: number): boolean => {
505469 }
506470 }
507471 if ( calculateHistoryActive . length > 0 )
508- return true
472+ return true ;
509473}
510474
511475console . log ( 'Telegram bot ready...' ) ;
0 commit comments