<commit_before><?php
class TelegramBridge extends BridgeAbstract {
	const NAME = 'Telegram Bridge';
	const URI = 'https://t.me';
	const DESCRIPTION = 'Returns newest posts from a public Telegram channel';
	const MAINTAINER = 'VerifiedJoseph';
	const PARAMETERS = array(array(
			'username' => array(
				'name' => 'Username',
				'type' => 'text',
				'required' => true,
				'exampleValue' => '@telegram',
			)
		)
	);

	const CACHE_TIMEOUT = 900; // 15 mins

	private $feedName = '';
	private $enclosures = array();
	private $itemTitle = '';

	private $backgroundImageRegex = "/background-image:url\('(.*)'\)/";

	public function collectData() {

		$html = getSimpleHTMLDOM($this->getURI())
			or returnServerError('Could not request: ' . $this->getURI());

		$channelTitle = htmlspecialchars_decode(
			$html->find('div.tgme_channel_info_header_title span', 0)->plaintext,
			ENT_QUOTES
		);
		$this->feedName = $channelTitle . ' (@' . $this->processUsername() . ')';

		foreach($html->find('div.tgme_widget_message_wrap.js-widget_message_wrap') as $index => $messageDiv) {
			$this->itemTitle = '';
			$this->enclosures = array();
			$item = array();

			$item['uri'] = $this->processUri($messageDiv);
			$item['content'] = html_entity_decode($this->processContent($messageDiv), ENT_QUOTES);
			$item['title'] = html_entity_decode($this->itemTitle, ENT_QUOTES);
			$item['timestamp'] = $this->processDate($messageDiv);
			$item['enclosures'] = $this->enclosures;
			$author = trim($messageDiv->find('a.tgme_widget_message_owner_name', 0)->plaintext);
			$item['author'] = html_entity_decode($author, ENT_QUOTES);

			$this->items[] = $item;
		}
		$this->items = array_reverse($this->items);
	}

	public function getURI() {

		if (!is_null($this->getInput('username'))) {
			return self::URI . '/s/' . $this->processUsername();
		}

		return parent::getURI();
	}

	public function getName() {

		if (!empty($this->feedName)) {<commit_msg>Revert "[TelegramBridge] Prevent double encoding entities (#1182)"<commit_after><?php
class TelegramBridge extends BridgeAbstract {
	const NAME = 'Telegram Bridge';
	const URI = 'https://t.me';
	const DESCRIPTION = 'Returns newest posts from a public Telegram channel';
	const MAINTAINER = 'VerifiedJoseph';
	const PARAMETERS = array(array(
			'username' => array(
				'name' => 'Username',
				'type' => 'text',
				'required' => true,
				'exampleValue' => '@telegram',
			)
		)
	);

	const CACHE_TIMEOUT = 900; // 15 mins

	private $feedName = '';
	private $enclosures = array();
	private $itemTitle = '';

	private $backgroundImageRegex = "/background-image:url\('(.*)'\)/";

	public function collectData() {

		$html = getSimpleHTMLDOM($this->getURI())
			or returnServerError('Could not request: ' . $this->getURI());

		$channelTitle = htmlspecialchars_decode(
			$html->find('div.tgme_channel_info_header_title span', 0)->plaintext,
			ENT_QUOTES
		);
		$this->feedName = $channelTitle . ' (@' . $this->processUsername() . ')';

		foreach($html->find('div.tgme_widget_message_wrap.js-widget_message_wrap') as $index => $messageDiv) {
			$this->itemTitle = '';
			$this->enclosures = array();
			$item = array();

			$item['uri'] = $this->processUri($messageDiv);
			$item['content'] = $this->processContent($messageDiv);
			$item['title'] = $this->itemTitle;
			$item['timestamp'] = $this->processDate($messageDiv);
			$item['enclosures'] = $this->enclosures;
			$author = trim($messageDiv->find('a.tgme_widget_message_owner_name', 0)->plaintext);
			$item['author'] = html_entity_decode($author, ENT_QUOTES);

			$this->items[] = $item;
		}
		$this->items = array_reverse($this->items);
	}

	public function getURI() {

		if (!is_null($this->getInput('username'))) {
			return self::URI . '/s/' . $this->processUsername();
		}

		return parent::getURI();
	}

	public function getName() {

		if (!empty($this->feedName)) {
{'fraction_non_alphanumeric': 0.18729010591578404, 'fraction_numerical': 0.004649961250322914, 'mean_word_length': 4.571223021582734, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 59, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5687638', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1277, 'n_words': 242}