collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Depot module  (Read 35833 times)

0 Members and 1 Guest are viewing this topic.

Offline Getrix

  • Contributor
  • *******
  • Posts: 509
  • Karma: +0/-0
Depot module
« on: December 17, 2008, 06:41:14 pm »
Did some modifying on the Depot module.
This module is primary for AoC, but it should work for AO also i think..

Its released as a Beta for now, so feedback is wanted.

http://dump.sjef.biz/aoc/bebot/Depot.phps


INFO:
Download, put in costume/modules
help should be complete, so check it out for commands info.
Biggest change is Request function. This will help ppl to get request item on the Depot list, and remind itemholder that someone wants it.

Changelog:
3.2: Removed old org security check. Using only command check.
« Last Edit: February 05, 2009, 03:05:33 pm by Getrix »
Success is not final, failure is not fatal: it is the courage to continue that counts.
- Sorry, i dont have time to reply question on PM. Make a topic.

Offline xlDanek

  • BeBot User
  • **
  • Posts: 22
  • Karma: +0/-0
Re: Depot module
« Reply #1 on: December 17, 2008, 11:39:29 pm »
Really nice one!

Unfortunately it doesn't work for me.

I can add items to the list, but if i check the list with "!depot", I only get "No items exist in the org depot.".

A look in the database shows: the new added items haven't been set to "Y" in the "itemActive" column.

I changed the SQL query as below (at row 124)

Code: [Select]
$query=("INSERT INTO #___depot (itemDatetime, itemHolder, itemName, itemLowid, itemHighid, itemQl, itemLowcrc, itemHighcrc, itemColour, itemUrl, itemActive) VALUES ('".$DatetimeNow."', '".$items[0]['holder']."', '".$items[0]['name']."', '".$items[0]['lowid']."', '".$items[0]['highid']."', '".$items[0]['ql']."', '".$items[0]['lowcrc']."', '".$items[0]['highcrc']."', '".$items[0]['colour']."', '$fitemname', 'Y')");
Now it works. Eventually the query in the "else" clause (row 128) has to be changed, too.

But i have two additional mistakes:

If I want to add an item with a german Umlaut "ä", "ü" or "ö" (untestet: "ß"), I get a positive answer, but the entry in the database isn't valid. There are some fields missing, like itemholder, itemName,... And the auto_increment function is sometimes broken after that :D Suddenly I had the ID "12259xxxx" after ID "4" :D
But it doesn't happen everytime (the ID problem, the Umlaut problem is repeatable).

The other mistake is a "permission to delete" problem. With the .php you posted above every member of my guild could delete every item in the list (I don't know why, but in my "whois" table every member has a "org_rank_id" of "0", perhaps because we have set no org). So I comment line 157 out:

Code: [Select]
//if($result1[0][0] < 2) $candel = true;
and it work's fine. Nobody could delete the items except the itemholder himself and the superadmins.

But I've got no solution for the Umlaut problem. :(

Edit:

Quote
And the auto_increment function is sometimes broken after that :D Suddenly I had the ID "12259xxxx" after ID "4" :D
But it doesn't happen everytime (the ID problem, the Umlaut problem is repeatable).

Ok, now I found th reason that is responsible for this behavior ;) If the added item is no "item link" but a normal text, the ID is set to the current time

Code: [Select]
$depotID = time();
and

Code: [Select]
$query=("INSERT INTO #___depot (id, itemName, itemURL, itemHolder) VALUES ('" . $depotID . "', '" . $fitemname . "', '', '" . $name . "')");
Afterwards, the auto_increment functions continues with this high ID.
But why is this implemented this way? I don't see why it's useful and necessary? Wouldn't it be better to disable the possibility of adding a normal text instead an item link?
« Last Edit: December 18, 2008, 12:19:11 pm by xlDanek »

Offline Getrix

  • Contributor
  • *******
  • Posts: 509
  • Karma: +0/-0
Re: Depot module
« Reply #2 on: December 18, 2008, 07:06:59 pm »
Thanks for the feedback!

