Skip to content

Commit

Permalink
Add intergrate naver-research
Browse files Browse the repository at this point in the history
  • Loading branch information
liante0904 committed Jul 17, 2024
1 parent c1adc06 commit 4caf1c3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions naver-research.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from package import googledrive
from package.SecretKey import SecretKey
from package.json_util import save_data_to_local_json # import the function from json_util
from package.json_util import save_data_to_local_json, get_unsent_main_ch_data_to_local_json, update_main_ch_send_yn_to_y # import the function from json_util

# import secretkey

Expand All @@ -38,6 +38,8 @@

SECRET_KEY = SecretKey()
SECRET_KEY.load_secrets()

JSON_FILE_NAME = './json/naver_research.json'
############ global 변수 끝 ############

def NAVER_Report_checkNewArticle():
Expand Down Expand Up @@ -92,7 +94,7 @@ def NAVER_Report_parse(ARTICLE_BOARD_ORDER, TARGET_URL):

# Use the imported save_data_to_local_json function with filename parameter
new_article_message = save_data_to_local_json(
filename='./json/naver_research.json',
filename=JSON_FILE_NAME,
sec_firm_order=SEC_FIRM_ORDER,
article_board_order=ARTICLE_BOARD_ORDER,
firm_nm=research['brokerName'],
Expand Down Expand Up @@ -145,6 +147,12 @@ async def sendMessage(sendMessageText): #실행시킬 함수명 임의지정
bot = telegram.Bot(token = SECRET_KEY.TELEGRAM_BOT_TOKEN_REPORT_ALARM_SECRET)
return await bot.sendMessage(chat_id = GetSendChatId(), text = sendMessageText, disable_web_page_preview = True, parse_mode = "Markdown")

async def sendMessageToMain(sendMessageText): #실행시킬 함수명 임의지정
global CHAT_ID
bot = telegram.Bot(token = SECRET_KEY.TELEGRAM_BOT_TOKEN_REPORT_ALARM_SECRET)
return await bot.sendMessage(chat_id = SECRET_KEY.TELEGRAM_CHANNEL_ID_REPORT_ALARM, text = sendMessageText, disable_web_page_preview = True, parse_mode = "Markdown")


# 가공없이 텍스트를 발송합니다.
def sendText(sendMessageText):
global CHAT_ID
Expand Down Expand Up @@ -201,6 +209,14 @@ def main():
print("NAVER_Report_checkNewArticle()=> 새 게시글 정보 확인") # 900
NAVER_Report_checkNewArticle()

lists = get_unsent_main_ch_data_to_local_json(JSON_FILE_NAME)
if lists:
for sendMessageText in lists:
asyncio.run(sendMessageToMain(sendMessageText))
update_main_ch_send_yn_to_y(JSON_FILE_NAME)

return True


if __name__ == "__main__":
main()

0 comments on commit 4caf1c3

Please sign in to comment.