Jump to content

User:DYKUpdateBot/Manual: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Tool Labs -> Toolforge
Tags: Mobile edit Mobile web edit
updating to reflect Python rewrite
 
Line 1: Line 1:
This page explains how DYKUpdateBot works in a human-friendly language. It's really more a collection of facts than a manual. Of course, the best way to learn about the bot is to read the [[User:DYKUpdateBot/Code|source code]].
This page explains how DYKUpdateBot works in a human-friendly language. It's really more a collection of facts than a manual. Of course, the best way to learn about the bot is to read the [[User:DYKUpdateBot/Code|source code]].


DYKUpdateBot runs on an infinite loop. Every 10 minutes it checks whether it's time to update DYK. It calculates the next update time by taking the last update time from [[Template:Did you know/Next update/Time]] and adding the number of seconds specified at [[User:DYKUpdateBot/Time Between Updates]]. If there are fewer than 10 minutes left until the next update, the bot will check again at the scheduled time of the next update. The bot uses the wait function in Java to sleep, so it's not guaranteed to wake up at precisely the right time, but it's within 5 seconds in my experience.
DYKUpdateBot runs on an infinite loop. Every 10 minutes it checks whether it's time to update DYK. It calculates the next update time by taking the last update time from [[Template:Did you know/Next update/Time]] and adding the number of seconds specified at [[User:DYKUpdateBot/Time Between Updates]]. If there are fewer than 10 minutes left until the next update, the bot will check again at the scheduled time of the next update. The bot uses the <code>sleep</code> function in Python to sleep, so it's not guaranteed to wake up at precisely the right time, but it's within 5 seconds in my experience.


If the update is less than two hours away, the bot checks the formatting of the pages required for the next update. The bot makes sure that both [[T:DYK]] and the next queue have <nowiki><!--Hooks--> and <!--HooksEnd--></nowiki>, the image is protected, and the next queue is tagged with {{tl|DYKbotdo}}. If the next queue isn't tagged with DYKbotdo, DYKUpdateBot will post to [[WT:DYK]] if there's less than two hours left until the next update. The bot will also check if the image has "|right" or the size isn't 100x100px and will post to /Errors if so (however, the bot won't take any action and will continue updating).
If the update is less than 2 hours away, the bot checks the formatting of the pages required for the next update. The bot makes sure that both [[T:DYK]] and the next queue have <nowiki><!--Hooks--> and <!--HooksEnd--></nowiki>, the incoming image is protected, and the next queue is tagged with {{tl|DYKbotdo}}. If the next queue isn't tagged with DYKbotdo, DYKUpdateBot will post to [[WT:DYK]].


