def rm_contact(message): """Remove a Whatsapp contact from the database. Message has the following format: /rm <name> Args: message: Received Telegram message. """ if message.chat.id != SETTINGS['owner']: tgbot.reply_to(message, 'you are not the owner of this bot') return # Get name name = telebot.util.extract_arguments(message.text) if not name: tgbot.reply_to(message, 'Syntax: /rm <name>') return # Check if it already exists if not get_phone(name): tgbot.reply_to(message, 'No contact found with that name') return # Add to database db_rm_contact(name) tgbot.reply_to(message, 'Contact removed')
def unlink(message): """Unlink bridge Message has the following format: /unlink Args: message: Received Telegram message. """ if message.chat.type not in ['group', 'supergroup']: tgbot.reply_to(message, 'This operation can be done only in a group') return # Check if it already exists wa_group_name = db_get_contact_by_group(message.chat.id) if not wa_group_name: tgbot.reply_to(message, 'This group is not bridged to anywhere') return # Add to database db_rm_contact(wa_group_name) tgbot.reply_to(message, 'Bridge has been successfully removed.')