init
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from datetime import datetime
|
||||
import telegram
|
||||
import asyncio
|
||||
from multiprocessing import Pool
|
||||
|
||||
class TelegramBot:
|
||||
enable = None
|
||||
@@ -31,13 +31,21 @@ class TelegramBot:
|
||||
self.enable = enable
|
||||
return
|
||||
|
||||
# https://velog.io/@gyunghoe/%ED%85%94%EB%A0%88%EA%B7%B8%EB%9E%A8-%EB%B4%87-%EC%84%B1%EB%8A%A5-%EC%B5%9C%EC%A0%81%ED%99%94%ED%95%98%EA%B8%B0
|
||||
|
||||
@staticmethod
|
||||
def send(text):
|
||||
client = telegram.Bot(token="6435061393:AAHOh9wB5yGNGUdb3SfCYJrrWTBe7wgConM")
|
||||
#client.sendMessage(chat_id='574661323', text=text)
|
||||
client.send_message(chat_id='574661323', text=text)
|
||||
return
|
||||
|
||||
def alarm_live(self, stock_code, stock_name):
|
||||
if self.enable:
|
||||
this_time = datetime.now()
|
||||
text = "ALIVE (" + this_time.strftime('%Y-%m-%d %H:%M:%S') + ") " + stock_code + "(" + stock_name +")"
|
||||
asyncio.run(
|
||||
self.client.sendMessage(chat_id=self.chat_id, text=text)
|
||||
)
|
||||
pool = Pool(12)
|
||||
pool.map(self.send, [text])
|
||||
print(text)
|
||||
|
||||
return
|
||||
@@ -46,9 +54,8 @@ class TelegramBot:
|
||||
if self.enable:
|
||||
this_time = datetime.now()
|
||||
text = "DATE TIME:" + this_time.strftime('%Y-%m-%d %H:%M:%S') + ", " + "stock_code:" + stock_code + ", " + "stock_name:" + stock_name + ", " + "type:" + type + ", " + "price:" + str(price) + ", " + "count:" + str(count)
|
||||
asyncio.run(
|
||||
self.client.sendMessage(chat_id=self.chat_id, text=text)
|
||||
)
|
||||
pool = Pool(12)
|
||||
pool.map(self.send, [text])
|
||||
print(text)
|
||||
return
|
||||
|
||||
@@ -56,9 +63,8 @@ class TelegramBot:
|
||||
if self.enable:
|
||||
this_time = datetime.now()
|
||||
text = "DATE TIME:" + this_time.strftime('%Y-%m-%d %H:%M:%S') + ", " + "msg:" + msg
|
||||
asyncio.run(
|
||||
self.client.sendMessage(chat_id=self.chat_id, text=text)
|
||||
)
|
||||
pool = Pool(12)
|
||||
pool.map(self.send, [text])
|
||||
print(text)
|
||||
|
||||
return
|
||||
@@ -71,7 +77,6 @@ if __name__ == "__main__":
|
||||
price = 2000
|
||||
count = 2
|
||||
|
||||
telegramBot = TelegramBot(True)
|
||||
telegramBot = TelegramBot()
|
||||
telegramBot.alarm_live(stock_code, stock_name)
|
||||
telegramBot.post(stock_code, stock_name, type, price, count)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user