GithubHelp home page GithubHelp logo

ohld / telegram-support-bot Goto Github PK

View Code? Open in Web Editor NEW
324.0 13.0 269.0 12 KB

Easy way to use Telegram bot to hide your identity. Useful for support, anonymous channel management. Free clone of Livegram Bot.

Home Page: https://t.me/danokhlopkov

License: MIT License

Python 100.00%
telegram-bot heroku-deployment support python-telegram-bot

telegram-support-bot's Introduction

telegram-support-bot

Easy way to use Telegram bot to hide your identity. Useful for support, anonymous channel management. Free clone of Livegram Bot.

Deploy

How bot works:

  1. Your client write a message to your bot
  2. Bot forwards the message to your secret chat
  3. Any chat participant can reply on a forwarded message
  4. Bot will copy the message and send it to your client

.env variables

You need to specify these env variables to run this bot. If you run it locally, you can also write them in .env text file.

TELEGRAM_TOKEN=  # your bot's token
TELEGRAM_SUPPORT_CHAT_ID=  # chat_id where the bot will forward all incoming messages

# optional params
HEROKU_APP_NAME=  # name of your Heroku app for webhook setup
WELCOME_MESSAGE=  # text of a message that bot will write on /start command

# If user don't allow forward his messages Bot adds his comment with thue user_id to reply
# Support team must reply to "bot reply", not to original user forwarded message
# Customize message for support team here:
REPLY_TO_THIS_MESSAGE=User above don't allow forward his messages. Reply to this message.
# If support reply to forwarded messages with hidded sender, bor warns with next error:
WRONG_REPLY=User above don't allow forward his messages. You must reply to bot reply under user forwarded message.

Run bot locally

First, you need to install all dependencies:

pip install -r requirements.txt

Then you can run the bot. Don't forget to create .env file in the root folder with all required params (read above).

python main.py

telegram-support-bot's People

Contributors

ohld avatar rus-ai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

telegram-support-bot's Issues

The bot cannot forward a message when account is hidden for forwarding

The bot won't forward the message to the user when privacy settings like:
image

No error handlers are registered, logging exception.
Traceback (most recent call last):
  File "/home/viktor/.local/lib/python3.8/site-packages/telegram/ext/dispatcher.py", line 432, in process_update
    handler.handle_update(update, self, check, context)
  File "/home/viktor/.local/lib/python3.8/site-packages/telegram/ext/handler.py", line 156, in handle_update
    return self.callback(update, context)
  File "/home/viktor/stuff/telegram-support-bot/handlers.py", line 47, in forward_to_user
    user_id = update.message.reply_to_message.forward_from.id
AttributeError: 'NoneType' object has no attribute 'id'

AWS Lambda

Can help, how to use it on AWS Lambda?

Checking that reply_to_message was reply to bot

if user_id:
    context.bot.copy_message(
        message_id=update.message.message_id,
        chat_id=user_id,
        from_chat_id=update.message.chat_id
    )
else:
    if update.message.reply_to_message.from_user.is_bot:      #Checking that reply_to_message was reply to bot 
        context.bot.send_message(
            chat_id=update.message.chat_id,
            text=WRONG_REPLY
        )

WRONG_REPLY will be send only for a bot's messages

Deploying on a server

Can you tell me how to deploy this bot on a private server? For example a VPS or a home Raspberry Pi.

Если можно, ответьте на на русском:)

Some problems

Приветствую! Всё поставил как нужно, .env и зависимости; Вывод такой:

2021-04-05 10:27:31,274 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
INFO:sqlalchemy.engine.base.Engine:SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
2021-04-05 10:27:31,274 INFO sqlalchemy.engine.base.Engine ()
INFO:sqlalchemy.engine.base.Engine:()
2021-04-05 10:27:31,274 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
INFO:sqlalchemy.engine.base.Engine:SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
2021-04-05 10:27:31,275 INFO sqlalchemy.engine.base.Engine ()
INFO:sqlalchemy.engine.base.Engine:()
2021-04-05 10:27:31,275 INFO sqlalchemy.engine.base.Engine PRAGMA table_info("chats")
INFO:sqlalchemy.engine.base.Engine:PRAGMA table_info("chats")
2021-04-05 10:27:31,275 INFO sqlalchemy.engine.base.Engine ()
INFO:sqlalchemy.engine.base.Engine:()
2021-04-05 10:27:31,276 INFO sqlalchemy.engine.base.Engine PRAGMA table_info("banned_users")
INFO:sqlalchemy.engine.base.Engine:PRAGMA table_info("banned_users")
2021-04-05 10:27:31,276 INFO sqlalchemy.engine.base.Engine ()
INFO:sqlalchemy.engine.base.Engine:()
2021-04-05 10:27:31,277 INFO sqlalchemy.engine.base.Engine 
CREATE TABLE chats (
	message_id INTEGER NOT NULL, 
	chat_id INTEGER, 
	date INTEGER, 
	PRIMARY KEY (message_id), 
	FOREIGN KEY(message_id) REFERENCES banned_users (id)
)


