-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
166 lines (154 loc) · 5.86 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
"""Configures Various interconnected components"""
import os
import pyrebase
import pytz
from binance.client import Client
from dotenv import load_dotenv
from telethon import TelegramClient
from telethon.sessions import StringSession
import munch
import discord
from discord.ext import commands
# Get environment variables
local = [True]
if os.name == 'nt':
local[0] = True
print('Windows Detected...')
else:
# code is reachable, vscode lying
local[0] = False
print('Linux Detected...')
load_dotenv()
def get_firebase_config():
"""Init Database Connection"""
config = {
"apiKey": str(os.getenv("FIREBASE_API")),
"authDomain": "telebagger.firebaseapp.com",
"projectId": "telebagger",
"messagingSenderId": "332905720250",
"storageBucket": "telebagger.appspot.com",
"appId": "1:332905720250:web:e2006e777fa8d980d61583",
"measurementId": "G-02W82CCF85",
"databaseURL": "https://telebagger-default-rtdb.firebaseio.com/",
}
return pyrebase.initialize_app(config)
def get_timezone_config():
"""Returns consistent timezon"""
return pytz.timezone('Australia/Perth')
def get_binance_config():
"""Gets binance client"""
r_api_key = os.getenv('LACH_BINANCE_KEY')
r_api_secret = os.getenv('LACH_BINANCE_SECRET')
realclient = Client(r_api_key, r_api_secret)
return realclient
def get_telegram_config():
"""Returns Telegram Client"""
api_id = os.getenv('TELEGRAM_ID')
api_hash = os.getenv('TELEGRAM_HASH')
if local[0]:
#stringsesh = os.getenv('TELEGRAM_LOCALSAVE')
stringsesh = '1BVtsOMQBuyhIoQWYzzU2C-IyIo0X2VTfU4lUdUxZh06BWVCHo9vpxyZuRqyFVS-dmQ2qF48TJKZZBWjHEqnx6E9VVSRxruaqVoeeLWWlFgAR4Vqij25d65tbdI5rKdJzEDkDfz2z5u11WwgAjFnOmdrQLgg4qFnOj8AlJxQyEqxZ3DRgJKy5uMg8nKg_BZx8uvNhAD-PI2NDMS96YJWSSt5LTS63v5GmBDOFq551Tf0zbmUaINqmwVQdHbPel7hTJahlP3UcuGD3ij0o96mu6kwk0bhFgg7QpD8LPJYVNMFFMGiDS7jHnF_2_wrpV_bHJY7Mn-J8qZuYJpm4__cYIk4yBFW_lTg='
else:
#stringsesh = os.getenv('TELEGRAM_SERVERSAVE')
stringsesh = '1BVtsOLsBu0NPznbcJmwVPJcAOaKZsQbaYMV79eL7fX-xPQeBR_KCtgNMRY1pBJimEcZGRPOoyBh7W_9ewyxdhoO2bxMJiJNsup0KLc7OyuoxP6sy_bVnFEQYtmafplDGnWfiWwKggzhZdnYRKD8VVB8KRmjzti4-2CGVplf8xLyhnlWvRZWbIE8S7yNUgcpll7Xi48KGw0gNbBLgUDrMd5jIj2ERGt8fecbO79RzNTqzLsnzyLB_aHjUdHB6Mj1Per2pmITweBkMHcAE5bvrBT_YBerGvReCz7hG3AC72kXo1l9p7zenPf-ZGzcLC_ip2Xl9yEFNBvECC_ZLFyy-6Nl6zzWE2Io='
return TelegramClient(StringSession(stringsesh), api_id, api_hash)
def get_discord_config():
"""Returns Discord Client"""
SELF_TOKEN = os.getenv('DISCORD_TOKEN')
bot = commands.Bot(command_prefix='>', self_bot=True)
return [bot, SELF_TOKEN]
def get_commands():
"""Returns set of telegram commands"""
if local[0]:
# Stream Commands Local
chat_commands = {
'STOP': '/stop',
'STREAM': '/stream',
'STOPSTREAM': '/stopstream',
'RESTART': '/restart',
'MENU': '/menu',
'ADD': '/add',
'ADD2': '/add2',
'ADD3': '/add3',
'UPDATE': '/update',
'UPDATE2': '/update2',
'PRE_AW': '/pre_aw',
'ALWAYS_WIN_SIGNAL': '/aw',
'HIRN_SIGNAL': '/hirn',
'RAND_HIRN_SIGNAL': '/new_hirn',
'UPDATE_NOW': '/now',
'STATUS': '/status',
'PAST': '/past',
'EXCEPT': '/except',
'DUMP': '/dump',
'SMOOTH_DUMP': '/smooth_dump',
'NEW_PORTFOLIO': '/newport',
'CLEAR_PORTFOLIO': '/clear_folio',
'DISPLAY_PORTFOLIO': '/display_folio',
'SNAPSHOT': '/snapshot',
'CLOSE_FUTURE': '/close_future',
'SIGNAL_GROUP': ['1548802426', '1248393106'],
'GENERAL_GROUP': ['1576065688', '1220789766', '1798277168', '1109500936', '1250090891']
}
else:
# Stream Commands Heroku Hosted
chat_commands = {
'STOP': '/stop!',
'STREAM': '/stream!',
'STOPSTREAM': '/stopstream!',
'RESTART': '/restart!',
'MENU': '/menu!',
'ADD': '/add!',
'ADD2': '/add2!',
'ADD3': '/add3!',
'UPDATE': '/update!',
'UPDATE2': '/update2!',
'PRE_AW': '/pre_aw!',
'ALWAYS_WIN_SIGNAL': '/aw!',
'HIRN_SIGNAL': '/hirn!',
'RAND_HIRN_SIGNAL': '/new_hirn!',
'UPDATE_NOW': '/now!',
'STATUS': '/status!',
'PAST': '/past!',
'EXCEPT': '/except!',
'DUMP': '/dump!',
'SMOOTH_DUMP': '/smooth_dump!',
'NEW_PORTFOLIO': '/newport!',
'CLEAR_PORTFOLIO': '/clear_folio!',
'DISPLAY_PORTFOLIO': '/display_folio!',
'SNAPSHOT': '/snapshot!',
'CLOSE_FUTURE': '/close_future!',
'SIGNAL_GROUP': ['1548802426', '1248393106'],
'GENERAL_GROUP': ['1576065688', '1220789766']
}
return munch.munchify(chat_commands)
def get_storage_paths():
"""Returns filepaths"""
UNIQUE_ID = 'heroku/'
if local[0]:
# Firebase Cloud Storage File Paths
file_paths = {
"ADD_MESSAGE": "trade_result/message_count/",
"SAVE": "save_data/savefile",
"SAVE_TRADE": "trade_result/",
"LIVE_VIEW": "live_view/",
"LOG": 'log/',
"REALTIME_SAVE": 'signal/',
"DISCORD_CHANNEL": 'discord_channel/',
"TELEGRAM_CHANNEL": 'telegram_channel/',
"SIGNAL_ENDPOINT_URL": 'https://luchodore.pythonanywhere.com/test_data'
}
else:
# Heroku Version
file_paths = {
"ADD_MESSAGE": UNIQUE_ID + "trade_results/message_count/",
"SAVE": UNIQUE_ID + "save_data/savefile",
"SAVE_TRADE": UNIQUE_ID + "trade_results/",
"LIVE_VIEW": UNIQUE_ID + "live_view/",
"LOG": UNIQUE_ID + 'logs/',
"REALTIME_SAVE": UNIQUE_ID + 'signals/',
"DISCORD_CHANNEL": UNIQUE_ID + 'discord_channels/',
"TELEGRAM_CHANNEL": UNIQUE_ID + 'telegram_channels/',
"SIGNAL_ENDPOINT_URL": 'https://luchodore.pythonanywhere.com/save_data'
}
return munch.munchify(file_paths)