[ABD] lastRSS autoposting bot MOD (0.1.4)

Any abandoned MODs will be moved to this forum.

WARNING: MODs in this forum are not currently being supported or maintained by the original MOD author. Proceed at your own risk.
Forum rules
IMPORTANT: MOD Development Forum rules

WARNING: MODs in this forum are not currently being supported nor updated by the original MOD author. Proceed at your own risk.
Locked
Jemme
Registered User
Posts: 52
Joined: Mon Jul 23, 2007 5:13 pm
Location: Belgium
Contact:

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by Jemme »

Hi,

Just installed this MOD and it's working fine. I just had this error message once. I think some characters are not accepted? This is the board: http://www.roadsterclub.be

Code: Select all

General Error
SQL ERROR [ mysql4 ]

Incorrect string value: '\xA0gamme...' for column 'post_text' at row 1 [1366]

SQL

INSERT INTO phpbb_posts (forum_id, poster_id, icon_id, poster_ip, post_time, post_approved, enable_bbcode, enable_smilies, enable_magic_url, enable_sig, post_username, post_subject, post_text, post_checksum, post_attachment, bbcode_bitfield, bbcode_uid, post_postcount, post_edit_locked, topic_id) 
VALUES ('30', 256, 0, '84.197.90.127', 1232709234, 1, 1, 1, 1, 1, '', 'Mazda Belux | NOUVEAUX PRIX A PARTIR DU 1IER JANVIER 2009 ', '[b:26fb4f8n]\n \n \n \n \n \n \n Willebroek, le 29 décembre 2008. \nLes nouveaux prix de la�gamme Mazda sont connus, y compris les prix du nouveau BT-50 FL et la série spéciale Mazda6 SportBreak Thierry Boutsen Energy Racing. \nNous vous souhaitons une excellente fin d’année et�nos meilleurs voeux pour 2009!\n \n \n \n \n [/b:26fb4f8n] \n \n <!-- e --><a href=\"mailto:gemoetsp@mazdaeur.com\">gemoetsp@mazdaeur.com</a><!-- e --> (MAZDA MOTOR BELUX)\n [url:26fb4f8n]http&#58;//www&#46;mazda-press&#46;be[/url:26fb4f8n]', '0f459f7b8c3442257fd5d01c0374987d', 0, 'UA==', '26fb4f8n', 1, 1, 518)

BACKTRACE

FILE: includes/db/mysql.php
LINE: 174
CALL: dbal->sql_error()

FILE: includes/functions_posting.php
LINE: 1876
CALL: dbal_mysql->sql_query()

FILE: includes/functions_lastrss_autopost.php
LINE: 184
CALL: submit_post()

FILE: includes/functions_lastrss_autopost.php
LINE: 52
CALL: autopost()

FILE: includes/functions_lastrss_autopost.php
LINE: 228
CALL: autopost_init()

FILE: index.php
LINE: 29
CALL: include('includes/functions_lastrss_autopost.php')

Also, is there a way to remove the formatting from the posts? It adds some empty lines and the text is in bold...

Thanks.

subfighter
Registered User
Posts: 46
Joined: Wed Sep 05, 2007 9:10 pm

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by subfighter »

DiegoPino wrote:
Smix wrote:
pre-list of features for 0.2.0
  • set poster per feed
  • set feed auto-approving on/off
  • ACP
  • wrap text ( <br> | <br /> | new line )
* posting templates (via ACP)

Take you time SMIX. The mod its very cool.

[*]set feed auto-approving on/off :o :o

bye
no please.. do not take anymore time... waiting patiently! :lol:

User avatar
Smix
Registered User
Posts: 482
Joined: Mon Sep 11, 2006 1:07 am

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by Smix »

Hello,

