User talk:wbm1058/Creating bots

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Creating Bots[edit]

Hello, I would like to start making my own bot, but have no idea where to start, I went to the special bot password page and set that up, what else do I do. And I do want to write it in php. Thank you, Prairie Astronomer Contributions 01:16, 8 May 2021 (UTC)[reply]

First thing is to decide where you want to run it. If you want to run it on your own computer running Microsoft Windows, I can help with that. If you want to run it on Cloud Services, a Mac or someplace else, best to find someone else to help you. – wbm1058 (talk) 01:21, 8 May 2021 (UTC)[reply]
@Prairie Astronomer: Also see Help:Creating a bot if you haven't looked at that yet. – wbm1058 (talk) 01:25, 8 May 2021 (UTC)[reply]
If I can run it on my computer thats fine. I want to start actually programming it. Do I need to create a new account for my bot? how do I access it now since I used the Special:BotPassword page? Prairie Astronomer Contributions 01:27, 8 May 2021 (UTC)[reply]
I wouldn't worry about setting up you bot account just yet. If you want to run it under PHP you need to set up PHP on your machine. Go here https://www.php.net/ to download and install the latest version. I don't bother with all the files, just the ones I need. I made a C:\php directory which is where I installed and run everything. – wbm1058 (talk) 01:32, 8 May 2021 (UTC)[reply]
@Prairie Astronomer: You might take a look at the thread I created when I was just getting started: Help talk:Creating a bot/Archive 1#Testing a "hello world" bot and running it under Windows PowerShell. – wbm1058 (talk) 01:43, 8 May 2021 (UTC)[reply]
Ok, so I installed php, although someday I will move this to my raspberry pi, what next? I want to start programming it. I know some things about php as I sue it for my own private web server. My first use for it as a test would be creating an edit on my talk page. Thanks, Prairie Astronomer Contributions 02:08, 8 May 2021 (UTC)[reply]
You can interact with Wikipedia through a "framework" Help:Creating a bot#PHP. Download a copy of the framework I took over and support now, from User:RMCD bot/botclasses.php – I don't have any experience with using any other frameworks so if you want to use something else, best to get help from someone else. The framework will be looking for logininfo.php to get your user ID and password, that's probably the only other file you'll need. That's kept in a separate file so that if you publish your source code it's not revealed.
You also probably need curl so you can make API requests using HTTPS. This is something my memory is foggy on, as it's a set-it-up-and-forget-it kind of thing. m:Talk:HTTPS#Bots. I have a curl.exe and curl-ca-bundle.crt security certificate in my php directory. This is tech stuff I don't understand that well myself but maybe you can figure out what to do from the discussion link I gave you.
You can make a test run to edit your own talk page from your own account, you don't need to use a bot account until you're ready to make a lot of automated edits that need prior approval at WP:BRFA. wbm1058 (talk) 02:58, 8 May 2021 (UTC)[reply]
@Prairie Astronomer: You can run my sample test program User:Wbm1058/edittalk.php to make an edit to your talk page. I ran it once and the output is the section below. Just change $mytalkpage value to your own talk page. – wbm1058 (talk) 03:47, 8 May 2021 (UTC)[reply]
I use Windows PowerShell to run php programs on my machine. I see that's open source now so maybe it will run on raspberry pi too. wbm1058 (talk) 03:52, 8 May 2021 (UTC)[reply]

Test edit[edit]

How ya doin? Bot1058 (talk) 03:34, 8 May 2021 (UTC)[reply]

Client URL Library (libcurl)[edit]

Installation of cURL consists of removing the semi-colon in front of the ;extension=php_curl.dll line in php.ini, and saving php.ini – it is not necessary to have a curl.exe in your php directory, though that might be useful for testing. Official curl website link: https://curl.haxx.se/wbm1058 (talk) 18:49, 1 October 2021 (UTC)[reply]

Running PHP 7.4 on Windows[edit]

PHP 7.4.x requires Microsoft Visual C++ Redistributable for Visual Studio 2019wbm1058 (talk) 15:37, 23 October 2021 (UTC)[reply]

About the bots[edit]

I have been noticing that the bots you run have been knocked out several times. Despite spending hours at a stretch clerking WP:RMC, I don't think that's substianable. Is there any way that I can help you to get the bots back to their reliable states? Co-run, co-operate, etc? I am a developer myself, mostly on WordPress, and pretty grounded in PHP and JS. Let me know. – robertsky (talk) 02:34, 23 August 2022 (UTC)[reply]

@Robertsky: My desktop computer froze up for some unknown reason, while I was on an extended road trip. I found it was still powered up but there was no video; forcing a shutdown and restart got it back up. I was running bots from my laptop as my backup, when I had Internet access available. I suppose the solution is to have backups running from another platform so that with failure on a single platform the bots would still be running on the other platform. With this task I've gained a bit more experience operating on the Toolforge platform. I've been asked why I don't run my bots on "the cluster" – I even put that in my bot's FAQ. I suppose I should bump my priority and make the effort. I know I'll need some Linux commands to set it up. If you have experience running (PHP) bots on the Toolforge, perhaps you could help guide me there. Thanks, wbm1058 (talk) 12:58, 29 August 2022 (UTC)[reply]
How was the road trip? Nice, I hope! I can empathise on the hardware failure. I run stuff on my own servers/VPS. I don't have experience yet running stuff on Toolforge, although I do have an account on it (have been putting off converting my index creation/maintenance script into a user friendly interface for others to generate their indexes). However, I have had looked at the RMCD script to manually generate the last few rounds of updates before you came back back proper. What you can try running is crontab or schedule the script to run on their Jobs framework:
For crontab, after spinning up an instance, edit the cron file and insert something like this:
*/30 * * * * /usr/bin/php /home/someUser/RMCD/requestedmoves.php >> /var/log/RMCD.log
This would run the script every 30 minutes (given that you have a hard stop of 24 minutes running time in the script, this should be more than enough).
For Jobs framework, (from the documentations) you can try running a command like this (not tested):
toolforge-jobs run mycronjob --command "/usr/bin/php /home/someUser/RMCD/requestedmoves.php >> /var/log/RMCD.log" --image tf-php74 --schedule "*/30 * * * *"
or for ease of tweaking the options, write a jobs.yaml file (again, based from documentation.):
::- name: 30-minute_rmcd_bot
::  command: /usr/bin/php /home/someUser/RMCD/requestedmoves.php
::  image: tf-php74
::  schedule: "*/30 * * * *"
::  emails: onfailure
::
Then after that, this command: toolforge-jobs load jobs.yaml – robertsky (talk) 17:31, 29 August 2022 (UTC)[reply]
@Robertsky: Yes my trip was a nice break from Wikipedia and I got a lot more exercise than I do sitting online... My experience trying to get bots running automated on the "Jobs framework" has been a long slog, would you mind reading through my BRFA (might help you getting started on Toolforge too) and if that's TL;DR then just skip to Job logs at the end. Any help you might give me there would be appreciated. – wbm1058 (talk) 20:06, 19 November 2022 (UTC)[reply]
Hello there! I am currently on holiday myself, having just attended m:ESEAP Conference! I will take a look at this sometime in December if you don't mind. Cheers! – robertsky (talk) 11:55, 21 November 2022 (UTC)[reply]