wlstp8473

resturan location using html map

...@@ -3,7 +3,7 @@ import telegram ...@@ -3,7 +3,7 @@ import telegram
3 from telegram.ext import Updater 3 from telegram.ext import Updater
4 from telegram.ext import MessageHandler, Filters 4 from telegram.ext import MessageHandler, Filters
5 import os 5 import os
6 - 6 +import webbrowser
7 import telegram 7 import telegram
8 from telegram.ext import Updater 8 from telegram.ext import Updater
9 from telegram.ext import MessageHandler, Filters 9 from telegram.ext import MessageHandler, Filters
...@@ -132,6 +132,8 @@ place_url_list = [ x_['place_url'] for x_ in result_5['documents']] ...@@ -132,6 +132,8 @@ place_url_list = [ x_['place_url'] for x_ in result_5['documents']]
132 x_list = [ x_['x'] for x_ in result_5['documents']] 132 x_list = [ x_['x'] for x_ in result_5['documents']]
133 y_list = [ x_['y'] for x_ in result_5['documents']] 133 y_list = [ x_['y'] for x_ in result_5['documents']]
134 134
135 +
136 +
135 #print(y_list) 137 #print(y_list)
136 #print(x_list) 138 #print(x_list)
137 139
...@@ -149,6 +151,7 @@ total_count_num = str(total_count_list[0]) ...@@ -149,6 +151,7 @@ total_count_num = str(total_count_list[0])
149 total_count_num = int(total_count_num) 151 total_count_num = int(total_count_num)
150 resturant_info = "" 152 resturant_info = ""
151 resturant_string = "관련 음식점 정보: " + '\n' 153 resturant_string = "관련 음식점 정보: " + '\n'
154 +resturant_location_string = "음식점의 x y좌표" + '\n'
152 155
153 #프린트 결과를 리턴받기 위한 함수 156 #프린트 결과를 리턴받기 위한 함수
154 #from io import StringIO 157 #from io import StringIO
...@@ -161,6 +164,12 @@ for i in range(0,10): #total_count_num가 너무 크면 인덱스 범위가 벗 ...@@ -161,6 +164,12 @@ for i in range(0,10): #total_count_num가 너무 크면 인덱스 범위가 벗
161 resturant_info = [place_name_list[i] + " " +phone_list[i] + " " + road_address_name_list[i] + " " + place_url_list[i]] 164 resturant_info = [place_name_list[i] + " " +phone_list[i] + " " + road_address_name_list[i] + " " + place_url_list[i]]
162 resturant_string += str(resturant_info) + "\n" + "\n" 165 resturant_string += str(resturant_info) + "\n" + "\n"
163 166
167 +for i in range(0,10): #total_count_num가 너무 크면 인덱스 범위가 벗어나서 실행이 안됨, 임시로 10개까지만
168 + resturant_location = [x_list[i] + ", " + y_list[i]]
169 + resturant_location_string += str(resturant_location) + "\n"
170 +
171 +
172 +
164 173
165 ########################### 날씨 크롤링 기능 ######################## 174 ########################### 날씨 크롤링 기능 ########################
166 175
...@@ -216,6 +225,8 @@ def covid_news_crawling(): ...@@ -216,6 +225,8 @@ def covid_news_crawling():
216 225
217 226
218 227
228 +
229 +
219 #####텔레그램 관련 코드############################################## 230 #####텔레그램 관련 코드##############################################
220 token = "1721885449:AAHDGMbjSJfhXxML6nfSCpfiU7SghpL_vOE" 231 token = "1721885449:AAHDGMbjSJfhXxML6nfSCpfiU7SghpL_vOE"
221 id = "1657858421" 232 id = "1657858421"
...@@ -225,7 +236,7 @@ updater = Updater(token=token, use_context=True) ...@@ -225,7 +236,7 @@ updater = Updater(token=token, use_context=True)
225 dispatcher = updater.dispatcher 236 dispatcher = updater.dispatcher
226 updater.start_polling() 237 updater.start_polling()
227 238
228 - 239 +url="file:///C:/Users/user/Documents/project_opensw-chatbot/telegram_Messenger_Chatbot/index.html"
229 240
230 #가능한 응답 리스트 목록 241 #가능한 응답 리스트 목록
231 menual_message = '''사용가능한 기능 #(모해?) #(맛집) #(오늘 날씨) #(코로나 정보) #(기능) ''' 242 menual_message = '''사용가능한 기능 #(모해?) #(맛집) #(오늘 날씨) #(코로나 정보) #(기능) '''
...@@ -271,6 +282,10 @@ def handler(update, context): ...@@ -271,6 +282,10 @@ def handler(update, context):
271 # 맛집 키워드 답장 282 # 맛집 키워드 답장
272 elif ("맛집" in user_text): 283 elif ("맛집" in user_text):
273 bot.sendMessage(chat_id=id, text=resturant_string) 284 bot.sendMessage(chat_id=id, text=resturant_string)
285 + #bot.sendMessage(chat_id=id, text=resturant_location_string) 음식점 xy좌표 반환할 거임
286 + bot.sendMessage(chat_id=id, text = webbrowser.open(url)) #############################webpage 내 위치 기바ㄴ
287 +
288 +
274 elif ("고마워" in user_text): 289 elif ("고마워" in user_text):
275 bot.send_message(chat_id=id, text="웅 ㅎㅎ") 290 bot.send_message(chat_id=id, text="웅 ㅎㅎ")
276 291
...@@ -286,7 +301,7 @@ def handler(update, context): ...@@ -286,7 +301,7 @@ def handler(update, context):
286 weather_info = weather_info_crawling() 301 weather_info = weather_info_crawling()
287 bot.send_message(chat_id=id, text= weather_info) 302 bot.send_message(chat_id=id, text= weather_info)
288 bot.sendMessage(chat_id=id, text=react_weather) 303 bot.sendMessage(chat_id=id, text=react_weather)
289 - #bot.send_photo(chat_id=id, photo=open(r'C:\Users\user\Documents\project_opensw-chatbot\telegram_Messenger_Chatbot\img\weather_cloth_info.jpg', 'rb')) ###절대 경로니까 수정하세요!!!!!! 304 +
290 if (find_currenttemp_num()>=27): 305 if (find_currenttemp_num()>=27):
291 bot.send_message(chat_id=id, text="와 미친,, 27도가 넘는데? 낼 무조건 시원하게 얇고 통풍 잘 되는 거 입어, 쪄 죽겠다 ㅋㅋㅋㅋ") 306 bot.send_message(chat_id=id, text="와 미친,, 27도가 넘는데? 낼 무조건 시원하게 얇고 통풍 잘 되는 거 입어, 쪄 죽겠다 ㅋㅋㅋㅋ")
292 elif (find_currenttemp_num()>=23): 307 elif (find_currenttemp_num()>=23):
...@@ -315,6 +330,7 @@ def handler(update, context): ...@@ -315,6 +330,7 @@ def handler(update, context):
315 elif (user_text == "기능"): 330 elif (user_text == "기능"):
316 bot.sendMessage(chat_id=id, text=menual_message_info) 331 bot.sendMessage(chat_id=id, text=menual_message_info)
317 332
333 +
318 else: 334 else:
319 update.message.reply_text("ㅎㅎ") 335 update.message.reply_text("ㅎㅎ")
320 336
......