microsoft / microsoft/OmniParser
avitopars
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 25.4k
- Forks
- 2.2k
- PR merge metrics
- No merged PRs in 30d
Description
import telebot
import sqlite3
from parser import AvitoParser
import time
from threading import Thread
class NotificationBot:
def init(self, token):
self.bot = telebot.TeleBot(token)
self.parser = AvitoParser()
self.setup_handlers()
def setup_handlers(self):
@self.bot.message_handler(commands=['start'])
def start(message):
self.bot.reply_to(message,
"🔍 Бот для отслеживания объявлений на Avito\n\n"
"Команды:\n"
"/add_filter - Добавить фильтр\n"
"/my_filters - Мои фильтры\n"
"/stats - Статистика\n"
"/help - Помощь"
)
@self.bot.message_handler(commands=['add_filter'])
def add_filter(message):
msg = self.bot.reply_to(message, "Введите запрос для поиска:")
self.bot.register_next_step_handler(msg, self.process_query)
def send_notification(self, chat_id, ad):
"""Отправляет уведомление о новом объявлении"""
message = f"""
🔥 НОВОЕ ОБЪЯВЛЕНИЕ
{ad['title']}
💰 Цена: {ad['price']:,} руб.
📍 {ad['location']}
📅 {ad['date']}
{ad['description'][:200]}...
# Отправляем текст
self.bot.send_message(chat_id, message, parse_mode='Markdown')
# Отправляем первое изображение если есть
images = ad.get('images', [])
if images:
try:
self.bot.send_photo(chat_id, images[0])
except:
pass
# Отмечаем как отправленное
conn = sqlite3.connect('avito_ads.db')
cursor = conn.cursor()
cursor.execute(
'INSERT INTO sent_notifications (ad_id, chat_id) VALUES (?, ?)',
(ad['id'], chat_id)
)
conn.commit()
conn.close()
def monitoring_loop(self):
"""Основной цикл мониторинга"""
while True:
try:
# Получаем все активные подписки
conn = sqlite3.connect('avito_ads.db')
cursor = conn.cursor()
cursor.execute('SELECT chat_id, filters FROM users WHERE active = 1')
users = cursor.fetchall()
conn.close()
for chat_id, filters_json in users:
filters = json.loads(filters_json)
new_ads = self.parser.get_new_ads(filters)
for ad in new_ads:
# Проверяем, не отправляли ли уже
conn = sqlite3.connect('avito_ads.db')
cursor = conn.cursor()
cursor.execute(
'SELECT * FROM sent_notifications WHERE ad_id = ? AND chat_id = ?',
(ad['id'], chat_id)
)
if not cursor.fetchone():
self.send_notification(chat_id, ad)
conn.close()
time.sleep(300) # Проверка каждые 5 минут
except Exception as e:
print(f"Ошибка в мониторинге: {e}")
time.sleep(60)
if name == 'main':
bot = NotificationBot('ВАШ_ТОКЕН')
# Запускаем мониторинг в отдельном потоке
monitor_thread = Thread(target=bot.monitoring_loop)
monitor_thread.daemon = True
monitor_thread.start()
# Запускаем бота
bot.bot.polling(none_stop=True)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue contains standalone Python code for an Avito notification bot using SQLite, but it names no OmniParser file, test, entry point, or requested change. There is no repository-specific completion criterion, so a contributor cannot identify what to inspect or what would constitute done.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlite
- Domain
- backend, database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 1/100