Quote
$depotID = time();
This is something from the old version, and i must say i never been in the situation where it was triggered...
And yes, its abit stupid that it adds a big number and auto_inc over it.
EDIT: This is removed from Beta 3.0-b


Quote
I changed the SQL query as below (at row 124)
This is probly because default value is not set correct, but your suggestion is a nice fix to make sure its being set correct
EDIT: Added this. Thanks for the suggestion!

Code: [Select]
//if($result1[0][0] < 2) $candel = true;Will check this out.
EDIT: Removed as i cant see the point having it... Got enough security checks.


Going to test some changes out before putting a new file up
EDIT: Working version is uploaded
« Last Edit: December 18, 2008, 07:51:39 pm by gerborg »
Success is not final, failure is not fatal: it is the courage to continue that counts.
- Sorry, i dont have time to reply question on PM. Make a topic.

Offline xlDanek

  • BeBot User
  • **
  • Posts: 22
  • Karma: +0/-0
Re: Depot module
« Reply #3 on: December 18, 2008, 11:20:56 pm »
It looks really good so far.

Quote
Wouldn't it be better to disable the possibility of adding a normal text instead an item link?

I see you changed this in the code, too. You made it exact the same way I did it in my german version ;)

In the meantime I also solved my Umlaut problem. Just for the record because it's only necessary for german bebot users. I only insert some "str_replace" functions in the "depot_add" methode to change the Umlaute in "ä = ae, ö = oe, ü = ue and ß = ss". Afterwards I changed it back to the Umlaute:

Code: [Select]
function depot_add($itemname, $name)
    {
 
        $itemname = str_replace('Ä','Ae',$itemname);
        $itemname = str_replace('ä','ae',$itemname);
        $itemname = str_replace('Ö','Oe',$itemname);
        $itemname = str_replace('ö','oe',$itemname);
        $itemname = str_replace('Ü','Ue',$itemname);
        $itemname = str_replace('ü','ue',$itemname);
        $itemname = str_replace('ß','ss',$itemname);

        $sql = "SELECT org_rank_id FROM #___whois WHERE nickname = '$name'";
        $result = $this -> bot -> db -> select($sql);
        if ($this -> bot -> guildbot && $result[0][0] < 6)
        {
           
            if(is_numeric($dimension)) {
              $itemPattern = '(<a href="itemref:\/\/([0-9]*)\/([0-9]*)\/([0-9]*)\/([0-9a-f]*\:[0-9a-f]*\:[0-9a-f]*:[0-9a-f]*)\/([0-9a-f]*\:[0-9a-f]*\:[0-9a-f]*:[0-9a-f]*)"><font color=#([0-9a-f]*)>\[([\\-a-zA-Z0-9_\'&\s\-]*)\]<\/font><\/a>)';
              $posPattern = "/<a href=(.+)$/i";
            }         
            else {
              $itemPattern = '(<a style="text-decoration:none" href="itemref:\/\/([0-9]*)\/([0-9]*)\/([0-9]*)\/([0-9a-f]*\:[0-9a-f]*\:[0-9a-f]*:[0-9a-f]*)\/([0-9a-f]*\:[0-9a-f]*\:[0-9a-f]*:[0-9a-f]*)"><font color=#([0-9a-f]*)>\[([\\-a-zA-Z0-9_\'&\s\-]*)\]<\/font><\/a>)';
              $posPattern = "/<a (.+) href=(.+)$/i";
            }
           
            $fitemname = addslashes($itemname);
            $pos = preg_match($posPattern, $itemname,$info);
            $DatetimeNow = date('Y-m-d H:i:s');
            //Debug statement, uncomment to see the values are being posted by the user.
            //$this->bot->log("Depot", "Add_Item", "Item string [$itemname] Cutdown[" .str_replace('a','b',$itemname). "] Info [$info]");
            if ($pos)
            {
                $count = preg_match_all('/'.$itemPattern.'/i', $itemname, $matches, PREG_SET_ORDER);
                foreach($matches as $match)
                {
                    $item['holder']                                 = $name;
                    if (is_numeric($match[2])) { $item['lowid']     = $match[2]; }
                    if (is_numeric($match[3])) { $item['highid']    = $match[3]; }
                    if (is_numeric($match[4])) { $item['ql']        = $match[4]; }
                    $item['lowcrc']                                 = $match[5];
                    $item['highcrc']                                = $match[6];
                    $item['colour']                                 = $match[7];
                    $item['name']                                   = addslashes($match[8]);

  $item['name'] = str_replace('Ae','Ä',$item['name']);
  $item['name'] = str_replace('ae','ä',$item['name']);
  $item['name'] = str_replace('Oe','Ö',$item['name']);
  $item['name'] = str_replace('oe','ö',$item['name']);
  $item['name'] = str_replace('Ue','Ü',$item['name']);
  $item['name'] = str_replace('ue','ü',$item['name']);

                    $items[] = $item;
                }
                $query=("INSERT INTO #___depot_eng (itemDatetime, itemHolder, itemName, itemLowid, itemHighid, itemQl, itemLowcrc, itemHighcrc, itemColour, itemUrl, itemActive) VALUES ('".$DatetimeNow."', '".$items[0]['holder']."', '".$items[0]['name']."', '".$items[0]['lowid']."', '".$items[0]['highid']."', '".$items[0]['ql']."', '".$items[0]['lowcrc']."', '".$items[0]['highcrc']."', '".$items[0]['colour']."', '$fitemname', 'Y')");
               
                $this -> bot -> db -> query($query);
                $depotID = mysql_insert_id();
                $strmsg = "Thank you, your item has been added to the database as id #" . $depotID;
            }
            else
            {
                $strmsg= "The link/item you are trying to share is not in a valid format!";
            }
           
        }
        else
            $strmsg = "You must be at least a Unit Member of the org to insert items into the org depot.";

        return $strmsg;
    }
