Pages:
Author

Topic: [BRAINSTORM] Any requests for custom extensions/user scripts for BitcoinTalk? - page 2. (Read 1323 times)

copper member
Activity: 2996
Merit: 2374
Would also be nice to have a script that automatically bumps a thread every 24 hours, ideally deleting the previous bump so as not to spam up the thread.

If this could be combined with custom texts that are randomly cycled that would be even better.

If something like this already exists, please do let me know as I play to launch a service thread soon and this would be very useful (+5 merits for the link!)
https://github.com/buxlover/autobump

I didn't create this personally, nor have I inspected it.

People have sold similar bots in the past, and even tried to use this as a service.
hero member
Activity: 1582
Merit: 759
Would also be nice to have a script that automatically bumps a thread every 24 hours, ideally deleting the previous bump so as not to spam up the thread.

If this could be combined with custom texts that are randomly cycled that would be even better.

If something like this already exists, please do let me know as I play to launch a service thread soon and this would be very useful (+5 merits for the link!)

At the very least this would have to be an extension, and not sure how easy this would be, or if it's even possible within the scopes of a browser extension.

Would probably have to be something server side.
legendary
Activity: 2030
Merit: 1189
Would also be nice to have a script that automatically bumps a thread every 24 hours, ideally deleting the previous bump so as not to spam up the thread.

If this could be combined with custom texts that are randomly cycled that would be even better.

If something like this already exists, please do let me know as I play to launch a service thread soon and this would be very useful (+5 merits for the link!)
hero member
Activity: 1582
Merit: 759
No worries man. Yea, I think there's a difference of interpretation between Windows versions of PHP & Linux, which may be why. I'm running on Mac right now.

I'll make a combined version tonight/tomorrow, and switch it to a regex just in case.

Thx, please share afterwards. Smiley
I gonna run the old code on my Mac later/tomorrow. I'm curious. Grin

Could just be my machine lol. I'll let you know Smiley
full member
Activity: 504
Merit: 137
Nope.
No worries man. Yea, I think there's a difference of interpretation between Windows versions of PHP & Linux, which may be why. I'm running on Mac right now.

I'll make a combined version tonight/tomorrow, and switch it to a regex just in case.

Thx, please share afterwards. Smiley
I gonna run the old code on my Mac later/tomorrow. I'm curious. Grin
hero member
Activity: 1582
Merit: 759
~snip

Good job man! You're fast.

What system/PHP version are you running?

I tried running on my local system. When you pull merit.all.txt, is it showing spaces for you, or tabs? For me, locally, it's showing tabs, so the top had to be changed to the following.

Code:
$url = "http://loyce.club/Merit/merit.all.txt"; 
$file = file($url);
$file = str_replace("\t", ",", $file);
$file = str_replace("\r\n", "",$file);

I'm not sure why there's a difference, perhaps it's environmental. But, I'd maybe switch to a regex to permit both spaces/tabs just in case.

Also, the return null; within the functions aren't allowing the table to be finished semantically (no ), so I'd drop those, or move the echo up.

Code:
echo "";
return null;

For todos, it's probably a good idea to accept no parameters as well, combining the script to allow the user to specify a output method (JSON, or table format)

I can help out providing modifications to your code, but I wanna grab your permission first. Your code after all.

Good job though, and thanks!

Hi, thanks for you inputs.
As I said: It's been a while since I actively coded a lot. Grin
Of course you can use and modify this code. Feel free.