@blitztrading
Hello,
as I checked your feed ( http://actufinance.typepad.com/weblog/rss.xml ), it contains only the first 200 (or similar number) characters, so it´s gathered completely ...
Picture parsing is not the first thing which I´ll want to implement, but I´ll try to do what I´ll do ...
Atom is not parsed ...

@djdurant
Hello,
I´m sorry, I´ve missed to reply to your post :oops: I think I was already checking that problem. If you´ll go to the forum, you´ll see the topics posted, but they should not be approved (yes, in some cases, there is a bug in autoapproving ... ) ... Or the ID of the forum is badly set and it´s posted into category - not forum and they are "not visible" and not counted ...

@deanandeva
Hello,
which version of APB are you using ? ... What´s on the row 89 (and around) ? ... Please send me the file to phpbb3 (at) smika.net ... Thank you ...

@Jemme
Hello,
I´m still fighting with this type of bug and I still haven´t a clue how to fix this ... I´m actually focusing on the server configuration - please check your phpinfo() and report if you have 'glibc' or/and 'libiconv' libraries on your server available, thanks ...

subfighter
Registered User
Posts: 46
Joined: Wed Sep 05, 2007 9:10 pm

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by subfighter »

how is the CRON JOB coming along??? as i a looking for performance.

is there a performance benefit if you have the RSS FEED POSTS going to a forum with less posts??? say if the forum already has a 100,000 posts and want to have your MOD add the RSS FEED Posts there will it hurt perfomance searching through the DB or better to create a new FORUM would i get better performance??

TiTex
Registered User
Posts: 79
Joined: Sun Jul 06, 2008 1:27 pm

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by TiTex »

Smix wrote: @Jemme
Hello,
I´m still fighting with this type of bug and I still haven´t a clue how to fix this ... I´m actually focusing on the server configuration - please check your phpinfo() and report if you have 'glibc' or/and 'libiconv' libraries on your server available, thanks ...
I have the same problem as Jemme do ... and here is my phpinfo
iconv
iconv support enabled
iconv implementation glibc
iconv library version 2.7

Directive Local Value Master Value
iconv.input_encoding ISO-8859-1 ISO-8859-1
iconv.internal_encoding ISO-8859-1 ISO-8859-1
iconv.output_encoding ISO-8859-1 ISO-8859-1

User avatar
Smix
Registered User
Posts: 482
Joined: Mon Sep 11, 2006 1:07 am

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by Smix »

@TiTex
Thanks for info ;)

@Subfighter
I didn´t tested cron run ... (but I´ll do it soon ;) ) ... I think you´ve got good ideas :) ... I can change the part which is looking for topic duplicity and limit it to search only in actual forum ... yeah ;) ... It´s checking all topics actually ... Good idea! Good idea! ... Thanks ... :)

subfighter
Registered User
Posts: 46
Joined: Wed Sep 05, 2007 9:10 pm

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by subfighter »

be waiting for the update..

also anyone using phpbb 3.0.4 when installing needs the directions updated for this last part.. as the code to search for is a bit different..

Open: language/en/acp/common.php


Find
Tip: This may be a partial find and not the whole line.

Code: Select all

	'LOG_ERROR_EMAIL'		=> '<strong>E-mail error</strong><br />» %s',
Add after
Tip: Add these lines on a new blank line after the preceding line(s) to find.

Code: Select all

	'LOG_ERROR_LASTRSS' 	=> '<strong>lastRSS error</strong><br />» %s',

subfighter
Registered User
Posts: 46
Joined: Wed Sep 05, 2007 9:10 pm

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by subfighter »

Smix wrote:
@Subfighter
I didn´t tested cron run ... (but I´ll do it soon ;) ) ... I think you´ve got good ideas :) ... I can change the part which is looking for topic duplicity and limit it to search only in actual forum ... yeah ;) ... It´s checking all topics actually ... Good idea! Good idea! ... Thanks ... :)
yeah if you can post the code here for the TOPICS would be great because there is a lag when it load a FEED..

Basically i am testing this out on my demo site.. but would a single person viewing the FORUM trigger the MOD to get the FEED??? Becuase it takes about 35 seconds for it to process the 5 feeds!!!! :o

thats why I say if a CRON JOB to run in the background would be great..