« Last Edit: December 19, 2008, 12:50:32 am by xlDanek »

Offline palm521

  • BeBot Rookie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Depot module
« Reply #4 on: February 04, 2009, 07:40:50 pm »
great. however it does not let me add items,

it says , You must be at least a Unit Member of the org to insert items into the org depot

how do you add/remove people from the org (im currently the owner of the bot)

thanks in advance.

Offline Getrix

  • Contributor
  • *******
  • Posts: 509
  • Karma: +0/-0
Re: Depot module
« Reply #5 on: February 04, 2009, 11:34:26 pm »
Have you setup the bot in a guild with members or just started using it?...

Success is not final, failure is not fatal: it is the courage to continue that counts.
- Sorry, i dont have time to reply question on PM. Make a topic.

Offline Wizhk

  • BeBot Apprentice
  • ***
  • Posts: 85
  • Karma: +0/-0
Re: Depot module
« Reply #6 on: February 04, 2009, 11:39:12 pm »
Bot is in guild with most functions working. I used to have the autogratz working but that is not the case after re-installing the bot on a new computer.

Bot recognizes guild chat and ads members, etc.

I had the old depot working fine. I just did not like looking through so many items for no reason and thought that more functionality was needed.

So, yes I believe that the bot is in proper working order.

Thanks

Offline palm521

  • BeBot Rookie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Depot module
« Reply #7 on: February 05, 2009, 07:29:55 am »
yes bot has members in it. but everytime i type !depot add silver (for example) i get the error above.

im loosing my mind.....

as owner i should have the priviledges of using this? what do you think its wrong?

thanks

Offline Getrix

  • Contributor
  • *******
  • Posts: 509
  • Karma: +0/-0
Re: Depot module
« Reply #8 on: February 05, 2009, 03:03:48 pm »
Ok, thanx for the replies.

Removed some security in the item_add function as "!depot" access is set in !command settings and its no point that i say its only orgmembers (something that also was wrong coded:P) should use it.

Default: Member can access !depot via tell and gc.
Success is not final, failure is not fatal: it is the courage to continue that counts.
- Sorry, i dont have time to reply question on PM. Make a topic.

Offline Wizhk

  • BeBot Apprentice
  • ***
  • Posts: 85
  • Karma: +0/-0
