README and clear requests

This commit is contained in:
Bandie 2021-06-11 19:41:31 +02:00
parent 0a762ebacc
commit dbd77e86ed
Signed by: Bandie
GPG Key ID: 843D7FA93BA46312
2 changed files with 34 additions and 9 deletions

25
README.md Normal file
View File

@ -0,0 +1,25 @@
# TelegramContactProtectionBot
## The idea
The idea behind this bot is that you want to take control on who can contact you.
Usually you use a public accessible username (@ handles) to be reachable without sharing your telephone number. This also means that strangers could talk to you and annoy you.
To prevent that, you could register a bot using https://t.me/BotFather and use this code to have actual contact requests.
## Configuration
- Register a bot using BotFather
- Put the API token in your `.env` file, looking like `TOKEN='398iufewj9fierhfefiuosf'`
- Start the bot
- Find your bot and `/start` it in Telegram
- Claim your bot by typing `/setup`
## How it works
People can `/start` and `/request` to contact you. If the being has no public username it will ask for their telephone number which is deniable though.
## Administration
- `/setup` - Write the forename and ID into the config. The forename is used to show to whom this bot belongs.
- `/block` - Block a being. Use the ID to block.
- `/unblock` - Unblock a being. Use the ID to unblock.
- `/blocklist` - Get all IDs who are blocked.
- `/setname` - Set the name which the bot will use.

View File

@ -117,9 +117,9 @@ def forwardContact(update: Update, context: CallbackContext):
return return
mesg = "\nID: " + str(user.id) mesg = "\nID: " + str(user.id)
mesg +="\nUN: @" + str(user.username) mesg +="\nUsername: @" + str(user.username)
mesg +="\nFN: " + str(user.first_name) mesg +="\nFore name: " + str(user.first_name)
mesg +="\nLN: " + str(user.last_name) mesg +="\nLast name: " + str(user.last_name)
bot.sendMessage(chat_id=config['adminID'], text="Request by: " + mesg) bot.sendMessage(chat_id=config['adminID'], text="Request by: " + mesg)
bot.send_contact(chat_id=config['adminID'], contact=update.message.contact) bot.send_contact(chat_id=config['adminID'], contact=update.message.contact)
reply_markup=telegram.ReplyKeyboardRemove() reply_markup=telegram.ReplyKeyboardRemove()
@ -131,9 +131,9 @@ def request(update: Update, context: CallbackContext):
return False return False
logging.info("ID: " + str(user.id)) logging.info("ID: " + str(user.id))
logging.info("UN: " + str(user.username)) logging.info("Username: @" + str(user.username))
logging.info("FN: " + str(user.first_name)) logging.info("Fore name: " + str(user.first_name))
logging.info("LN: " + str(user.last_name)) logging.info("Last name: " + str(user.last_name))
if(user.username is None): if(user.username is None):
@ -144,9 +144,9 @@ def request(update: Update, context: CallbackContext):
else: else:
mesg = "\nID: " + str(user.id) mesg = "\nID: " + str(user.id)
mesg +="\nUN: @" + str(user.username) mesg +="\nUsername: @" + str(user.username)
mesg +="\nFN: " + str(user.first_name) mesg +="\nFore name: " + str(user.first_name)
mesg +="\nLN: " + str(user.last_name) mesg +="\nLast name: " + str(user.last_name)
bot.sendMessage(chat_id=config['adminID'], text="Request by: " + mesg) bot.sendMessage(chat_id=config['adminID'], text="Request by: " + mesg)
context.bot.send_message(chat_id=update.effective_chat.id, text="Your request has been sent. " + config['name'] + " will eventually contact you back.") context.bot.send_message(chat_id=update.effective_chat.id, text="Your request has been sent. " + config['name'] + " will eventually contact you back.")