but for now even to just check the FORUM ID would help out...

Ikhsan4488
Registered User
Posts: 63
Joined: Sun Nov 25, 2007 12:46 pm
Location: <REtN>
Contact:

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by Ikhsan4488 »

uppss.. sory.. :D working great. :)

spartanic
Registered User
Posts: 14
Joined: Thu Oct 21, 2004 12:38 am

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by spartanic »

I'm a little confused here. Whats the difference between this mod and the aggregator mod? They both seem to do the same thing.

User avatar
Tripp
Former Team Member
Posts: 1358
Joined: Sun May 20, 2007 5:14 am
Location: G'boro, North Carolina
Name: Tripp
Contact:

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by Tripp »

spartanic wrote:I'm a little confused here. Whats the difference between this mod and the aggregator mod? They both seem to do the same thing.
This takes a user's ID, and POST feeds from other sites as topics. The other gives your site RSS support for your site.
The box said 'You need Windows XP or better' .... so I installed linux.

Formerly Drugs

spartanic
Registered User
Posts: 14
Joined: Thu Oct 21, 2004 12:38 am

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by spartanic »

Just got done installing this mod. So far so good. However I'm a little confused as to editing the tables in phpmyadmin to get the right feed to display.

`name` - name of the feed - is also used in posting
`url` - URL of the feed ...
`next_check` - next check time (from PHP function time())
`next_check_after` - number of hours between checks
`destination_id` - forum_id where BOT will try to post
`enabled` INT( 1 ) - boolean - if true, this feed will be checked

Is there a tutorial on this? Where can I find the areas to edit it without messing it up?

subfighter
Registered User
Posts: 46
Joined: Wed Sep 05, 2007 9:10 pm

Correct Edits assigning a NEW MEMBER to EAch FEED

Post by subfighter »

somewhere around page 36 some posted on how to make some edits so that you can assign a certain member to each feed...

anyways you can compare there edits they posted as there was like 3 problems with errors in the syntax.. you can compare with my file and see what was messed up.. as i wasted some time figuring it out so trying to save anyone else the headache.

you can see here in action as i made a couple of other tweaks.. as i am using ABBC3 mod and have it Embed the PAGE and Link in the POST..

http://www.subfighter.tv/phpBB3/viewfor ... ef8d9dd405

actually even did some tweaking and got it to SEARCH on YOUTUBE for certain VIDEOS and Return the results in the API FEED and and had it embed them.. would be cool to have some option like this integration if we ever get an ACP. so i was dumping like 50 videos at time from the YOUTUBE feed into forum.

http://www.subfighter.tv/phpBB3/viewforum.php?f=32

Code: Select all

<?php
/**
*
* @package includes
* @version $Id: $
* @copyright (c) 2007-2008 Jiri Smika (Smix) http://phpbb3.smika.net
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/ 
 
/**
 *  Autopost functions
 *  Get the next feed to check
 *  return array $next_feed       
 */        
function get_next_feed_to_post()
{
  global $db;
  $sql = 'SELECT name, url, next_check, next_check_after, lastrss_ap_bot_id, destination_id, enabled
		      FROM ' . LASTRSS_AP_TABLE . '
		      WHERE next_check < "' . time() . '" AND enabled = "1"
		      ORDER BY next_check DESC 
          LIMIT 0,1';
  $result	= $db->sql_query($sql);
	$next_feed = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);

  // feed was checked - do not check it again until ...
	$sql = 'UPDATE ' . LASTRSS_AP_TABLE . '
          SET next_check = "' . ( time() + $next_feed['next_check_after'] * 3600 ) . '"
          WHERE name = "' . $next_feed['name'] . '"';
  // for development reasons - do not update -> force to always load fresh data
  $db->sql_query($sql);
  return $next_feed;
} 

/**
 *  Autopost functions
 *  init lastRSS to get feed data and post the feed items! 
 *  @param mixed $feed - including url for downloading and other data 
 */   