Re: Depot module
« Reply #9 on: February 05, 2009, 05:17:44 pm »
Just changed my code and closed the bot and restarted. Added a new item and checked for it. Still not working.

Code: [Select]
Dhlbot [GROUP]  [MSG]   [Last Crusade] ChuckTaylor: !depot add <a style="text-de
coration:none" href="itemref://3746106/3746106/41/689e89fa:1e5fa7f7:a56ecf10:307
d132f/689e89fa:1e5fa7f7:a56ecf10:307d132f">[Heretic's Vambraces][/link]
MySQL error (# 0) on query: INSERT INTO dhlbot_depot (itemDatetime, itemHolder,
itemName, itemLowid, itemHighid, itemQl, itemLowcrc, itemHighcrc, itemColour, it
emUrl, itemActive) VALUES ('2009-02-05 08:09:11', 'ChuckTaylor', 'Heretic\'s Vambra
ces', '3746106', '3746106', '41', '689e89fa:1e5fa7f7:a56ecf10:307d132f', '689e89
fa:1e5fa7f7:a56ecf10:307d132f', '6d8dff', '<a style=\"text-decoration:none\" hre
f=\"itemref://3746106/3746106/41/689e89fa:1e5fa7f7:a56ecf10:307d132f/689e89fa:1e
5fa7f7:a56ecf10:307d132f\"><font color=#6d8dff>[Heretic\'s Vambraces]</font></a>
', 'Y')
Unknown column 'itemDatetime' in 'field list'
Dhlbot [GROUP]  [MSG]   [Last Crusade] Dhlbot: Thank you, your item has been
added to the database as id #0
Dhlbot [GROUP]  [MSG]   [Last Crusade] ChuckTaylor: !depot
MySQL error (# 0) on query: SELECT id, itemName, itemURL, itemHolder, itemColour
, itemLowid, itemQl, itemDatetime, itemReq FROM dhlbot_depot WHERE itemActive='Y
' ORDER BY itemDatetime DESC
Unknown column 'itemDatetime' in 'field list'
Dhlbot [GROUP]  [MSG]   [Last Crusade] Dhlbot: No items exist in the org depo
t.


Offline Getrix

  • Contributor
  • *******
  • Posts: 509
  • Karma: +0/-0
Re: Depot module
« Reply #10 on: February 05, 2009, 05:33:41 pm »
You probly got the old Depot database.. This version got alot of new stuff storing in the table.

Delete dhlbot_depot, start your bot again.
Success is not final, failure is not fatal: it is the courage to continue that counts.
- Sorry, i dont have time to reply question on PM. Make a topic.

Offline Wizhk

  • BeBot Apprentice
  • ***
  • Posts: 85
  • Karma: +0/-0
Re: Depot module
« Reply #11 on: February 05, 2009, 10:37:37 pm »
Sorry.. where do I find that? I am guessing I have to access the database for that, how do I do that? ;)

I can figure it out just need to know where to look.. ;)

Wizhk

Offline Wizhk

  • BeBot Apprentice
  • ***
  • Posts: 85
  • Karma: +0/-0
Re: Depot module
« Reply #12 on: February 05, 2009, 10:46:05 pm »
Think I found it and dropped it.. Testing now.



Offline Wizhk

  • BeBot Apprentice
  • ***
  • Posts: 85
  • Karma: +0/-0
Re: Depot module
« Reply #13 on: February 05, 2009, 10:50:38 pm »
Yep it worked.. Thanks alot.

One last request. If possible can the request option be made to send a mail instead of a tell.

Thanks.


Offline Getrix

  • Contributor
  • *******
  • Posts: 509
  • Karma: +0/-0
Re: Depot module
« Reply #14 on: February 06, 2009, 07:08:04 am »
Well, that will "whats best for everyone" case.. Im happy with the solution today, and i dont know if any other modules that use Mail system.
Success is not final, failure is not fatal: it is the courage to continue that counts.
- Sorry, i dont have time to reply question on PM. Make a topic.

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 272
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal