-
Notifications
You must be signed in to change notification settings - Fork 8
/
tradetelegrambot.py
4638 lines (3634 loc) · 221 KB
/
tradetelegrambot.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from flask import Flask,jsonify
from config import DevelopmentConfig
from db import db
from backend.models import Telegram, TradeDataDefaults
from backend.models import Bybit as BybitModel
from backend.utils import security as auth_security
from flask_restx import Api,fields
from backend.controller.userAuth import api as userNS
from backend.controller.userAuth import api2 as authNS
from flask_cors import CORS
app = Flask(__name__)
app.config.from_object(DevelopmentConfig)
db.init_app(app)
CORS(app)
# manage file here
#!/usr/bin/env python
# -*- coding: utf-8 -*-ci
# pylint: disable=W0613, C0116
# type: ignore[union-attr]
# This program is dedicated to the public domain under the CC0 license.
from enum import Enum
from operator import pos # for enum34, or the stdlib version
import ccxt
from sqlalchemy.sql.sqltypes import DECIMAL
from sqlalchemy.sql import exists
from backend.extensions import MarketData
from backend.extensions import WebsocketMarket
from backend.extensions import Client as FuturesClient
import random
import csv
import string
from csv import writer
from csv import reader
# from decimal import *
import math
import logging
from datetime import datetime
from time import sleep
import time
import json
import ast
# import bybit
import argparse
import os
import sys
import click
import time
import logging
from flask import Flask, request, abort, session
from flask_session import Session
from loguru import logger
import threading, time
from telethon import TelegramClient, events, sync
import time
import json
from io import StringIO
import socket
import datetime
#import pyperclip
import os, ast
import subprocess
import re
import signal
import clipboard
#from jaraco import clipboard as clipboard2
# First we need the asyncio library
import asyncio
#from backend.extensions import db
from flask.cli import FlaskGroup, run_command
from flask_cors import CORS
# from backend.models import Bybit as BybitModel
# from backend.models import Telegram
from backend.extensions import Bybit
# from backend.database import BaseModel
from multiprocessing import Process
from flask_alembic import Alembic
from flask_session import Session
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import MetaData
from telethon import TelegramClient, events, sync
import time
alembic = Alembic()
# from backend.api import ModelResource
# from backend.extensions.api import api # url_prefix='/api/v1'
# from backend.security.models import Asset
# from backend.extensions import db
from flask import Blueprint, url_for
# from backend.api import CREATE, DELETE, GET, LIST, PATCH, PUT
from flask import jsonify, Flask
from flask_wtf.csrf import CSRFProtect
import requests
security = Blueprint('security', __name__, url_prefix='/auth',
template_folder='templates')
# csrf = CSRFProtect()
# csrf.init_app(app)
api = Api(app, version = "1.0",
title = "Crypttops BybitBot Api",
description = "Admin panel",
doc=False)
# adding the namespaces
api.add_namespace(userNS, path='/users')
api.add_namespace(authNS)
# Then we need a loop to work with
loop = asyncio.get_event_loop()
bot_token = "add your telegram token"
#curl http://127.0.0.1:5000/asset{"hello": "world"}
#curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST http://localhost:5000/asset
#maybe this method have defined below will be useful
#it will eliminate the aspect of receiving bot updates when you havent even started the bot
#it is useful so that a user only received automated updates only when they have started
#the bot
import random
import csv
import string
from csv import writer
from csv import reader
global result_str
result_str = ''
def get_random_string():
letters = string.ascii_lowercase
result_str = ''.join(random.choice(letters) for i in range(16))
print('value to write to file')
print(result_str)
result_str1 = [result_str, ]
print('----------------------------')
with open('tokens.csv', 'a+', newline='') as write_obj:
# Create a writer object from csv module
csv_writer = writer(write_obj)
# Add contents of list as last row in the csv file
csv_writer.writerow(result_str1)
return result_str
def save_order_ids(order_Id):
with open('orderId.csv', 'a+', newline='') as write_obj:
# Create a writer object from csv module
csv_writer = writer(write_obj)
# Add contents of list as last row in the csv file
csv_writer.writerow(order_Id)
return order_Id
import logging
from telegram import InlineKeyboardMarkup, InlineKeyboardButton, Update
from telegram.ext import (
Updater,
CommandHandler,
MessageHandler,
Filters,
ConversationHandler,
CallbackQueryHandler,
CallbackContext,
)
# Enable logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
)
logger = logging.getLogger(__name__)
# State definitions for top level conversation
SELECTING_ACTION, ADDING_MEMBER, ADDING_SELF, DESCRIBING_SELF = map(chr, range(4))
# State definitions for second level conversation
SELECTING_LEVEL, SELECTING_GENDER, SELECTING_TRADE = map(chr, range(4, 7))
# State definitions for descriptions conversation
SELECTING_FEATURE, SELECTING_FEATURE1, SELECTING_FEATURE2, SELECTING_FEATURE3, TYPING, TYPING1, TYPING2, TYPING3 = map(chr, range(7, 15))
# Meta states
STOPPING, SHOWING = map(chr, range(15, 17))
# Shortcut for ConversationHandler.END
END = ConversationHandler.END
# own settings
ENDMANUAL = map(chr, range(17, 18))
# Different constants for this example
(
PARENTS,
CHILDREN,
NEIGHBORS,
FOREIGNERS,
SELF,
GENDER,
MALE,
FEMALE,
AUTOMATED,
SETTINGS,
SHOW_SETTINGS,
WEBHOOK,
WEBHOOKR,
AGE,
NAME,
BUYETH,
BUYEOS,
BUYXRP,
SELLETH,
SELLEOS,
SELLXRP,
LEVERAGE,
CLOSE,
POSITION,
START_OVER,
FEATURES,
CURRENT_FEATURE,
CURRENT_LEVEL,
TAKEPROFIT,
STOPLOSS,
AMOUNTSETTING,
TRAILINGSTOP,
NEWTRAILINGACTIVE,
LEVERAGESETTING,
) = map(chr, range(18, 52))
global telegram_id
global first_name
global second_name
telegram_id = ''
first_name = ''
second_name = ''
# http://a0902b3e4a41.ngrok.io/webhook/zulhfezpankgalke
def get_random_string():
letters = string.ascii_lowercase
result_str = ''.join(random.choice(letters) for i in range(16))
print('value to write to file')
print(result_str)
result_str1 = [result_str, ]
print('----------------------------')
with open('tokens.csv', 'a+', newline='') as write_obj:
# Create a writer object from csv module
csv_writer = writer(write_obj)
# Add contents of list as last row in the csv file
csv_writer.writerow(result_str1)
return result_str
def checkPositionExistsAutomated(user_trade_data):
has_position = False
textp =''
print("Trade symbol...................", user_trade_data['symbol'])
trade_symbol = user_trade_data['symbol']
vvery12 = telegram_id
with app.app_context():
api_data = db.session.query(Telegram.api_key, Telegram.api_secret,Telegram.verified, Telegram.first_name,Telegram.second_name).filter(Telegram.telegramid==user_trade_data['TelegramID']).all()
#and thhis is API KEY AND SECRET of the Leder
api_key = api_data[0][0]
api_secret = api_data[0][1]
try:
bybit1 = Bybit(api_key=api_key,
secret=api_secret, symbol=trade_symbol, ws=True, test=False)
position1 = bybit1.get_position_http()
print('---------------------------New Position DATA----------------------------------')
position_result1 = position1['result']
json.dumps(position_result1, indent=2)
# update1.message.reply_text('Your Bybit Positions')
botu_message = 'Your Bybit Positions\n\n'
print('auto_resultauto_resultauto_resultauto_resultauto_resultauto_resultauto_resultauto_resultauto_resultauto_resultauto_resultauto_resultauto_resultauto_resultauto_result')
print(position_result1)
# if position_result1['data'] is None :
# else:
print(len(position_result1))
for x in range(len(position_result1)):
# print("\n\n\n\n\n\n\n\n\n----------------------------&&&&&&&&&&&&&&&&&&&&&",position_result1[x]['symbol'], trade_symbol, user_trade_data['side'], position_result1[x]['side'] )
if position_result1[x]['data']['symbol'] == trade_symbol and position_result1[x]['data']['side'] == user_trade_data['side']:
textp = "You are already in a trade:\n side | {0}| size | {1} \n Wait until the position is closed before opening another trade of the same asset.".format(position_result1[x]['data']['side'],position_result1[x]['data']['size'])
print(textp)
has_position = True
if position_result1[x]['data']['symbol'] == trade_symbol and position_result1[x]['data']['side'] == 'None':
# update1.message.reply_text('You have no open position')
bot_message1 = 'You have no open position'
textp = bot_message1
has_position = False
except:
textp = "There is something wrong, your current positions could not be fetched from Bybit."
return has_position, textp
@app.route('/webhook', methods=['POST'])
def webhook():
textp = ''
print('Webhook REsource Started to manage Auto-TRading from TradingView')
#generate api id and hash on https://my.telegram.org
#name = 'Bybit_TradingView_Bot'
list_of_rows = [[]]
# read csv file as a list of lists
with open('tokens.csv', 'r') as read_obj:
# pass the file object to reader() to get the reader object
csv_reader = reader(read_obj)
# Pass reader object to list() to get a list of lists
list_of_rows = list(csv_reader)
print('list_of_rows', list_of_rows)
token = '111'
print('token = ', token)
#generate api id and hash on https://my.telegram.org
#name = 'Bybit_TradingView_Bot'
list_of_rows_access = [[]]
# read csv file as a list of lists
with open('access.csv', 'r') as read_obj:
# pass the file object to reader() to get the reader object
csv_reader = reader(read_obj)
# Pass reader object to list() to get a list of lists
list_of_rows_access = list(csv_reader)
print('list_of_rows_access', list_of_rows_access)
print('token = ', token)
toList = []
toListAccess = []
if request.method == 'POST':
datart = request.get_data(as_text=True)
print(datart)
# y_dict = ast.literal_eval(datart)
y_dict = json.loads(datart)
for i in range(len(list_of_rows)):
rt = str(list_of_rows[i])[1:]
tr = rt[1:]
re = tr[:-1]
rew = re[:-1]
toList.append(rew)
for i in range(len(list_of_rows_access)):
rt = str(list_of_rows_access[i])[1:]
tr = rt[1:]
re = tr[:-1]
rew = re[:-1]
toListAccess.append(rew)
# print('toListAccess', toListAccess, 'passed token', y_dict['token'])
with app.app_context():
authenticated = bool(db.session.query(Telegram).filter_by(telegramid = int(y_dict['TelegramID'])).first())
# if token in toList:
if authenticated == True:
print('token found')
#datart = datarc[1:-1]
print('===================================================')
print(datart)
print('===================================================')
bot_token = 'add telegram token here'
bot_chatID =y_dict['TelegramID']
print("bot chat id", bot_chatID)
#datart = '{"type": "market", "side": "buy", "amount": "97", "leftAsset" : "BTC", "rightAsset" : "USDT","leverage":"10", "takeProfit" : "None","stopLoss":"None","trailingStop":"None", "new_trailing_active":"None", "TelegramID":"1093054762"}'
if datart != None :
# bot_message = datart
# send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&parse_mode=Markdown&text=' + bot_message
# #https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
# response = requests.get(send_text)
# bot_message = '*Telegram ID* : ' ''+ str(bot_chatID) +'' ' \n '' '
# bot_message1 = datart
# send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + bot_message + bot_message1
# #https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
# response = requests.get(send_text)
# my code running perfectly
print('Trade request received from TradingView.')
has_positions, textresponse = checkPositionExistsAutomated(y_dict)
print("\n\n\n\n\n******************++++++++++++++++++++++", has_positions, textresponse)
if has_positions ==True:
textp = textresponse
bot_message = textp
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + str(bot_chatID) + '&parse_mode=Markdown&text=' + bot_message
response = requests.get(send_text)
else:
ret_msg, error_reta, placed_btc_value, created_at, final_entry_price = send_order_v2(y_dict)
print('ret_msg', ret_msg)
print('error_reta', error_reta)
print('placed_btc_value', placed_btc_value)
print('final_entry_price', final_entry_price)
try:
placedbtcvalue = "%.6f"%float(placed_btc_value)
except:
placedbtcvalue = " "
vvery12 = y_dict['TelegramID']
# if error_reta is not None:
# bot_message = ' *'+error_reta+'* ' + str(placedbtcvalue) + ' BTC contracts. *Filled entry* '''+ created_at +'' ' ''' + str(placedbtcvalue) +'' '@ $'+str(round(float(final_entry_price), 5))+''
# print("bot message ", bot_message)
# send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + str(bot_chatID) + '&parse_mode=Markdown&text=' + bot_message
# #https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
# response = requests.get(send_text)
# bot_message = '*Telegram ID* : ' ''+ str(bot_chatID) +'' ' \n '' '
# bot_message1 = ''+ error_reta +''
# send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + bot_message + bot_message1
# #https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
# response = requests.get(send_text)
# else:
# bot_message = error_reta
# send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&parse_mode=Markdown&text=' + bot_message
# #https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
# response = requests.get(send_text)
# bot_message = '*Telegram ID* : ' ''+ str(bot_chatID) +'' ' \n '' '
# bot_message1 = ''+ error_reta +''
# send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + bot_message + bot_message1
# #https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
# response = requests.get(send_text)
if ret_msg == 'OK' or ret_msg == 'ok':
# print(float(placed_btc_value))
# update1.message.reply_text(' *Manual Order Received: Buy* ' + str(round(float(placed_btc_value), 5)) + ' BTC contracts\n \n'
# 'Filled entry ' ''+ created_at +'' ' \n \n '
# '' + str(round(float(placed_btc_value), 5)) +'' '@ $'+str(round(float(final_entry_price), 5))+'')
bot_message = '*Telegram ID* : ' ''+ str(vvery12) +'' ' \n '' '
bot_message1 = '*Name* : ' + first_name + ' ' + second_name + ' \n '' '
bot_message2 = '*Sir Name* : ' ''+ second_name +' \n '' '
bot_message3 = '*Automated Order Received: * ' + str(placedbtcvalue) + ' ' + y_dict['symbol'] + ' \n '' '
bot_message4 = '*Filled entry*' ''+ str(created_at) +'\n '' '
bot_message5 = '' + str(placedbtcvalue) +' BTC' '@ $'+str(round(float(final_entry_price), 5))+''
# send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + bot_message + bot_message1 + bot_message2 +bot_message3 +bot_message4 + bot_message5
# #https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
# response = requests.get(send_text)
# send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '146943702' + '&parse_mode=Markdown&text=' + bot_message + bot_message1 + bot_message2 +bot_message3 +bot_message4 + bot_message5
# #https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
# response = requests.get(send_text)
textp = bot_message3 + bot_message4 + bot_message5
if error_reta.startswith('TrailingStop:') or ret_msg.startswith('TrailingStop:'):
print(float(placed_btc_value))
# update1.message.reply_text(error_reta)
# update1.message.reply_text(' *Manual Order Received: Buy* ' + str(round(float(placed_btc_value), 5)) + ' BTC contracts\n \n'
# 'Filled entry ' ''+ created_at +'' ' \n \n '
# '' + str(round(float(placed_btc_value), 5)) +'' '@ $'+str(round(float(final_entry_price), 5))+'')
bot_message = '*Telegram ID* : ' ''+ str(vvery12) +'' ' \n '' '
bot_message1 = '*Name* : ' + first_name + ' ' + second_name + ' \n '' '
bot_message2 = '*Sir Name* : ' ''+ second_name +' \n '' '
bot_message3 = '*' +y_dict['side'] + '*' + '*Automated Order Received: * ' + str(placedbtcvalue) + ' ' + y_dict['symbol'] + ' \n '' '
bot_message4 = '*Filled entry*' ''+ str(created_at) +'\n '' '
bot_message5 = '' + str(placedbtcvalue) +'' '@ $'+str(round(float(final_entry_price), 5))+''
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + bot_message + bot_message1 + bot_message2 +bot_message3 +bot_message4 + bot_message5
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '146943702' + '&parse_mode=Markdown&text=' + bot_message + bot_message1 + bot_message2 +bot_message3 +bot_message4 + bot_message5
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
textp = bot_message3 + bot_message4 + bot_message5
if ret_msg == 'empty price':
# update1.message.reply_text('Your buy Order Not successful')
# update1.message.reply_text('You have no funds in your Bybit Account')
# update1.message.reply_text('Top up to continue using the Bot')
bot_message = '*Telegram ID* : ' ''+ str(vvery12) +'' ' \n '' '
bot_message1 = '*Name* : ' + first_name + ' ' + second_name + ' \n '' '
bot_message2 = '*Sir Name* : ' ''+ second_name +' \n '' '
bot_message3 = 'Your buy Order Not successful' '\n '' '
bot_message4 = 'You have no funds in your Bybit Account ' ' \n '
bot_message5 = 'Top up to continue using the Bot'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + bot_message + bot_message1 + bot_message2 +bot_message3 +bot_message4 + bot_message5
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '146943702' + '&parse_mode=Markdown&text=' + bot_message + bot_message1 + bot_message2 +bot_message3 +bot_message4 + bot_message5
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
textp = bot_message3 + bot_message4 + bot_message5
if error_reta.startswith('error sign!'):
# update1.message.reply_text('Your sell Order Not successful though leverage was set')
# update1.message.reply_text('Your quantity was not correct, you can reduce the percentage of amount. ')
# update1.message.reply_text('Or you can top up to continue using the Bot')
# update1.message.reply_text(' *Manual Order Received: Buy* ' + str(round(float(placed_btc_value), 5)) + ' BTC contracts\n \n'
# 'Filled entry ' ''+ created_at +'' ' \n \n '
# '' + str(round(float(placed_btc_value), 5)) +'' '@ $'+str(round(float(final_entry_price), 5))+'')
bot_message = '*Telegram ID* : ' ''+ str(vvery12) +'' ' \n '' '
bot_message1 = '*Name* : ' + first_name + ' ' + second_name + ' \n '' '
bot_message2 = '*Sir Name* : ' ''+ second_name +' \n '' '
bot_message3 = 'Your buy Order Not successful' '\n '' '
bot_message4 = 'You have no funds in your Bybit Account ' ' \n \n '
bot_message5 = 'Top up to continue using the Bot'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + bot_message + bot_message1 + bot_message2 +bot_message3 +bot_message4 + bot_message5
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '146943702' + '&parse_mode=Markdown&text=' + bot_message + bot_message1 + bot_message2 +bot_message3 +bot_message4 + bot_message5
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
textp = bot_message3 + bot_message4 + bot_message5
# Param validation for
if error_reta.startswith('Param validation') or ret_msg.startswith('Param validation'):
# update1.message.reply_text('You have insuffient Balance to Place this Order. Check the percentage of Amount you are passing\n')
# update1.message.reply_text('Your quantity was not correct, you can reduce the percentage of amount. ')
# update1.message.reply_text('Or you can top up to continue using the Bot')
# update1.message.reply_text('Type /stop to restart the bot')
bot_message = '*Telegram ID* : ' ''+ str(vvery12) +'' ' \n '' '
bot_message1 = '*Name* : ' + first_name + ' ' + second_name + ' \n '' '
bot_message2 = '*Sir Name* : ' ''+ second_name +' \n '' '
bot_message3 = 'Your buy Order Not successful' '\n '' '
bot_message4 = 'You have no funds in your Bybit Account ' ' \n \n '
bot_message5 = 'Top up to continue using the Bot'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + bot_message + bot_message1 + bot_message2 +bot_message3 +bot_message4 + bot_message5
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '146943702' + '&parse_mode=Markdown&text=' + bot_message + bot_message1 + bot_message2 +bot_message3 +bot_message4 + bot_message5
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
botu_message = 'You have insuffient Balance to Place this Order. Check the percentage of Amount you are passing\n'
botu_message1 = 'Your quantity was not correct, you can reduce the percentage of amount. '
botu_message2 = 'Or you can top up to continue using the Bot'
textp = botu_message + botu_message1 + botu_message2
if error_reta.startswith('incorrect'):
textp = "something is wrong\n Check your default settings \n \n "
bot_message = textp
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + str(bot_chatID) + '&parse_mode=Markdown&text=' + bot_message
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
else:
bot_message = 'No valid message received from TradingView eligible of placing trade on your Bybit Account'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + str(bot_chatID) + '&parse_mode=Markdown&text=' + bot_message
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
print('Automated Webhook Sent for processing')
bot_message = '*Telegram ID* : ' ''+ str(bot_chatID) +'' ' \n '' '
bot_message1 = 'No valid message received from TradingView eligible of placing trade on your Bybit Account'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + bot_message + bot_message1
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
else:
print('you not authenticated to use this bot')
print('token not found')
print('You have wrong settings for your url. Click Webhook button to get correct format')
# bot_message = 'token not found. Ensure you have correct token to use the bot'
bot_message = 'you are not authenticated to use this bot\n Visit https://www.bybit.com/en-US/invite?ref=J6WWOV to create a Bybit account and get API keys.\n'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&parse_mode=Markdown&text=' + bot_message
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
print('Automated Webhook Sent for processing')
bot_message = '*Telegram ID* : ' ''+ str(bot_chatID) +'' ' \n '' '
bot_message1 = 'You have wrong settings for your url. Click Webhook button to get correct format'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + bot_message + bot_message1
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
abort(400)
print('_____________TESTING ASSET WITHOUT MODEL RESURCE______________________')
return "WEBHOOK CALLED"
@app.route('/close', methods=['GET','POST'])
def close():
print('Webhook REsource Started to manage Auto-TRading from TradingView')
#generate api id and hash on https://my.telegram.org
#name = 'Bybit_TradingView_Bot'
list_of_rows = [[]]
# read csv file as a list of lists
with open('tokens.csv', 'r') as read_obj:
# pass the file object to reader() to get the reader object
csv_reader = reader(read_obj)
# Pass reader object to list() to get a list of lists
list_of_rows = list(csv_reader)
#generate api id and hash on https://my.telegram.org
#name = 'Bybit_TradingView_Bot'
list_of_rows_access = [[]]
# read csv file as a list of lists
with open('access.csv', 'r') as read_obj:
# pass the file object to reader() to get the reader object
csv_reader = reader(read_obj)
# Pass reader object to list() to get a list of lists
list_of_rows_access = list(csv_reader)
print('list_of_rows_access', list_of_rows_access)
token = '11111'
print('token = ', token)
toList = []
toListAccess = []
if request.method == 'POST':
datart = request.get_data(as_text=True)
# y_dict = ast.literal_eval(datart)
y_dict = json.loads(datart)
for i in range(len(list_of_rows)):
rt = str(list_of_rows[i])[1:]
tr = rt[1:]
re = tr[:-1]
rew = re[:-1]
toList.append(rew)
for i in range(len(list_of_rows_access)):
rt = str(list_of_rows_access[i])[1:]
tr = rt[1:]
re = tr[:-1]
rew = re[:-1]
toListAccess.append(rew)
# print('toListAccess', toListAccess, 'passed token', y_dict['token'])
# if token in toList and y_dict['token'] in toListAccess:
with app.app_context():
authenticated = bool(db.session.query(Telegram).filter_by(telegramid = int(y_dict['TelegramID'])).first())
# if token in toList:
if authenticated == True:
print('token found')
#datart = datarc[1:-1]
print('===================================================')
print(datart)
print('===================================================')
# y_dict = ast.literal_eval(datart)
bot_token = 'add telegram token here'
y_dict = json.loads(datart)
bot_chatID = y_dict['TelegramID']
#datart = '{"type": "Market", "side": "Buy", "amount": "97", "symbol": "BTCUSD","leverage":"10", "takeProfit" : "None","stopLoss":"None","trailingStop":"None", "new_trailing_active":"None", "TelegramID":"1093054762"}'
if datart != None :
# my code running perfectly
print('Trade request received from TradingView.')
closes = close_webhook(y_dict)
print("Printing closes------------", closes)
if closes !='None' or None:
bot_message = closes
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&parse_mode=Markdown&text=' + bot_message
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
bot_message = '*Telegram ID* : ' ''+ str(bot_chatID) +'' ' \n '' '
bot_message1 = closes
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + bot_message + bot_message1
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
else:
bot_message = 'Positions already closed'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&parse_mode=Markdown&text=' + bot_message
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
bot_message = '*Telegram ID* : ' ''+ str(bot_chatID) +'' ' \n '' '
bot_message1 = 'Positions already closed'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + bot_message + bot_message1
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
else:
bot_message = 'No valid message received from TradingView eligible of closing trade on your Bybit Account'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&parse_mode=Markdown&text=' + bot_message
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
print('Automated Webhook Sent for processing')
bot_message = '*Telegram ID* : ' ''+ str(bot_chatID) +'' ' \n '' '
bot_message1 = 'No valid message received from TradingView eligible of closing trade on your Bybit Account'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + bot_message + bot_message1
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
else:
print('you not authenticated to use this bot')
print('token not found')
print('You have wrong settings for your url. Click Webhook button to get correct format')
# bot_message = 'token not found. Ensure you have correct token to use the bot'
bot_message = 'you are not authenticated to use this bot\n Visit https://www.bybit.com/en-US/invite?ref=J6WWOV to create a Bybit account and get API keys.\n'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&parse_mode=Markdown&text=' + bot_message
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
print('Automated Webhook Sent for processing')
bot_message = '*Telegram ID* : ' ''+ str(bot_chatID) +'' ' \n '' '
bot_message1 = 'token not found. Ensure you have correct token to use the bot'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + bot_message + bot_message1
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
abort(400)
print('_____________TESTING ASSET WITHOUT MODEL RESURCE______________________')
return "WEBHOOK CALLED"
@app.route('/leverage', methods=['GET','POST'])
def leverage():
print('CLOSE Webhook REsource Started to manage Auto-TRading from TradingView')
list_of_rows = [[]]
# read csv file as a list of lists
with open('tokens.csv', 'r') as read_obj:
# pass the file object to reader() to get the reader object
csv_reader = reader(read_obj)
# Pass reader object to list() to get a list of lists
list_of_rows = list(csv_reader)
token = '1111'
print('token = ', token)
#generate api id and hash on https://my.telegram.org
#name = 'Bybit_TradingView_Bot'
list_of_rows_access = [[]]
# read csv file as a list of lists
with open('access.csv', 'r') as read_obj:
# pass the file object to reader() to get the reader object
csv_reader = reader(read_obj)
# Pass reader object to list() to get a list of lists
list_of_rows_access = list(csv_reader)
print('list_of_rows_access', list_of_rows_access)
print('token = ', token)
toList = []
toListAccess = []
if request.method == 'POST':
datart = request.get_data(as_text=True)
# y_dict = ast.literal_eval(datart)
y_dict = json.loads(datart)
for i in range(len(list_of_rows)):
rt = str(list_of_rows[i])[1:]
tr = rt[1:]
re = tr[:-1]
rew = re[:-1]
toList.append(rew)
for i in range(len(list_of_rows_access)):
rt = str(list_of_rows_access[i])[1:]
tr = rt[1:]
re = tr[:-1]
rew = re[:-1]
toListAccess.append(rew)
# print('toListAccess', toListAccess, 'passed token', y_dict['token'])
# if token in toList and y_dict['token'] in toListAccess:
print('token found')
#datart = datarc[1:-1]
with app.app_context():
authenticated = bool(db.session.query(Telegram).filter_by(telegramid = int(y_dict['TelegramID'])).first())
# if token in toList:
if authenticated == True:
print('===================================================')
print(datart)
print('===================================================')
# y_dict = ast.literal_eval(datart)
y_dict = json.loads(datart)
bot_token = 'add token here'
bot_chatID = y_dict['TelegramID']
#datart = '{"type": "Market", "side": "Buy", "amount": "97", "symbol": "BTCUSD","leverage":"10", "takeProfit" : "None","stopLoss":"None","trailingStop":"None", "new_trailing_active":"None", "TelegramID":"1093054762"}'
if datart != None :
# my code running perfectly
print('Trade request received from TradingView.')
current_manual_leverage, adjusted_manual_leverage, manual_leverage= set_manual_leverage(y_dict)
bot_message2 = 'Leverage Adjusted to:'
send_text2 = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + str(bot_chatID) + '&parse_mode=Markdown&text=' + bot_message2
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response2 = requests.get(send_text2)
bot_message = current_manual_leverage
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + str(bot_chatID) + '&parse_mode=Markdown&text=' + str(bot_message)
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
bot_message = '*Telegram ID* : ' ''+ str(bot_chatID) +'' ' \n '' '
bot_message1 = current_manual_leverage
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + str(bot_message) + str(bot_message1)
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
"""
bot_message3 = 'New Set Leverage'
send_text3 = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + str(bot_chatID) + '&parse_mode=Markdown&text=' + str(bot_message3)
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response3 = requests.get(send_text2)
bot_message1 = adjusted_manual_leverage
send_text1 = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + str(bot_chatID) + '&parse_mode=Markdown&text=' + str(bot_message1)
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response1 = requests.get(send_text1)
bot_message4 = 'You can click the Positions/Balances button to confirm your positions. Remember to start the bot for this to work'
send_text4 = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + str(bot_chatID) + '&parse_mode=Markdown&text=' + str(bot_message4)
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response4 = requests.get(send_text1)
"""
else:
bot_message = 'No valid message received from TradingView eligible of changing leverage on your Bybit Account'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + str(bot_chatID) + '&parse_mode=Markdown&text=' + str(bot_message)
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
print('Automated Webhook Sent for processing')
bot_message = '*Telegram ID* : ' ''+ str(bot_chatID) +'' ' \n '' '
bot_message1 = 'No valid message received from TradingView eligible of changing leverage on your Bybit Account'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + bot_message + bot_message1
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
else:
print('you not authenticated to use this bot')
print('token not found')
print('You have wrong settings for your url. Click Webhook button to get correct format')
# bot_message = 'token not found. Ensure you have correct token to use the bot'
bot_message = 'you are not authenticated to use this bot\n Visit https://www.bybit.com/en-US/invite?ref=J6WWOV to create a Bybit account and get API keys.\n'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&parse_mode=Markdown&text=' + bot_message
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
print('Automated Webhook Sent for processing')
bot_message = '*Telegram ID* : ' ''+ str(bot_chatID) +'' ' \n '' '
bot_message1 = 'You have wrong settings for your url. Click Webhook button to get correct format'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + '1093054762' + '&parse_mode=Markdown&text=' + bot_message + bot_message1
#https://api.telegram.org/botAAEXuaj6a029wmrNBnOCSFpPadIWga7KOBk/sendMessage?chat_id=1093054762&parse_mode=Markdown&text=atomatedtradingview
response = requests.get(send_text)
abort(400)
print('_____________TESTING ASSET WITHOUT MODEL RESURCE______________________')
return "WEBHOOK CALLED"
def error_ret(error_rets):
error_reta = error_rets
def keysf(*args):
saved_args = locals()
keys = args
print('------keyss--------secretss--------------')
print(str(keys)[1:-1])
#print(saved_args)
global uid
global keyss
global secretss
uid = keys[0]
keyss = keys[1]
secretss = keys[2]
print('-------uids-------00000000---keyss--------secretss-------000000000-------')
thisdict["Uid"] = uid
thisdict["Key"] = keyss
thisdict["Secret"] = secretss
print(thisdict)
with open('keys.json','w') as student_dumped :
json.dump(thisdict,student_dumped)
with open('keys.json', 'r+') as json_file:
datasa = json.load(json_file)
print('Data Read From File', datasa)
datasa.update(thisdict)
print('Updated Data', datasa)
json_file.seek(0)
json.dump(datasa,json_file)
return datasa
def uids(*args):
saved_args = locals()
keys = args
print('------keyss--------secretss--------------')
print(str(keys)[1:-1])
#print(saved_args)
global keyss
keyss = keys[0]
print('---00000000---keyss--------secretss-------000000000-------')
thisdict1["uids"] = keyss
print(thisdict1)
with open('uids.json', 'r+') as json_file:
datasas = json.load(json_file)
print('Data Read From File', datasas)
datasas.update(thisdict1)
print('Updated Data', datasas)
json_file.seek(0)
json.dump(datasas,json_file)
with open('uids.json','w') as student_dumped :
json.dump(thisdict1,student_dumped)
return datasas
def buidtuid(*args):
saved_args = locals()
keysa = args
print('------keyss--------secretss--------------')
print(str(keys)[1:-1])
#print(saved_args)
global tuid
global buidtuid
uid = keysa[0]
keyss = keysa[1]
thisdicta = {
""+uid+"": 0,
""+keyss+"": 0
}
print('-------uids-------00000000---keyss--------secretss-------000000000-------')
thisdicta[""+uid+""] = uid
thisdicta[""+keyss+""] = keyss
print(thisdicta)
with open('keys.json','w') as student_dumped :
json.dump(thisdicta,student_dumped)
with open('keys.json', 'r+') as json_file:
datasa = json.load(json_file)
print('Data Read From File', datasa)
datasa.update(thisdict)
print('Updated Data', datasa)
json_file.seek(0)
json.dump(datasa,json_file)
return datasa
def parse__price_webhook(data):
bybit_ids = ''
with app.app_context():
recordss = db.session.query(Telegram.api_key).filter(Telegram.telegramid == data['TelegramID']).all()
print(recordss)
asset_to_idss = str(recordss)[1:-1]
asset_to_idsss = str(asset_to_idss)[1:-1]
asset_to_idssss = str(asset_to_idsss)[1:-1]