function autopost_init($feed)
{
  global $rss;
  // get the feed data
  $result = $rss->parse($feed);
  // return full data collection
  if($result['items_count'] > 0)
  {
    $result = array_merge($feed, $result);
    // ... and try to post them  
    autopost($result);
  }
}

/**
 *  Autopost functions
 *  approve topic/post tables after posting 
 *  @param string $subject - subject which we want to approve 
 */
function autopost_approve($subject)
{				
  global $db;								
  $sql = 'UPDATE ' . POSTS_TABLE . '
  	      SET post_approved = 1
  	      WHERE post_subject = "' . $db->sql_escape($subject) . '"';
  $db->sql_query($sql);
  $sql = 'UPDATE ' . TOPICS_TABLE . '
  	      SET topic_approved = 1
  	      WHERE topic_title = "' . $db->sql_escape($subject) . '"';
  $db->sql_query($sql);
}  

/**
 *  Autopost functions
 *  posts new topic in forum 
 *  @param mixed $post_data - includes all data of feed  
 */  
function autopost($post_data)
{
	global $config, $user, $db, $phpbb_root_path, $phpEx;
  // require necessary functions for posting
	require($phpbb_root_path . 'includes/functions_posting.' . $phpEx);

	// prepare user data for lastRSS autopost bot
	$user_backup = $user->data;
	$sql = 'SELECT username, user_colour
		      FROM ' . USERS_TABLE . '
		      WHERE user_id = "' . $post_data['lastrss_ap_bot_id'] . '"';
	$result	= $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);
	
	// change poster ...
	$user->data = array_merge($user->data, array(
		'user_id'		=> $post_data['lastrss_ap_bot_id'],
		'username'		=> $row['username'],
		'user_colour'	=> $row['user_colour'],
	));

  // do this only once ...
  // prepare post_data
  $post_data['copyright'] = (isset($post_data['copyright']) && ($post_data['copyright'] != '')) ? '&copy; ' . $post_data['copyright'] : '';

  // get image data if possible
	if( isset($post_data['image_link']) && isset($post_data['image_url']) ) 
	{
    $image = '[url='.$post_data['image_link'].'][img]'.$post_data['image_url'].'[/img][/url]';
  }
  elseif( isset($post_data['image_url']))
  {
  	$image = '[img]'.$post_data['image_url'].'[/img]';
  }
  else
  {
    $image = '';
  }

  // do the rest for every item in feed
  $count = (isset($post_data['items'])) ? count($post_data['items']) : 0;
  $i = $count-1;
  // backward posting (from the oldest to the newest)
  while($i >= 0)
  {
    // necessary vars 
    $uid = $bitfield = $options = $poll = ''; 
    
  	// prepare data for posting
		$subject = truncate_string($post_data['items'][$i]['title']);
		$subject = htmlspecialchars_decode($subject);

    generate_text_for_storage($subject, $uid, $bitfield, $options, false, false, false);
    
    // check if this topic is not already posted
  	$sql = 'SELECT topic_title
  		      FROM ' . TOPICS_TABLE . '
  		      WHERE topic_title = "' . $db->sql_escape($subject) . '"';
  	$result	= $db->sql_query($sql);
  	$row = $db->sql_fetchrow($result);
  	$db->sql_freeresult($result);	 	

  	// Do we have a new item to post ?
  	// TODO review later the comparing function
  	if (strnatcasecmp($row['topic_title'], $subject))
  	{ 
  	  // necessary recoding/styling of message
  	  
    	// do we have pubDate ? ... post will be posted with this time!
      $post_time = (sizeof($post_data['items'][$i]['pubDate']) > 0) ? strtotime($post_data['items'][$i]['pubDate']) : 0;
      
      $author = ( isset($post_data['items'][$i]['author']) && ($post_data['items'][$i]['author'] != '')) ? $post_data['items'][$i]['author'] : '';

      // this defines how the final post looks     
      // edit the $message if you wan´t to change it there
      $message = $image.'
                   [quote]' . $post_data['items'][$i]['description'] . ' [/quote]     	
                   ' . $post_data['copyright'] . ' ' . $author . '
                   [url]' . $post_data['items'][$i]['link'] . '[/url]
			       [web 100%,600]' . $post_data['items'][$i]['link'] . '[/web]';
//                 [BBvideo 720,480]' . $post_data['items'][$i]['link'] . '[/BBvideo]';    
                 

      // prepare post data
    	generate_text_for_storage($message, $uid, $bitfield, $options, true, true, true);
    	$data = array( 
      	'forum_id'			=> $post_data['destination_id'],
      	'icon_id'			=> false,
      	'enable_bbcode'		=> true,
      	'enable_smilies'	=> true,
      	'enable_urls'		=> true,
      	'enable_sig'		=> true,
      	'message'			=> $message,
      	'message_md5'		=> md5($message),
      	'bbcode_bitfield'	=> $bitfield,
      	'bbcode_uid'		=> $uid,
      	'post_edit_locked'	=> false,
      	'topic_title'		=> $subject,
      	'notify_set'		=> false,
      	'notify'			=> false,
      	// make a post in original time ;)
      	'post_time' 		=> $post_time,
      	'forum_name'		=> '',
      	'enable_indexing'	=> true,
      	// this is not working, but let´s try it
      	'post_approved' => true,
    	);
    	// submit and approve the post!
    	submit_post('post', $subject, '', POST_NORMAL, $poll, $data);
    	autopost_approve($subject);
    }
    // change $i to the next (ehm previous :D ) item
    $i--;
	}
	// reset user´s data after posting
	$user->data = array_merge($user->data, $user_backup);
}

