@borg.on(admin_cmd('bforward ?(.*)', allow_sudo=True))
async def forw(event):
    if event.fwd_from:
        return
    if (not event.is_reply):
        (await event.edit('Reply to a message to broadcast.'))
        return
    channels = get_all_channels()
    (await event.edit('Sending...'))
    error_count = 0
    sent_count = 0
    if event.reply_to_msg_id:
        previous_message = (await event.get_reply_message())
        message = previous_message.message
        raw_text = previous_message.raw_text
    error_count = 0
    for channel in channels:
        try:
            (await borg.forward_messages(int(channel.chat_id), previous_message))
            sent_count += 1
            (await event.edit(f'''Sent : {sent_count}
Error : {error_count}
Total : {len(channels)}'''))
        except Exception as error:
            try:
                (await borg.send_message(logs_id, f'Error in sending at {channel.chat_id}.'))
                (await borg.send_message(logs_id, ('Error! ' + str(error))))
                if (error == 'The message cannot be empty unless a file is provided'):
                    event.edit('For sending files, upload in Saved Messages and reply .forward to in.')
                    return
            except:
                pass
            error_count += 1
            (await event.edit(f'''Sent : {sent_count}
Error : {error_count}'''))
    (await event.edit(f'{sent_count} messages sent with {error_count} errors.'))
    if (error_count > 0):
        try:
            (await borg.send_message(logs_id, f'{error_count} Errors'))
        except:
            (await event.edit('Set up log channel for checking errors.'))
@borg.on(admin_cmd('bforward ?(.*)', allow_sudo=True))
async def forw(event):
    if event.fwd_from:
        return
    if (not event.is_reply):
        (await event.edit('Reply to a message to broadcast.'))
        return
    channels = get_all_channels()
    (await event.edit('Sending...'))
    error_count = 0
    sent_count = 0
    if event.reply_to_msg_id:
        previous_message = (await event.get_reply_message())
        message = previous_message.message
        raw_text = previous_message.raw_text
    error_count = 0
    for channel in channels:
        try:
            (await borg.forward_messages(int(channel.chat_id), previous_message))
            sent_count += 1
            (await event.edit(f'Sent : {sent_count}
Error : {error_count}
Total : {len(channels)}'))
        except Exception as error:
            try:
                (await borg.send_message(logs_id, f'Error in sending at {channel.chat_id}.'))
                (await borg.send_message(logs_id, ('Error! ' + str(error))))
                if (error == 'The message cannot be empty unless a file is provided'):
                    event.edit('For sending files, upload in Saved Messages and reply .forward to in.')
                    return
            except:
                pass
            error_count += 1
            (await event.edit(f'Sent : {sent_count}
Error : {error_count}'))
    (await event.edit(f'{sent_count} messages sent with {error_count} errors.'))
    if (error_count > 0):
        try:
            (await borg.send_message(logs_id, f'{error_count} Errors'))
        except:
            (await event.edit('Set up log channel for checking errors.'))