Skip to content

Commit

Permalink
Steps to Run on Heroku
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe committed Mar 17, 2019
1 parent 153b1e2 commit d4fd5c4
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 48 deletions.
16 changes: 14 additions & 2 deletions GenerateStringSession.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
#!/usr/bin/env python3
# (c) https://t.me/TelethonChat/37677
# This Source Code Form is subject to the terms of the GNU
# General Public License, v.3.0. If a copy of the GPL was not distributed with this
# file, You can obtain one at https://www.gnu.org/licenses/gpl-3.0.en.html.

from telethon.sync import TelegramClient
from telethon.sessions import StringSession
from config import Config

with TelegramClient(StringSession(), Config.APP_ID, Config.API_HASH) as client:
print("""Please go-to my.telegram.org
Login using your Telegram account
Click on API Development Tools
Create a new application, by entering the required details""")
APP_ID = int(input("Enter APP ID here: "))
API_HASH = input("Enter API HASH here: ")

with TelegramClient(StringSession(), APP_ID, API_HASH) as client:
print(client.session.save())
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
worker: python3 -m stdborg stdborg
worker: python3 -m stdborg
17 changes: 15 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
{
"name": "UniBorg",
"description": "Modular UserBot powered by @TelethonChat!",
"logo": "https://telegra.ph/file/6ce444f5ba54d79fb8622.jpg",
"keywords": [
"telegram",
"userbot",
"plugin",
"modular"
"modular",
"productivity"
],
"repository": "https://github.com/SpEcHiDe/uniborg",
"repository": "https://gitlab.com/SpEcHiDe/UniBorg",
"website": "https://telegram.dog/UniBorg",
"success_url": "https://t.me/UniBorg/5",
"env": {
"ENV": {
"description": "Setting this to ANYTHING will enable environment variables.",
Expand All @@ -21,6 +25,10 @@
"description": "Get this value from my.telegram.org! Please do not steal",
"value": ""
},
"HU_STRING_SESSION": {
"description": "Get this value by running python3 GenerateStringSession.py locally",
"value": ""
},
"OPEN_WEATHER_MAP_APPID": {
"description": "Get your own APPID from https://api.openweathermap.org/data/2.5/weather",
"value": "",
Expand Down Expand Up @@ -85,6 +93,11 @@
"description": "Obtain a Telegram bot token by contacting @BotFather",
"value": "",
"required": false
},
"TG_BOT_USER_NAME_BF_HER": {
"description": "Obtain a Telegram bot @username by contacting @BotFather",
"value": "",
"required": false
}
},
"addons": [],
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
telethon
-r ./requirements-stdborg.txt
46 changes: 26 additions & 20 deletions sample_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,42 @@ class Config(object):
# Get this value from my.telegram.org! Please do not steal
APP_ID = int(os.environ.get("APP_ID", "12345"))
API_HASH = os.environ.get("API_HASH", "")
# This is required for the plugins involving the file system.
TMP_DOWNLOAD_DIRECTORY = os.environ.get("TMP_DOWNLOAD_DIRECTORY", "./DOWNLOADS/")
# This is required for the hash to torrent file functionality to work.
HASH_TO_TORRENT_API = os.environ.get("HASH_TO_TORRENT_API", "https://example.com/torrent/{}");
# This is required for the @telegraph functionality.
TELEGRAPH_SHORT_NAME = os.environ.get("TELEGRAPH_SHORT_NAME", "UniBorg")
# This is required for the speech to text module. Get your USERNAME from https://console.bluemix.net/docs/services/speech-to-text/getting-started.html
IBM_WATSON_CRED_USERNAME = os.environ.get("IBM_WATSON_CRED_USERNAME", None)
IBM_WATSON_CRED_PASSWORD = os.environ.get("IBM_WATSON_CRED_PASSWORD", None)
# Get your own ACCESS_KEY from http://api.screenshotlayer.com/api/capture
SCREEN_SHOT_LAYER_ACCESS_KEY = os.environ.get("SCREEN_SHOT_LAYER_ACCESS_KEY", None)
# string session for running on Heroku
# some people upload their session files on GitHub or other third party hosting
# websites, this might prevent the un-authorized use of the
# confidential session files
HU_STRING_SESSION = os.environ.get("HU_STRING_SESSION", None)
# Get your own APPID from https://api.openweathermap.org/data/2.5/weather
OPEN_WEATHER_MAP_APPID = os.environ.get("OPEN_WEATHER_MAP_APPID", None)
# Get your own ACCESS_KEY from http://api.screenshotlayer.com/api/capture
SCREEN_SHOT_LAYER_ACCESS_KEY = os.environ.get("SCREEN_SHOT_LAYER_ACCESS_KEY", None)
# Send .get_id in any group to fill this value.
PRIVATE_GROUP_BOT_API_ID = int(os.environ.get("PRIVATE_GROUP_BOT_API_ID", "-100123456789"))
# Send .get_id in any channel to fill this value. ReQuired for @Manuel15 inspiration to work!
PRIVATE_CHANNEL_BOT_API_ID = int(os.environ.get("PRIVATE_CHANNEL_BOT_API_ID", "-100123456789"))
# This is required for the plugins involving the file system.
TMP_DOWNLOAD_DIRECTORY = os.environ.get("TMP_DOWNLOAD_DIRECTORY", "./DOWNLOADS/")
# This is required for the speech to text module. Get your USERNAME from https://console.bluemix.net/docs/services/speech-to-text/getting-started.html
IBM_WATSON_CRED_USERNAME = os.environ.get("IBM_WATSON_CRED_USERNAME", None)
IBM_WATSON_CRED_PASSWORD = os.environ.get("IBM_WATSON_CRED_PASSWORD", None)
# This is required for the hash to torrent file functionality to work.
HASH_TO_TORRENT_API = os.environ.get("HASH_TO_TORRENT_API", "https://example.com/torrent/{}");
# This is required for the @telegraph functionality.
TELEGRAPH_SHORT_NAME = os.environ.get("TELEGRAPH_SHORT_NAME", "UniBorg")
# Get a Free API Key from OCR.Space
OCR_SPACE_API_KEY = os.environ.get("OCR_SPACE_API_KEY", None)
# Send .get_id in any group with all your administration bots (added)
G_BAN_LOGGER_GROUP = int(os.environ.get("G_BAN_LOGGER_GROUP", "-100123456789"))
# TG API limit. An album can have atmost 10 media!
TG_GLOBAL_ALBUM_LIMIT = int(os.environ.get("TG_GLOBAL_ALBUM_LIMIT", 9))
# Telegram BOT Token from @BotFather
TG_BOT_TOKEN_BF_HER = os.environ.get("TG_BOT_TOKEN_BF_HER", None)
TG_BOT_USER_NAME_BF_HER = os.environ.get("TG_BOT_USER_NAME_BF_HER", None)
#
#
# DO NOT EDIT BELOW THIS LINE IF YOU DO NOT KNOW WHAT YOU ARE DOING
MAX_MESSAGE_SIZE_LIMIT = 4095
# TG API limit. A message can have maximum 4096 characters!
TG_GLOBAL_ALBUM_LIMIT = int(os.environ.get("TG_GLOBAL_ALBUM_LIMIT", 9))
# TG API limit. An album can have atmost 10 media!
# Get a Free API Key from OCR.Space
OCR_SPACE_API_KEY = os.environ.get("OCR_SPACE_API_KEY", None)
MAX_MESSAGE_SIZE_LIMIT = 4095
# set blacklist_chats where you do not want userbot's incoming=True feature
UB_BLACK_LIST_CHAT = [
"@UserBotGroup",
Expand All @@ -48,10 +58,6 @@ class Config(object):
# chat ids or usernames, it is recommended to use chat ids,
# providing usernames means an additional overhead for the user
CHATS_TO_MONITOR_FOR_ANTI_FLOOD = []
G_BAN_LOGGER_GROUP = int(os.environ.get("G_BAN_LOGGER_GROUP", None))
# specify LOAD and NO_LOAD
LOAD = []
NO_LOAD = []
# Telegram BOT Token from @BotFather
TG_BOT_TOKEN_BF_HER = os.environ.get("TG_BOT_TOKEN_BF_HER", None)
TG_BOT_USER_NAME_BF_HER = os.environ.get("TG_BOT_USER_NAME_BF_HER", None)
35 changes: 12 additions & 23 deletions stdborg.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sys
from uniborg import Uniborg
from uniborg.storage import Storage
from telethon.sessions import StringSession


logging.basicConfig(level=logging.INFO)
Expand All @@ -21,30 +22,18 @@
from config import Config
else:
logging.warning("No config.py Found!")
logging.info("[BETA] Trying to create config.py")
with open("app.json") as auto_json_file:
json_data = json.load(json_file)
app_variables = json_data["env"]
logging.info(app_variables)
logging.info("Need to finish this, but not now!")
logging.info("Please run the command, again, after creating config.py similar to README.md")
sys.exit(1)


if len(sys.argv) == 2:
session_name = str(sys.argv[1])
borg = Uniborg(
session_name,
plugin_path="stdplugins",
storage=lambda n: Storage(Path("data") / n),
connection_retries=None,
api_config=Config,
api_id=Config.APP_ID,
api_hash=Config.API_HASH
)
borg.run_until_disconnected()
else:
logging.error("USAGE EXAMPLE:\n"
"python3 -m stdborg <SESSION_NAME>"
"\n 👆👆 Please follow the above format to run your userbot."
"\n Bot quitting.")
session_name = str(Config.HU_STRING_SESSION)
borg = Uniborg(
StringSession(session_name),
plugin_path="stdplugins",
storage=lambda n: Storage(Path("data") / n),
connection_retries=None,
api_config=Config,
api_id=Config.APP_ID,
api_hash=Config.API_HASH
)
borg.run_until_disconnected()

0 comments on commit d4fd5c4

Please sign in to comment.