Newsbot - a few problems... :(

Discussion forum for MOD Writers regarding MOD Development.
Locked
Nomolas
Registered User
Posts: 20
Joined: Sat Jun 03, 2006 12:40 pm

Newsbot - a few problems... :(

Post by Nomolas » Thu Jun 21, 2007 5:42 pm

Hello,

I've a problem (hmm 3 i'm afraid :P) with a newsbot-mod. I want to post news of Tweakers.net (dutch site) in my newsforum, but i've a few problems :(
  1. BBCode UID: When I submit a post (by using submit_post) you see the uid. Example:

    Code: Select all

    [b:1234a]text[/b:1234a]
    instead of

    Code: Select all

    [b]text[/b]
    . After editing, everything's right...
  2. What's a good method to prevent that posts are posted more than 1 time? My method doesn't work...
  3. How can I convert HTML to text? (Example: ' instead of #39;)
Those are my problems... O yes my source: http://forum.probleemoppc.com/bot.php?bron

PS: What's a good method to run this bot? Include in common.php or by a crontask?
Sorry for my bad english, I am Dutch.....

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25497
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: Newsbot - a few problems... :(

Post by Paul » Thu Jun 21, 2007 9:35 pm

Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

Nomolas
Registered User
Posts: 20
Joined: Sat Jun 03, 2006 12:40 pm

Re: Newsbot - a few problems... :(

Post by Nomolas » Fri Jun 22, 2007 6:40 am

Thanks! The problems 2 & 3 are solved, but problem 1 exists....

This is the code, related to my problem (I thin):

Code: Select all

$title         = utf8_normalize_nfc($title[1][$i]);
    $bbcode_uid = $bbcode_bitfield = $flags = '';
    $message     = utf8_normalize_nfc($message); 
    generate_text_for_storage($title, $bbcode_uid, $bbcode_bitfield, $flags); 
    generate_text_for_storage($message, $bbcode_uid, $bbcode_bitfield, $flags, true, true, true);
    
    // If the news is already in our database....
    $sql = "SELECT post_subject FROM " . POSTS_TABLE . " WHERE `post_subject` = '" . $title . "'";
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);

    if ( !$result || $row !== null && in_array($title, $row) || empty($result) || empty($row) ) {
        continue; // there is no reason the continue THIS iteration.
    }
    // Prepare some data
    $this_i_post_data = array_merge($post_data, array(
        "topic_title"             => $title,
        "message_md5"            => md5($message),
        "bbcode_uid"            => '',
        'message'                => $message,
    ));
    // Submit the post
    submit_post("post", $this_i_post_data['topic_title'], $bot_data['username'], POST_NORMAL, $poll, $this_i_post_data); 
Sorry for my bad english, I am Dutch.....

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25497
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: Newsbot - a few problems... :(

Post by Paul » Fri Jun 22, 2007 7:35 am

Read the docs again, and then special the part about the bbcode uid/bitfield, and what you need to do with that.
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

Nomolas
Registered User
Posts: 20
Joined: Sat Jun 03, 2006 12:40 pm

Re: Newsbot - a few problems... :(

Post by Nomolas » Fri Jun 22, 2007 10:44 am

And what's wrong with my code, I can't find that.
Sorry for my bad english, I am Dutch.....

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25497
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: Newsbot - a few problems... :(

Post by Paul » Fri Jun 22, 2007 11:09 am

that you dont give the bbcode uid/bitfield to submit post.
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

Nomolas
Registered User
Posts: 20
Joined: Sat Jun 03, 2006 12:40 pm

Re: Newsbot - a few problems... :(

Post by Nomolas » Sun Jun 24, 2007 8:22 am

Even this dusn't work:

bot.php

(Uploaded to my own codehost; line-numbering and highlighting are included).

The problems:
  • I don't know how to convert #39; to '
  • The BBCode uid doesn't work.....
  • I don't know how to run it; cron ? Or include in common.php?
  • My check doesn't work...
If nobody can help me, I abandone this mod :(
Sorry for my bad english, I am Dutch.....

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25497
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: Newsbot - a few problems... :(

Post by Paul » Sun Jun 24, 2007 8:53 am

You still hasnt set correctly the bbcode bitfield.
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

Nomolas
Registered User
Posts: 20
Joined: Sat Jun 03, 2006 12:40 pm

Re: Newsbot - a few problems... :(

Post by Nomolas » Sun Jun 24, 2007 9:05 am

And how can I do that correctly?
Sorry for my bad english, I am Dutch.....

Nomolas
Registered User
Posts: 20
Joined: Sat Jun 03, 2006 12:40 pm

Re: Newsbot - a few problems... :(

Post by Nomolas » Sun Jun 24, 2007 2:02 pm

I've found my mistake, but those problems are still present:
  • I don't know how to convert #39; to '
  • I don't know how to run it; cron ? Or include in common.php?
Sorry for my bad english, I am Dutch.....

Nomolas
Registered User
Posts: 20
Joined: Sat Jun 03, 2006 12:40 pm

Re: Newsbot - a few problems... :(

Post by Nomolas » Tue Jun 26, 2007 10:42 am

Anybody?
Sorry for my bad english, I am Dutch.....

Locked

Return to “[3.0.x] MOD Writers Discussion”