init
This commit is contained in:
@@ -24,9 +24,9 @@ class TelegramBot:
|
||||
username for the bot: ncue_stock_bot
|
||||
token to access the HTTP API: 6874078562:AAEHxGDavfc0ssAXPQIaW8JGYmTR7LNUJOw
|
||||
"""
|
||||
self.botname = "stockbot"
|
||||
self.username = "ncue_stock_bot"
|
||||
self.token = "6874078562:AAEHxGDavfc0ssAXPQIaW8JGYmTR7LNUJOw"
|
||||
self.botname = "coinbot"
|
||||
self.username = "ncue_coin_bot"
|
||||
self.token = "6435061393:AAHOh9wB5yGNGUdb3SfCYJrrWTBe7wgConM"
|
||||
self.chat_id = '574661323'
|
||||
self.client = telegram.Bot(token=self.token)
|
||||
|
||||
@@ -37,7 +37,7 @@ class TelegramBot:
|
||||
|
||||
@staticmethod
|
||||
def send(text):
|
||||
client = telegram.Bot(token="6874078562:AAEHxGDavfc0ssAXPQIaW8JGYmTR7LNUJOw")
|
||||
client = telegram.Bot(token="6435061393:AAHOh9wB5yGNGUdb3SfCYJrrWTBe7wgConM")
|
||||
if platform.system().lower() == 'windows':
|
||||
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
||||
asyncio.run(client.send_message(chat_id='574661323', text=text))
|
||||
@@ -49,29 +49,29 @@ class TelegramBot:
|
||||
text = "[ALIVE] {} {} ({})".format(this_time.strftime('%H:%M'), stock_code, stock_name)
|
||||
pool = Pool(12)
|
||||
pool.map(self.send, [text])
|
||||
print(text)
|
||||
print(" * "+text)
|
||||
|
||||
return
|
||||
|
||||
def post(self, stock_code, stock_name, type, price, amount, rsi, balance=0):
|
||||
def post(self, stock_code, stock_name, type, price, count, rsi, balance=0):
|
||||
if self.enable:
|
||||
this_time = datetime.now()
|
||||
if 0 < balance:
|
||||
text = "{}, {}, code: {}, name: {}, price: {}, amount: {}, (balance: {:2f}), (rsi: {:2f})".format(type, this_time.strftime('%H:%M'), stock_code, stock_name, price, amount, balance, rsi)
|
||||
text = "{}, {}, code: {}, name: {}, amount: {}, price: {}, count: {}, (balance: {:.2f}), (rsi: {:.2f})".format(type, this_time.strftime('%H:%M'), stock_code, stock_name, price*count, price, count, balance, rsi)
|
||||
else:
|
||||
text = "{}, {}, code: {}, name: {}, price: {}, amount: {}, (rsi: {:2f})".format(type, this_time.strftime('%H:%M'), stock_code, stock_name, price, amount, rsi)
|
||||
text = "{}, {}, code: {}, name: {}, amount: {}, price: {}, count: {}, (rsi: {:.2f})".format(type, this_time.strftime('%H:%M'), stock_code, stock_name, price*count, price, count, rsi)
|
||||
pool = Pool(12)
|
||||
pool.map(self.send, [text])
|
||||
print(text)
|
||||
print(" * "+text)
|
||||
return
|
||||
|
||||
def sendMsg(self, msg):
|
||||
if self.enable:
|
||||
this_time = datetime.now()
|
||||
text = "{}: {}".format(this_time.strftime('%H:%M'), msg)
|
||||
text = "[{}]\n{}".format(this_time.strftime("%H:%M:%S"), msg)
|
||||
pool = Pool(12)
|
||||
pool.map(self.send, [text])
|
||||
print(text)
|
||||
print(" * "+text)
|
||||
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user