// if lastrss autopost bot is enabled 
if($config['lastrss_ap_enabled'])
{
  // init & setup lastrss
  // $rss can be already initiated by lastRSS agregator mod by SmiX
  if(!isset($rss))
  {
    require $phpbb_root_path . 'includes/class_lastrss.' . $phpEx; 
    $rss = new lastrss;	
  }
  // init/change settings for lastrss autopost bot
  $rss->cache_time = 0;                                         // not used in this mod
  $rss->items_limit = $config['lastrss_ap_items_limit'];        // default limit of items to post
  $rss->type = $config['lastrss_type'];                         // connection type (fopen / curl)

  // init lastRSS autopost MOD !
  // check if we have some feeds in database to check
  $sql = 'SELECT *
		      FROM ' . LASTRSS_AP_TABLE . '
		      WHERE next_check < "' . time() . '" AND enabled = "1"';
  $result	= $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);
  // so do we have some feeds to post ?
  if(sizeof($row) > 0)
  {
    // we are already sure, that at least one feed exists!
    $feed = get_next_feed_to_post(); 
  }

  // do we have some feed data ?
  if (isset($feed) && (sizeof($feed) > 0))
  {  
    // we are sure, we have feed info for checking the feed!
    autopost_init($feed);
  }
}
?>

spartanic
Registered User
Posts: 14
Joined: Thu Oct 21, 2004 12:38 am

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by spartanic »

OK well it looks like I figured out how to make it work. Took some experimenting but it works. Someone needs to make a "user pdf manual" on this mod. It kind of sucks to have to go through a ton of pages to find answers.

User avatar
Tripp
Former Team Member
Posts: 1358
Joined: Sun May 20, 2007 5:14 am
Location: G'boro, North Carolina
Name: Tripp
Contact:

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by Tripp »

spartanic wrote:OK well it looks like I figured out how to make it work. Took some experimenting but it works. Someone needs to make a "user pdf manual" on this mod. It kind of sucks to have to go through a ton of pages to find answers.
I'm sorry but I have to disagree. Dev/Beta MODS are not meant to used in live environments or to be used to someone who is not well experienced in using phpBB/mods or making database changes.
The box said 'You need Windows XP or better' .... so I installed linux.

Formerly Drugs

Locked

Return to “[3.0.x] Abandoned MODs”