For me it is tabs aswell, but it works like a charme (win xamp v3.2.2. w/ std ini's).
regex are far better! I am just suffering from forgotten knowledge and lazyness. (see above: it has been a while Grin)

Return and Echo is obv incorrect and has to be changed.
Parameters: I was not sure what was exactly needed. So I made just two versions. But afterall a good idea to just add another bool for JSON output or not, or something like this. Also I initially wanted to work with switch() and parse the whole array as a default.

Holy grail would be a read-only database access to the effected tables. Would be much faster and easier.

Cheers!

No worries man. Yea, I think there's a difference of interpretation between Windows versions of PHP & Linux, which may be why. I'm running on Mac right now.

I'll make a combined version tonight/tomorrow, and switch it to a regex just in case.
full member
Activity: 504
Merit: 137
Nope.
~snip

Good job man! You're fast.

What system/PHP version are you running?

I tried running on my local system. When you pull merit.all.txt, is it showing spaces for you, or tabs? For me, locally, it's showing tabs, so the top had to be changed to the following.

Code:
$url = "http://loyce.club/Merit/merit.all.txt"; 
$file = file($url);
$file = str_replace("\t", ",", $file);
$file = str_replace("\r\n", "",$file);

I'm not sure why there's a difference, perhaps it's environmental. But, I'd maybe switch to a regex to permit both spaces/tabs just in case.

Also, the return null; within the functions aren't allowing the table to be finished semantically (no ), so I'd drop those, or move the echo up.

Code:
echo "";
return null;

For todos, it's probably a good idea to accept no parameters as well, combining the script to allow the user to specify a output method (JSON, or table format)

I can help out providing modifications to your code, but I wanna grab your permission first. Your code after all.

Good job though, and thanks!

Hi, thanks for you inputs.
As I said: It's been a while since I actively coded a lot. Grin
Of course you can use and modify this code. Feel free.

For me it is tabs aswell, but it works like a charme (win xamp v3.2.2. w/ std ini's).
regex are far better! I am just suffering from forgotten knowledge and lazyness. (see above: it has been a while Grin)

Return and Echo is obv incorrect and has to be changed.
Parameters: I was not sure what was exactly needed. So I made just two versions. But afterall a good idea to just add another bool for JSON output or not, or something like this. Also I initially wanted to work with switch() and parse the whole array as a default.

Holy grail would be a read-only database access to the effected tables. Would be much faster and easier.

Cheers!
hero member
Activity: 1582
Merit: 759
~snip

Good job man! You're fast.

What system/PHP version are you running?

I tried running on my local system. When you pull merit.all.txt, is it showing spaces for you, or tabs? For me, locally, it's showing tabs, so the top had to be changed to the following.

Code:
$url = "http://loyce.club/Merit/merit.all.txt"; 
$file = file($url);
$file = str_replace("\t", ",", $file);
$file = str_replace("\r\n", "",$file);

I'm not sure why there's a difference, perhaps it's environmental. But, I'd maybe switch to a regex to permit both spaces/tabs just in case.

Also, the return null; within the functions aren't allowing the table to be finished semantically (no ), so I'd drop those, or move the echo up.

Code:
echo "";
return null;

For todos, it's probably a good idea to accept no parameters as well, combining the script to allow the user to specify a output method (JSON, or table format)

I can help out providing modifications to your code, but I wanna grab your permission first. Your code after all.

Good job though, and thanks!
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
@CryptoNeed: I haven't had the time to thoroughly look at it, but thanks for the code!

Call this file anything-you-want.php and just upload it in the same folder as the merit.all.txt file.

But if you don’t want, I could try making my own as well. I thought I had to scrape each user merit page or similar.

Edit:@Loyce how do you get the name of the users and posts?
I'll have time for it tomorrow. I'll also make a new topic tomorrow (something like: "loyce.club crowdsourced user scripts"), because (although very interesting) I think we're a bit off-topic here.

All my public Merit data is summarized in this post, including usernames. Post titles are published in a 98 MB large file, I can make a less bloated version if needed.
full member
Activity: 504
Merit: 137
Nope.
Hope it fits the needs.  Smiley
Is this something I run on the server?
(complete n00b here)
Call this file anything-you-want.php and just upload it in the same folder there is the merit.all.txt file.

But if you don’t want, I could try making my own as well. I thought I had to scrape each user merit page or similar.

Exactly. Sorry, I forgot to mention it. I made two files.
The HTML-Output file will generate clickable links for everyone and the other file will provide other users with a "light API" for your file.
If you safe these files in the same directory on your server where the merit.all.txt is located, you can set $url to "merit.all.txt". If not, you may need to adjust the variable.
legendary
Activity: 2758
Merit: 6830
Hope it fits the needs.  Smiley
Is this something I run on the server?
(complete n00b here)
Call this file anything-you-want.php and just upload it in the same folder as the merit.all.txt file.

But if you don’t want, I could try making my own as well. I thought I had to scrape each user merit page or similar.

Edit:@Loyce how do you get the name of the users and posts?
full member
Activity: 504
Merit: 137
Nope.
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
Hope it fits the needs.  Smiley
Is this something I run on the server?
(complete n00b here)
full member
Activity: 504
Merit: 137
Nope.
Seems to work, could be improved for sure.
I think you're overestimating my php-knowledge: I have no idea what to do with this Tongue

Quote
it would be much faster to send individual request to the database (e.g. by GET).
If you tell us the structure of the database, it is actually super easy to implement.
I don't have a database, just static HTML. That makes it very fast to browse as the server just has to read the file from disk, but I'm also at the point that adding more functionality becomes exceedingly difficult. I know nothing about databases and php Sad

Np, I will write an example script based on your .txt.
Database details for such functionalities would have to be provided by btct admin anyways.

Will adjust the script now ...

Output in HTML:

Quote

//GET Request by: merithtml.php?donor=USERID

$url = "http://loyce.club/Merit/merit.all.txt";
$file = file($url);
$file = str_replace("   ", ",",$file);
$file = str_replace("\r\n", "",$file);
// put the array together
foreach ($file as $line => $value) {
   $value = explode(",", $value);
    $bigArray[] = array("Donor" => $value[3], "Recipient" => $value[4], "Merits" => $value[1], "Msg" => $value[2], "DTG" => $value[0]);
}

function searchForDonor($uid, $array) {
   echo "";
   foreach ($array as $key => $val) {
      if($val["Donor"] === $uid) {
         //print_r($array[$key]);
         echo "
               
               
               
               
               
            ";
      }
   }
   return null;
   echo "
".date("d.m.Y H:i:s", $val["DTG"])."".$val["Msg"]."".$val["Donor"]."-(".$val["Merits"].")->".$val["Recipient"]."
";
}

function searchForRecipient($uid, $array) {
   echo "";
   foreach ($array as $key => $val) {
      if($val["Recipient"] === $uid) {
         //print_r($array[$key]);
         echo "
               
               
               
               
               
            ";
      }
   }
   return null;
   echo "
".date("d.m.Y H:i:s", $val["DTG"])."".$val["Msg"]."".$val["Recipient"]."<-(".$val["Merits"].")-".$val["Donor"]."
";
}

if(isset($_GET["donor"])) {
   searchForDonor($_GET["donor"], $bigArray);
}

if(isset($_GET["recipient"])) {
   searchForRecipient($_GET["recipient"], $bigArray);
}

?>


Output as JSON array:

Quote

//GET Request by: meritjson.php?donor=USERID
header('Content-Type: application/json');
$url = "http://loyce.club/Merit/merit.all.txt";
$file = file($url);
$file = str_replace("   ", ",",$file);
$file = str_replace("\r\n", "",$file);
// put the array together
foreach ($file as $line => $value) {
   $value = explode(",", $value);
    $bigArray[] = array("Donor" => $value[3], "Recipient" => $value[4], "Merits" => $value[1], "Msg" => $value[2], "DTG" => $value[0]);
}

function searchForDonor($uid, $array) {
   foreach ($array as $key => $val) {
      if($val["Donor"] === $uid) {
         echo json_encode($array[$key], JSON_PRETTY_PRINT);
      }
   }
   return null;
}

function searchForRecipient($uid, $array) {
   foreach ($array as $key => $val) {
      if($val["Recipient"] === $uid) {
         echo json_encode($array[$key], JSON_PRETTY_PRINT);
      }
   }
   return null;
}

if(isset($_GET["donor"])) {
   searchForDonor($_GET["donor"], $bigArray);
}

if(isset($_GET["recipient"])) {
   searchForRecipient($_GET["recipient"], $bigArray);
}


?>


Once uploaded, you can search your .txt for merits given and received by users through file.php?donor=USERID and ?recipient=USERID
Hope it fits the needs.  Smiley
full member
Activity: 504
Merit: 137
Nope.
Seems to work, could be improved for sure.
I think you're overestimating my php-knowledge: I have no idea what to do with this Tongue

Quote
it would be much faster to send individual request to the database (e.g. by GET).
If you tell us the structure of the database, it is actually super easy to implement.
I don't have a database, just static HTML. That makes it very fast to browse as the server just has to read the file from disk, but I'm also at the point that adding more functionality becomes exceedingly difficult. I know nothing about databases and php Sad

Np, I will write an example script based on your .txt.
Database details for such functionalities would have to be provided by btct admin anyways.

Will adjust the script now ...
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
Seems to work, could be improved for sure.
I think you're overestimating my php-knowledge: I have no idea what to do with this Tongue

Quote
it would be much faster to send individual request to the database (e.g. by GET).
If you tell us the structure of the database, it is actually super easy to implement.
I don't have a database, just static HTML. That makes it very fast to browse as the server just has to read the file from disk, but I'm also at the point that adding more functionality becomes exceedingly difficult. I know nothing about databases and php Sad
full member
Activity: 504
Merit: 137
Nope.
I'm assuming he's just talking about producing an API endpoint. Sort of, a URL which supports a GET request and returns a valid format (JSON). No library needed.

Pretty much what you have here (http://loyce.club/Merit/merit.all.txt), just converted to a JSON format w/ the ability to filter based off parameters (sending user, receiving user, etc)

It could be done w/ 1 front-facing PHP script.
I don't know JSON/PHP (and don't really have the time to learn it now), so it's not something I can easily produce. But if someone (you?) wants to create it based on the full Merit data, go ahead. I can create for instance api.loyce.club to host it. Just tell me what I need to do Tongue

Has been a while since I did PHP but I hope this helps:

Quote
header("Content-type:application/json");

//dtg, merit, msg, giver, receiver
$url = "merits.txt";
$file = file($url);
$file = str_replace("   ", ",",$file);
$file = str_replace("\r\n", "",$file);
$jsonObj = array();
foreach ($file as $line => $value) {
   $value = explode(",", $value);
   // unsorted (line numbers)
   //$file[$line] = array("DTG" => $value[0], "Merit" => $value[1], "Message" => $value[2], "Donor" => $value[3], "Receiver" => $value[4]);

   //array sorted by DTG
   $jsonObj[]= array($value[0] => array("Merit" => $value[1], "Message" => $value[2], "Donor" => $value[3], "Receiver" => $value[4]));
}
echo json_encode($jsonObj, JSON_PRETTY_PRINT);

?>




Seems to work, could be improved for sure. But otherwise ... it has been a while. Besides this and as already stated, it would be much faster to send individual request to the database (e.g. by GET).
If you tell us the structure of the database, it is actually super easy to implement.

I have forgotten my actual request for this topic ...  Roll Eyes Grin

Got it again:
Sometimes quoting a full text makes posts less well structured. While there is a function to full-quote other posts, I would like to have a function to mark and insert text you actually want to quote from other posts.
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
I'm assuming he's just talking about producing an API endpoint. Sort of, a URL which supports a GET request and returns a valid format (JSON). No library needed.

Pretty much what you have here (http://loyce.club/Merit/merit.all.txt), just converted to a JSON format w/ the ability to filter based off parameters (sending user, receiving user, etc)

It could be done w/ 1 front-facing PHP script.
I don't know JSON/PHP (and don't really have the time to learn it now), so it's not something I can easily produce. But if someone (you?) wants to create it based on the full Merit data, go ahead. I can create for instance api.loyce.club to host it. Just tell me what I need to do Tongue
hero member
Activity: 1582
Merit: 759
The main problem is probably getting the merit data. You would need to make your own scraper to get merit data and then build an API or maybe ask Vod or Loyce for an API.
I have no plans on making an API (and have no idea how to do this). Besides, I don't scrape Merit continuously, only weekly (full list: merit.all.txt).

I'm assuming he's just talking about producing an API endpoint. Sort of, a URL which supports a GET request and returns a valid format (JSON). No library needed.

Pretty much what you have here (http://loyce.club/Merit/merit.all.txt), just converted to a JSON format w/ the ability to filter based off parameters (sending user, receiving user, etc)

It could be done w/ 1 front-facing PHP script.

For example,
http://loyce.club/Merit/merit.all.php?sending_user=2458002

@TryNinja, I'm not sure but I recall that Vod may have mentioned about an API in the past. So I'm not sure if one is in development right now.
Could have been me asking about it tho, so not 100% certain.
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
The main problem is probably getting the merit data. You would need to make your own scraper to get merit data and then build an API or maybe ask Vod or Loyce for an API.
I have no plans on making an API (and have no idea how to do this). Besides, I don't scrape Merit continuously, only weekly (full list: merit.all.txt).

API probably is best solution, but i was thinking about parsing HTML from user's merit summary page & built a list/dictionary contains total merit sent & count of merit transaction to an user.
Instead of scraping individual user's merit summaries, it's much less work to just scrape Recent merits and keep track (that's what BPIP does).

I think Piggy updated it to where it does actually support PMs.
Correct. Maggiordome was polluting the list of unread posts too much.
Pages:
Jump to: