Исходники - Агрегатор новостей Telegram V2 | End Way - форум программирования и сливов различных скриптов
  • Присоединяйтесь к нам в телеграм канал! EndWay канал | EndSoft канал | EWStudio канал
  • Хочешь поставить скрипт, но не умеешь?
    А может ты хочешь свой скрипт на основе слитого?

    Тогда добро пожаловать в нашу студию разработки!

    Телеграм бот: EWStudioBot
    Телеграм канал: EWStudio

Исходники Агрегатор новостей Telegram V2

HATNIX

Бот
Автор темы
8 Авг 2023
43
192
33
Нашел свой старый код, решил немного переделать.
Пишите что можно добавить, возможно реализую.

 
Последнее редактирование:
Like
  • 28
Реакции: 27 users

HATNIX

Бот
Автор темы
8 Авг 2023
43
192
33
nikitas244, все новости из rss канала ria новости перекидывает в тг канал добавляя гиперссылку с названием канала и также на статью.
 

CashOutGang

Сеньор
14 Июн 2023
185
97
0
timbo,
To parse news from an RSS feed from a XenForo forum, you can modify the check_and_send_news() function as follows:

Python:
def check_and_send_news():
    try:
        feed = feedparser.parse('http://example.com/external.php?type=rss2') # Replace with the URL of the XenForo RSS feed
        latest_news = feed.entries[0]
        news_title = latest_news.title
        if news_title not in sent_news:
            article_link = latest_news.link
            send_news(news_title, CLM, article_link)

    except Exception as e:
        logging.error(f"Error checking and sending news: {e}")

Here's what has changed:


  1. Replaced the feed URL with the appropriate URL of the XenForo RSS feed. It typically follows the format http://example.com/external.php?type=rss2 , but you need to replace example.com with the actual domain of your XenForo forum.

Make sure to have the feedparser library installed (pip install feedparser) to parse the RSS feed.
 

CashOutGang

Сеньор
14 Июн 2023
185
97
0
Python:
import time
import feedparser
import telebot
import logging

TOKEN = 'Tokaev'
CHANNEL_ID = '-100'
NEWS_FILE_PATH = 'news.txt'
URLC = 'https://t.me/'
CLM = "Channel Name"

bot = telebot.TeleBot(TOKEN)
sent_news = set()

def send_news(news_title, channel_name, article_link):
    try:
        caption = f"{news_title}\n\n<a href='{URLC}'>{CLM}</a> | <a href='{article_link}'>READ</a>"
        bot.send_message(CHANNEL_ID, caption, parse_mode='HTML', disable_web_page_preview=True if channel_name == URLC else False)
        logging.info(f"Sent message for news: {news_title}")

        with open(NEWS_FILE_PATH, 'a') as file:
            file.write(news_title + '\n')
        sent_news.add(news_title)

    except Exception as e:
        logging.error(f"Error sending message to channel: {e}")

def check_and_send_news():
    try:
        feed = feedparser.parse('http://example.com/external.php?type=rss2') # Replace with the URL of the XenForo RSS feed
        latest_news = feed.entries[0]
        news_title = latest_news.title
        if news_title not in sent_news:
            article_link = latest_news.link
            send_news(news_title, CLM, article_link)

    except Exception as e:
        logging.error(f"Error checking and sending news: {e}")

logging.basicConfig(level=logging.INFO, filename='bot.log', format='%(asctime)s - %(levelname)s - %(message)s')

while True:
    try:
        check_and_send_news()
        time.sleep(300)
    except KeyboardInterrupt:
        break
    except Exception as e:
        logging.error(f"Error: {e}")
 
Активность:
Пока что здесь никого нет