INFO:sqlalchemy.engine.base.Engine:
CREATE TABLE chats (
	message_id INTEGER NOT NULL, 
	chat_id INTEGER, 
	date INTEGER, 
	PRIMARY KEY (message_id), 
	FOREIGN KEY(message_id) REFERENCES banned_users (id)
)


2021-04-05 10:27:31,277 INFO sqlalchemy.engine.base.Engine ()
INFO:sqlalchemy.engine.base.Engine:()
2021-04-05 10:27:31,371 INFO sqlalchemy.engine.base.Engine COMMIT
INFO:sqlalchemy.engine.base.Engine:COMMIT
2021-04-05 10:27:31,372 INFO sqlalchemy.engine.base.Engine 
CREATE TABLE banned_users (
	id INTEGER NOT NULL, 
	username VARCHAR, 
	PRIMARY KEY (id), 
	FOREIGN KEY(id) REFERENCES chats (chat_id)
)


INFO:sqlalchemy.engine.base.Engine:
CREATE TABLE banned_users (
	id INTEGER NOT NULL, 
	username VARCHAR, 
	PRIMARY KEY (id), 
	FOREIGN KEY(id) REFERENCES chats (chat_id)
)


2021-04-05 10:27:31,372 INFO sqlalchemy.engine.base.Engine ()
INFO:sqlalchemy.engine.base.Engine:()
2021-04-05 10:27:31,447 INFO sqlalchemy.engine.base.Engine COMMIT
INFO:sqlalchemy.engine.base.Engine:COMMIT
ERROR:asyncio:_GatheringFuture exception was never retrieved
future: <_GatheringFuture finished exception=Unauthorized('Unauthorized')>
Traceback (most recent call last):
  File "/home/USER/TeleFeedBack/utils.py", line 10, in log_bot_info
    bot_info = await bot.get_me()
  File "/home/USER/.local/lib/python3.8/site-packages/aiogram/bot/bot.py", line 174, in get_me
    result = await self.request(api.Methods.GET_ME, payload)
  File "/home/USER/.local/lib/python3.8/site-packages/aiogram/bot/base.py", line 183, in request
    return await api.make_request(self.session, self.__token, method, data, files,
  File "/home/USER/.local/lib/python3.8/site-packages/aiogram/bot/api.py", line 98, in make_request
    return check_result(method, response.content_type, response.status, await response.text())
  File "/home/USER/.local/lib/python3.8/site-packages/aiogram/bot/api.py", line 78, in check_result
    exceptions.Unauthorized.detect(description)
  File "/home/USER/.local/lib/python3.8/site-packages/aiogram/utils/exceptions.py", line 138, in detect
    raise cls(description)
aiogram.utils.exceptions.Unauthorized: Unauthorized
WARNING:aiogram:Goodbye!
Traceback (most recent call last):
  File "main.py", line 88, in <module>
    executor.start_polling(dp)
  File "/home/USER/.local/lib/python3.8/site-packages/aiogram/utils/executor.py", line 41, in start_polling
    executor.start_polling(reset_webhook=reset_webhook, timeout=timeout, fast=fast)
  File "/home/USER/.local/lib/python3.8/site-packages/aiogram/utils/executor.py", line 305, in start_polling
    loop.run_until_complete(self._startup_polling())
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/USER/.local/lib/python3.8/site-packages/aiogram/utils/executor.py", line 355, in _startup_polling
    await self._welcome()
  File "/home/USER/.local/lib/python3.8/site-packages/aiogram/utils/executor.py", line 345, in _welcome
    user = await self.dispatcher.bot.me
  File "/home/USER/.local/lib/python3.8/site-packages/aiogram/bot/bot.py", line 25, in me
    setattr(self, '_me', await self.get_me())
  File "/home/USER/.local/lib/python3.8/site-packages/aiogram/bot/bot.py", line 174, in get_me
    result = await self.request(api.Methods.GET_ME, payload)
  File "/home/USER/.local/lib/python3.8/site-packages/aiogram/bot/base.py", line 183, in request
    return await api.make_request(self.session, self.__token, method, data, files,
  File "/home/USER/.local/lib/python3.8/site-packages/aiogram/bot/api.py", line 98, in make_request
    return check_result(method, response.content_type, response.status, await response.text())
  File "/home/USER/.local/lib/python3.8/site-packages/aiogram/bot/api.py", line 78, in check_result
    exceptions.Unauthorized.detect(description)
  File "/home/USER/.local/lib/python3.8/site-packages/aiogram/utils/exceptions.py", line 138, in detect
    raise cls(description)
aiogram.utils.exceptions.Unauthorized: Unauthorized

media group

Возможно реализовать отправку группы медиа одним сообщением? На данный момент идет разделение каждого медиа на отдельные сообщения.

Bad webhook error on start up

I just deployed this to Heroku and I think I got everything right but I'm getting an error when the app tries to start... telegram.error.BadRequest: Bad webhook

I've checked the URL as per the first line of output but there's not many other clues... it's running on a free dyno if that makes a difference?

app[web.1]: Running bot in webhook mode. Make sure that this url is correct: https://<app-name>.herokuapp.com/
app[web.1]: Error while bootstrap set webhook: Bad webhook: webhook can be set up only on ports 80, 88, 443 or 8443
app[web.1]: Failed bootstrap phase after 0 retries (Bad webhook: webhook can be set up only on ports 80, 88, 443 or 8443)
app[web.1]: unhandled exception in Bot:1782207609:updater
app[web.1]: Traceback (most recent call last):
app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/telegram/ext/updater.py", line 236, in _thread_wrapper
app[web.1]:     target(*args, **kwargs)
app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/telegram/ext/updater.py", line 602, in _start_webhook
app[web.1]:     ip_address=ip_address,
app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/telegram/ext/updater.py", line 674, in _bootstrap
app[web.1]:     bootstrap_interval,
app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/telegram/ext/updater.py", line 530, in _network_loop_retry
app[web.1]:     onerr_cb(telegram_exc)
app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/telegram/ext/updater.py", line 652, in bootstrap_onerr_cb
app[web.1]:     raise exc
app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/telegram/ext/updater.py", line 516, in _network_loop_retry
app[web.1]:     if not action_cb():
app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/telegram/ext/updater.py", line 640, in bootstrap_set_webhook
app[web.1]:     drop_pending_updates=drop_pending_updates,
app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/telegram/bot.py", line 127, in decorator
app[web.1]:     result = func(*args, **kwargs)
app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/telegram/bot.py", line 2863, in set_webhook
app[web.1]:     result = self._post('setWebhook', data, timeout=timeout, api_kwargs=api_kwargs)
app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/telegram/bot.py", line 260, in _post
app[web.1]:     f'{self.base_url}/{endpoint}', data=data, timeout=effective_timeout
app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/telegram/utils/request.py", line 354, in post
app[web.1]:     **urlopen_kwargs,
app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/telegram/utils/request.py", line 272, in _request_wrapper
app[web.1]:     raise BadRequest(message)
app[web.1]: telegram.error.BadRequest: Bad webhook: webhook can be set up only on ports 80, 88, 443 or 8443

Бесплатного Heroku больше нет

Спасибо за вашу работу, до сих пор пользуюсь, очень удобно.
Heroku больше не будет бесплатным с этого ноября. Думаю что уместно убрать всю инфу об этом.
Успешно перенёс бота на свою vps, ничего сложного.

Item could not be created

When creating a program in Hiroku, an error "We couldnt deploy your app because the source code violates the Salesforce Acceptable Use and External-Facing Services Policy". Can you please tell me how to register the program?

Блок пользователей

Было бы здорово увидеть возможность заблокировать неугодных по Telegram id или любым другим способом

Bot Code Issues

When bot forwarded to a Telegram Group that have been set up to receive, it work normally.

Bot function normally by forwarding messages to the group.
This include "From: @sadvibealone
User above don't allow forward his messages.
Reply to this message."

However , when reply to the "bot reply under user forwarded message" , it shows WRONG_REPLY error.

Much Thx

The reply is not getting the contacting user

The app is deployed on heroku. If a user that needs support starts the bot the bot is messaging hand emoji and I am getting the contacted user info. I am getting forwarded messages of users from the bot. But if I reply to the forwarded message my message is being forwarded to myself and the owner of the message is not gettin my message.
I have tried to restart all dynos. How can I fix the problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.