This commit is contained in:
dsyoon
2024-03-20 22:42:10 +09:00
parent 8b8b89c0a1
commit 2a746c72c8

View File

@@ -24,9 +24,9 @@ class TelegramBot:
username for the bot: ncue_stock_bot username for the bot: ncue_stock_bot
token to access the HTTP API: 6874078562:AAEHxGDavfc0ssAXPQIaW8JGYmTR7LNUJOw token to access the HTTP API: 6874078562:AAEHxGDavfc0ssAXPQIaW8JGYmTR7LNUJOw
""" """
self.botname = "stockbot" self.botname = "coinbot"
self.username = "ncue_stock_bot" self.username = "ncue_coin_bot"
self.token = "6874078562:AAEHxGDavfc0ssAXPQIaW8JGYmTR7LNUJOw" self.token = "6435061393:AAHOh9wB5yGNGUdb3SfCYJrrWTBe7wgConM"
self.chat_id = '574661323' self.chat_id = '574661323'
self.client = telegram.Bot(token=self.token) self.client = telegram.Bot(token=self.token)
@@ -37,7 +37,7 @@ class TelegramBot:
@staticmethod @staticmethod
def send(text): def send(text):
client = telegram.Bot(token="6874078562:AAEHxGDavfc0ssAXPQIaW8JGYmTR7LNUJOw") client = telegram.Bot(token="6435061393:AAHOh9wB5yGNGUdb3SfCYJrrWTBe7wgConM")
if platform.system().lower() == 'windows': if platform.system().lower() == 'windows':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(client.send_message(chat_id='574661323', text=text)) 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) text = "[ALIVE] {} {} ({})".format(this_time.strftime('%H:%M'), stock_code, stock_name)
pool = Pool(12) pool = Pool(12)
pool.map(self.send, [text]) pool.map(self.send, [text])
print(text) print(" * "+text)
return 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: if self.enable:
this_time = datetime.now() this_time = datetime.now()
if 0 < balance: 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: 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 = Pool(12)
pool.map(self.send, [text]) pool.map(self.send, [text])
print(text) print(" * "+text)
return return
def sendMsg(self, msg): def sendMsg(self, msg):
if self.enable: if self.enable:
this_time = datetime.now() 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 = Pool(12)
pool.map(self.send, [text]) pool.map(self.send, [text])
print(text) print(" * "+text)
return return