-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind.py
49 lines (42 loc) · 1.65 KB
/
find.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from telegram import Update
from telegram.ext import ContextTypes
from src.log import logger
from src import crawling
async def find(update: Update, context: ContextTypes.DEFAULT_TYPE):
chat_id = update.effective_chat.id
logger.info(f"ChatID: {chat_id} - find")
# 입력 메시지에서 '/find'를 제외한 텍스트 추출
search_value = update.message.text.replace('/find', '').replace('@black_tuesday_bot', '').strip()
if search_value == "":
await context.bot.send_message(
chat_id=chat_id,
text="Please enter your search value.\n"
"e.g.) /find Apple"
)
else:
await process_find_value(chat_id, context, search_value)
async def f(update: Update, context: ContextTypes.DEFAULT_TYPE):
chat_id = update.effective_chat.id
logger.info(f"ChatID: {chat_id} - f")
# 입력 메시지에서 '/f'를 제외한 텍스트 추출
search_value = update.message.text.replace('/f', '').replace('@black_tuesday_bot', '').strip()
if search_value == "":
await context.bot.send_message(
chat_id=chat_id,
text="Please enter your search value.\n"
"e.g.) /f Apple"
)
else:
await process_find_value(chat_id, context, search_value)
async def process_find_value(chat_id: int, context: ContextTypes.DEFAULT_TYPE, find_value: str):
result = crawling.find_crawling(find_value)
if not result:
await context.bot.send_message(
chat_id=chat_id,
text="Can't find any result."
)
else:
await context.bot.send_message(
chat_id=chat_id,
text=result
)