A Telegram Bot Control Center to send messages to list of channels
api_key and api_hash): https://my.telegram.orgpython3 -m pip install -r requirements.txtpython3 telegram/gui/telegram_gui.pypython3 main.pypython3 telegram/api/server.pydocker build -t tgram-bot .docker run -p 9090:9090 tgram-botapi_key and api_hash from https://my.telegram.org/sessions/initiate API Call to Initiate the session
api_key, api_hash, session, and phone as query parameters/sessions/start API Call to Start the session
phone and code as query parameter/channels/join API to join list of channels
channels parameters as comma separated list in query parameter/messages/send API to send messages to the list of channels
channels and message parameters in query parameter/api/docs URL contains the API Docsuvicorn server:appgunicorn server:app -w 4 -k uvicorn.workers.UvicornWorkerhypercorn server:appdaphne server:appgunicorn server:app --bind 0.0.0.0:9090 --worker-class sanic.worker.GunicornWorkerheroku login - Login to Herokuheroku container:login - Login to Heroku Docker Registeryheroku container:push web -a tgram-bot - Push current local docker image to registeryheroku container:release web -a tgram-bot - Release and Deploy the latest imageheroku logs --tail -a tgram-bot-deploy - To check the logsRef: https://blog.codeship.com/the-shortlist-of-docker-hosting/
POST, DELETE HTTP Methodsauto_reload=True option)/deploy folder)https://sanic-jwt.readthedocs.io/en/latest/pages/simpleusage.htmlpython main.py
https://github.com/google/python-firehttps://github.com/chriskiehl/Gooeyhttps://wiki.python.org/moin/PyQt/Tutorialshttps://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uswgi-and-nginx-on-ubuntu-18-04https://github.com/serathius/sanic-sentry
Test Server: 149.154.167.40:443
@TelethonChat
@TelethonOfftopic
https://t.me/TelethonSnippets
https://telegramchannels.me
https://tlgrm.eu/channels/language
https://t.me/PixelExperience
https://t.me/xXx_OP6_Lounge
if __name__ == ‘__main__’:
context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
context.load_cert_chain(“./.ssl/name_of_cert_file.crt”, keyfile=”./.ssl/name_of_key_file.key”)app.go_fast(host=”0.0.0.0", port=8443, ssl=context, workers=os.cpu_count(), debug=True)
from functools import wraps
def check_request_for_authorization_status(request):
# Note: Define your check, for instance cookie, session.
flag = True
return flag
def authorized():
def decorator(f):
@wraps(f)
async def decorated_function(request, *args, **kwargs):
# run some method that checks the request
# for the client's authorization status
is_authorized = check_request_for_authorization_status(request)
if is_authorized:
# the user is authorized.
# run the handler method and return the response
response = await f(request, *args, **kwargs)
return response
else:
# the user is not authorized.
return json({'status': 'not_authorized'}, 403)
return decorated_function
return decorator
@app.route("/")
@authorized()
async def test(request):
return json({'status': 'authorized'})
server {
listen 80;
server_name app.com;
charset utf-8;
location / {
proxy_pass http://app:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
# handler = logging.StreamHandler()
# logger.addHandler(handler)
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
pip3 install PyQt5==5.11.3
# self.setWindowIcon(QtGui.QIcon("icon.png"))
# self.resize(500,650)
# self.setMinimumSize(500,650)
# self.center()
# --- Menu --- #
open = QAction("Exit", self)
save = QAction("Save", self)
build = QAction("Build", self)
exit = QAction("Quit", self)
menu_bar = QMenuBar()
file1 = menu_bar.addMenu("&File")
help = menu_bar.addMenu("&Help")
file1.addAction(open)
file1.addAction(save)
file1.addAction(build)
self.tab_widget.setTabPosition(QTabWidget.TabPosition.West)
self.tab_widget.setTabShape(QTabWidget.TabShape.Triangular)
# data = loop.run_until_complete(bot.initiate(self.loop))
# done, pending = loop.run_until_complete(asyncio.wait(await bot.initiate(self.loop)))
# for future in done:
# data = future.result()
# print(data)
# async with data_future as data:
# menubar = self.menuBar()
# fileMenu = menubar.addMenu('&File')
# fileMenu.addAction(exitAction)
exitAction = QtGui.QAction(QtGui.QIcon('exit24.png'), 'Exit', self)
exitAction.setShortcut('Ctrl+Q')
exitAction.triggered.connect(QtGui.qApp.quit)
self.toolbar = self.addToolBar('Exit')
self.toolbar.addAction(exitAction)
pyuic4 -x test.ui -o test.py
pyuic5 mydesign.ui -o mydesign.py
pip install pyinstaller
pyinstaller --onefile --windowed app.py
pyinstaller app.py
def get_ui_path(self, ui_file):
if getattr(sys, 'frozen', False):
bundle_dir = sys._MEIPASS
ui_path = f'{bundle_dir}/{ui_file}'
else:
bundle_dir = os.path.dirname(os.path.abspath(__file__))
ui_path = f'{bundle_dir}/ui/{ui_file}'
print('bundle_dir', bundle_dir)
print('ui_path', ui_path)
return ui_path
Content type
Image
Digest
Size
211 MB
Last updated
almost 7 years ago
docker pull vs4vijay/tgram-bot