Once it's time to update, the bot does a few tasks:
Once it's time to update, the bot does a few tasks:
Line 11: Line 11:
* Purges the Main Page.
* Purges the Main Page.
* Edits [[Template:Did you know/Next update/Time]], replacing it with the time of the edit to [[T:DYK]]. The bot rounds down to the nearest minute.
* Edits [[Template:Did you know/Next update/Time]], replacing it with the time of the edit to [[T:DYK]]. The bot rounds down to the nearest minute.
* Archives the old set at [[Wikipedia:Recent additions]]. If there isn't a section for the day, the bot will create one. The bot relies on the <nowiki><!--BOTPOINTER--></nowiki> to figure out where to put the hooks; if it isn't there, the bot will put the hooks in wrong spot and break the formatting ([http://en.wikipedia.org/w/index.php?title=User:Shubinator/Sandbox/Wikipedia_Recent_additions&diff=prev&oldid=345313745 example]). If the image in the old set was a cropped version and tagged with {{tl|m-cropped}}, the bot will replace the cropped image with the original image for the archive.
* Archives the old set at [[Wikipedia:Recent additions]]. If there isn't a section for the day, the bot will create one. The bot relies on the <nowiki><!--BOTPOINTER--></nowiki> to figure out where to put the hooks; if it isn't there, the bot will put the hooks in wrong spot and break the formatting ([http://en.wikipedia.org/w/index.php?title=User:Shubinator/Sandbox/Wikipedia_Recent_additions&diff=prev&oldid=345313745 example]).
* Tags article talk pages with {{tl|dyktalk}}. If the talk page is already tagged with {{tl|ArticleHistory}}, the bot will add the dykdate and dykentry parameters to it instead of adding a new tag. The bot makes sure that the corresponding article exists before tagging the talk page, and it will also follow redirects. The bot will try to find the hook for the article by looking for the article title in the set of hooks (case-insensitive). The bot won't tag example credits.
* Tags article talk pages with {{tl|DYK talk}}. If the talk page is already tagged with {{tl|Article history}}, the bot will add the <code>dykdate</code>, <code>dykentry</code>, and <code>dyknom</code> parameters to it instead of adding a new tag. The bot makes sure that the corresponding article exists before tagging the talk page, and it will also follow redirects. The bot will try to find the hook for the article by looking for the article title in the set of hooks (case-insensitive). The bot won't tag example credits.
* Credits users. The bot makes sure the user is registered or the talk page redirects to another talk page (in case of a rename) before adding the credit. It will follow redirects and won't credit [[User:Editor]] or [[User:Nominator]]. The bot doesn't use its own signature, but instead reads the signature from the {{tl|DYKbotdo}} tag in the queue.
* Credits users. The bot makes sure the user is registered or an anonymous editor with contributions before adding the credit. Bot also checks if the user was renamed, and will credit the renamed user. It will follow redirects and won't credit [[User:Editor]] or [[User:Nominator]]. The bot doesn't use its own signature, but instead reads the signature from the {{tl|DYKbotdo}} tag in the queue.
* Tags the file (or the original, in the case of a cropped image) with {{tl|DYKfile}}.
* Deletes the file coming off of T:DYK if it was cropped just for DYK, or if: 1) it exists on enwiki and Commons under the same filename, 2) it is tagged with {{tl|c-uploaded}}, and 3) no revisions exist from before the time the file was uploaded. (Admins, if you don't want the bot to delete an image, format the c-uploaded tag slightly differently so the bot can't recognize it, like <nowiki>{{ c-uploaded }}</nowiki>.) Otherwise, if the file is hosted locally on enwiki, and the protection reason mentions "Main Page", the bot will unprotect the file.
* Tags the file (or the original, in the case of a cropped image) with {{tl|DYKfile}}. The bot will not add another tag if one is already on the file.
* Clears the queue with {{[[User:DYKUpdateBot/REMOVE THIS LINE]]}}.
* Clears the queue with {{[[User:DYKUpdateBot/REMOVE THIS LINE]]}}.
* Increments the [[Template:Did you know/Queue/Next|next queue count]].
* Increments the [[Template:Did you know/Queue/Next|next queue count]].
Line 22: Line 21:
Other notes:
Other notes:
* The bot sees $ just like any other character, so there's no need to use {{tl|dollarsign}}.
* The bot sees $ just like any other character, so there's no need to use {{tl|dollarsign}}.
* The bot replaces multiple spaces with one space when it reads hooks from the queue.
* After each edit the bot asks the server for its latest edit to the page it thinks it edited to make sure the edit processed.
* The bot checks if it's logged in by null editing its own userpage and checking the result.
* The bot will drift to sync with 00:00 UTC if necessary. The drift is calculated in the update time written to [[Template:Did you know/Next update/Time]]. [[User:DYKUpdateBot/ResyncDrift]] specifies the maximum amount the bot can drift per update. To disable drift, set both values to 0 on that page. See [[User:DYKUpdateBot/ResyncDrift]] and its editnotice for more technical information on automatic resyncing.
* The bot will drift to sync with 00:00 UTC if necessary. The drift is calculated in the update time written to [[Template:Did you know/Next update/Time]]. [[User:DYKUpdateBot/ResyncDrift]] specifies the maximum amount the bot can drift per update. To disable drift, set both values to 0 on that page. See [[User:DYKUpdateBot/ResyncDrift]] and its editnotice for more technical information on automatic resyncing.
* The bot outputs errors it encounters to [[User:DYKUpdateBot/Errors]]. The bot will clear the page once it completes a run with no errors, but that doesn't mean the previous error(s) is/are taken care of. For example, if the bot sees username that isn't registered, it will [http://en.wikipedia.org/w/index.php?title=User:DYKUpdateBot/Errors&diff=prev&oldid=347693625 edit the errors page] after its run saying that the username isn't valid. About 10 minutes later it will then [http://en.wikipedia.org/w/index.php?title=User:DYKUpdateBot/Errors&diff=prev&oldid=347694555 clear the page] because it has successfully completed a status check. However, someone should still go back and see why the error occurred and if the credit was [http://en.wikipedia.org/w/index.php?title=User_talk:Steven_Walling&diff=347713210&oldid=347010133 meant to go to someone else].
* The bot outputs errors it encounters to [[User:DYKUpdateBot/Errors]]. The bot will clear the page once it completes a run with no errors, but that doesn't mean the previous error(s) is/are taken care of. For example, if the bot sees username that isn't registered, it will [[Special:Diff/347693625|edit the errors page]] after its run saying that the username isn't valid. About 10 minutes later it will then [[Special:Diff/347694555|clear the page]] because it has successfully completed a status check. However, someone should still go back and see why the error occurred and if the credit was [[Special:Diff/347713210|meant to go to someone else]].
* The bot can match hooks that use ship templates (like {{tl|HMS}}) with their titles.
* The bot can match hooks that use templates (like {{tl|HMS}}) with their titles.
* The bot runs on a [[WP:Toolforge|WMF Toolforge]] server.
* The bot runs on a [[WP:Toolforge|WMF Toolforge]] server.
* If the bot is caught in an exception loop, it will check (after ~30 minutes) if the next queue number has been changed manually. If so, the bot will reset itself.
* Please [[User talk:Shubinator|let me know]] if you see any bugs.
* Please [[User talk:Shubinator|let me know]] if you see any bugs.

Latest revision as of 03:25, 10 May 2021

This page explains how DYKUpdateBot works in a human-friendly language. It's really more a collection of facts than a manual. Of course, the best way to learn about the bot is to read the source code.

DYKUpdateBot runs on an infinite loop. Every 10 minutes it checks whether it's time to update DYK. It calculates the next update time by taking the last update time from Template:Did you know/Next update/Time and adding the number of seconds specified at User:DYKUpdateBot/Time Between Updates. If there are fewer than 10 minutes left until the next update, the bot will check again at the scheduled time of the next update. The bot uses the sleep function in Python to sleep, so it's not guaranteed to wake up at precisely the right time, but it's within 5 seconds in my experience.

If the update is less than 2 hours away, the bot checks the formatting of the pages required for the next update. The bot makes sure that both T:DYK and the next queue have <!--Hooks--> and <!--HooksEnd-->, the incoming image is protected, and the next queue is tagged with {{DYKbotdo}}. If the next queue isn't tagged with DYKbotdo, DYKUpdateBot will post to WT:DYK.

Once it's time to update, the bot does a few tasks:

  • Reads from the next queue and takes everything between <!--Hooks--> and <!--HooksEnd--> as the new set.
  • Reads from the T:DYK and takes everything between <!--Hooks--> and <!--HooksEnd--> as the old set.
  • Replaces the old set with the new on T:DYK and edits the page.
  • Purges the Main Page.
  • Edits Template:Did you know/Next update/Time, replacing it with the time of the edit to T:DYK. The bot rounds down to the nearest minute.
  • Archives the old set at Wikipedia:Recent additions. If there isn't a section for the day, the bot will create one. The bot relies on the <!--BOTPOINTER--> to figure out where to put the hooks; if it isn't there, the bot will put the hooks in wrong spot and break the formatting (example).
  • Tags article talk pages with {{DYK talk}}. If the talk page is already tagged with {{Article history}}, the bot will add the dykdate, dykentry, and dyknom parameters to it instead of adding a new tag. The bot makes sure that the corresponding article exists before tagging the talk page, and it will also follow redirects. The bot will try to find the hook for the article by looking for the article title in the set of hooks (case-insensitive). The bot won't tag example credits.
  • Credits users. The bot makes sure the user is registered or an anonymous editor with contributions before adding the credit. Bot also checks if the user was renamed, and will credit the renamed user. It will follow redirects and won't credit User:Editor or User:Nominator. The bot doesn't use its own signature, but instead reads the signature from the {{DYKbotdo}} tag in the queue.
  • Tags the file (or the original, in the case of a cropped image) with {{DYKfile}}.
  • Clears the queue with {{User:DYKUpdateBot/REMOVE THIS LINE}}.
  • Increments the next queue count.


Other notes:

  • The bot sees $ just like any other character, so there's no need to use {{dollarsign}}.
  • The bot will drift to sync with 00:00 UTC if necessary. The drift is calculated in the update time written to Template:Did you know/Next update/Time. User:DYKUpdateBot/ResyncDrift specifies the maximum amount the bot can drift per update. To disable drift, set both values to 0 on that page. See User:DYKUpdateBot/ResyncDrift and its editnotice for more technical information on automatic resyncing.
  • The bot outputs errors it encounters to User:DYKUpdateBot/Errors. The bot will clear the page once it completes a run with no errors, but that doesn't mean the previous error(s) is/are taken care of. For example, if the bot sees username that isn't registered, it will edit the errors page after its run saying that the username isn't valid. About 10 minutes later it will then clear the page because it has successfully completed a status check. However, someone should still go back and see why the error occurred and if the credit was meant to go to someone else.
  • The bot can match hooks that use templates (like {{HMS}}) with their titles.
  • The bot runs on a WMF Toolforge server.
  • Please let me know if you see any bugs.