Page MenuHomePhabricator
Paste P1850

arwikinews core pwb welcome.py
ActivePublic

Authored by Meno25 on Aug 7 2015, 11:15 AM.
Referenced Files
F703037: arwikinews core pwb welcome.py
Aug 7 2015, 11:15 AM
Subscribers
None
Script to welcome new users.
This script works out of the box for Wikis that
have been defined in the script. It is currently used on the Dutch, Norwegian,
Albanian, Italian Wikipedia, Wikimedia Commons and English Wikiquote.
Ensure you have community support before running this bot!
URLs to current implementations:
* Wikimedia Commons: https://commons.wikimedia.org/wiki/Commons:Welcome_log
* Dutch Wikipedia: https://nl.wikipedia.org/wiki/Wikipedia:Logboek_welkom
* Italian Wikipedia: https://it.wikipedia.org/wiki/Wikipedia:Benvenuto_log
* English Wikiquote: https://en.wikiquote.org/wiki/Wikiquote:Welcome_log
* Persian Wikipedia: https://fa.wikipedia.org/wiki/ویکی‌پدیا:سیاهه_خوشامد
* Korean Wikipedia: https://ko.wikipedia.org/wiki/위키백과:Welcome_log
Everything that needs customisation to support additional projects is
indicated by comments.
Description of basic functionality:
* Request a list of new users every period (default: 3600 seconds)
You can choose to break the script after the first check (see arguments)
* Check if new user has passed a threshold for a number of edits
(default: 1 edit)
* Optional: check username for bad words in the username or if the username
consists solely of numbers; log this somewhere on the wiki (default: False)
Update: Added a whitelist (explanation below).
* If user has made enough edits (it can be also 0), check if user has an empty
talk page
* If user has an empty talk page, add a welcome message.
* Optional: Once the set number of users have been welcomed, add this to the
configured log page, one for each day (default: True)
* If no log page exists, create a header for the log page first.
This script (by default not yet implemented) uses two templates that need to
be on the local wiki:
* {{WLE}}: contains mark up code for log entries (just copy it from Commons)
* {{welcome}}: contains the information for new users
This script understands the following command-line arguments:
-edit[:#] Define how many edits a new user needs to be welcomed
(default: 1, max: 50)
-time[:#] Define how many seconds the bot sleeps before restart
(default: 3600)
-break Use it if you don't want that the Bot restart at the end
(it will break) (default: False)
-nlog Use this parameter if you do not want the bot to log all
welcomed users (default: False)
-limit[:#] Use this parameter to define how may users should be
checked (default:50)
-offset[:TIME] Skip the latest new users (those newer than TIME)
to give interactive users a chance to welcome the
new users (default: now)
Timezone is the server timezone, GMT for Wikimedia
TIME format : yyyymmddhhmmss
-timeoffset[:#] Skip the latest new users, accounts newer than
# minutes
-numberlog[:#] The number of users to welcome before refreshing the
welcome log (default: 4)
-filter Enable the username checks for bad names (default: False)
-ask Use this parameter if you want to confirm each possible
bad username (default: False)
-random Use a random signature, taking the signatures from a wiki
page (for instruction, see below).
-file[:#] Use a file instead of a wikipage to take the random sign.
If you use this parameter, you don't need to use -random.
-sign Use one signature from command line instead of the default
-savedata This feature saves the random signature index to allow to
continue to welcome with the last signature used.
-sul Welcome the auto-created users (default: False)
-quiet Prevents users without contributions are displayed
-quick Provide quick check by API bulk-retrieve user datas
********************************* GUIDE ***********************************
Report, Bad and white list guide:
1) Set in the code which page it will use to load the badword, the
whitelist and the report
2) In these page you have to add a "tuple" with the names that you want to
add in the two list. For example: ('cat', 'mouse', 'dog')
You can write also other text in the page, it will work without problem.
3) What will do the two pages? Well, the Bot will check if a badword is in
the username and set the "warning" as True. Then the Bot check if a word
of the whitelist is in the username. If yes it remove the word and
recheck in the bad word list to see if there are other badword in the
username.
Example:
* dio is a badword
* Claudio is a normal name
* The username is "Claudio90 fuck!"
* The Bot finds dio and sets "warning"
* The Bot finds Claudio and sets "ok"
* The Bot finds fuck at the end and sets "warning"
* Result: The username is reported.
4) When a user is reported you have to check him and do:
* If he's ok, put the {{welcome}}
* If he's not, block him
* You can decide to put a "you are blocked, change another username"
template or not.
* Delete the username from the page.
IMPORTANT : The Bot check the user in this order:
* Search if he has a talkpage (if yes, skip)
* Search if he's blocked, if yes he will be skipped
* Search if he's in the report page, if yes he will be skipped
* If no, he will be reported.
Random signature guide:
Some welcomed users will answer to the one who has signed the welcome message.
When you welcome many new users, you might be overwhelmed with such answers.
Therefore you can define usernames of other users who are willing to receive
some of these messages from newbies.
1) Set the page that the bot will load
2) Add the signatures in this way:
*<SPACE>SIGNATURE
<NEW LINE>
Example:
<pre>
* [[User:Filnik|Filnik]]
* [[User:Rock|Rock]]
</pre>
NOTE: The white space and <pre></pre> aren't required but I suggest you to
use them.
*************************** Known issues/FIXMEs ****************************
* *
* The regex to load the user might be slightly different from project to *
* project. (In this case, write to Filnik or the PWRF for help...) *
* Use a class to group toghether the functions used. *
* *
******************************** Badwords **********************************
The list of Badwords of the code is opened. If you think that a word is
international and it must be blocked in all the projects feel free to add it.
If also you think that a word isn't so international, feel free to delete it.
However, there is a dinamic-wikipage to load that badwords of your project or
you can add them directly in the source code that you are using without adding
or deleting.
Some words, like "Administrator" or "Dio" (God in italian) or "Jimbo" aren't
badword at all but can be used for some bad-nickname.
Global arguments available for all bots:
-dir:PATH Read the bot's configuration data from directory given by
PATH, instead of from the default directory.
-lang:xx Set the language of the wiki you want to work on, overriding
the configuration in user-config.py. xx should be the
language code.
-family:xyz Set the family of the wiki you want to work on, e.g.
wikipedia, wiktionary, wikitravel, ...
This will override the configuration in user-config.py.
-user:xyz Log in as user 'xyz' instead of the default username.
-daemonize:xyz Immediately return control to the terminal and redirect
stdout and stderr to file xyz.
(only use for bots that require no input from stdin).
-help Show this help text.
-log Enable the log file, using the default filename
'welcome-bot.log'
Logs will be stored in the logs subdirectory.
-log:xyz Enable the log file, using 'xyz' as the filename.
-nolog Disable the log file (if it is enabled by default).
-maxlag Sets a new maxlag parameter to a number of seconds. Defer bot
edits during periods of database server lag. Default is set by
config.py
-putthrottle:n Set the minimum time (in seconds) the bot will wait between
-pt:n saving pages.
-put_throttle:n
-debug:item Enable the log file and include extensive debugging data
-debug for component "item" (for all components if the second form
is used).
-verbose Have the bot provide additional console output that may be
-v useful in debugging.
-cosmeticchanges Toggles the cosmetic_changes setting made in config.py or
-cc user_config.py to its inverse and overrules it. All other
settings and restrictions are untouched.
-simulate Disables writing to the server. Useful for testing and
debugging of new code (if given, doesn't do any real
changes, but only shows what would have been changed).
-<config var>:n You may use all given numeric config variables as option and
modify it with command line.
WARNING: u'Site wikinews:ar not managed by welcome.py: lang "ar" missing in nete xt[wikinews].'
meno25@tools-bastion-01:~/core$ python pwb.py welcome -edit:0 -nlog -sul -limit:500 -lang:ar -family:wikinews
Script to welcome new users.
This script works out of the box for Wikis that
have been defined in the script. It is currently used on the Dutch, Norwegian,
Albanian, Italian Wikipedia, Wikimedia Commons and English Wikiquote.
Ensure you have community support before running this bot!
URLs to current implementations:
* Wikimedia Commons: https://commons.wikimedia.org/wiki/Commons:Welcome_log
* Dutch Wikipedia: https://nl.wikipedia.org/wiki/Wikipedia:Logboek_welkom
* Italian Wikipedia: https://it.wikipedia.org/wiki/Wikipedia:Benvenuto_log
* English Wikiquote: https://en.wikiquote.org/wiki/Wikiquote:Welcome_log
* Persian Wikipedia: https://fa.wikipedia.org/wiki/ویکی‌پدیا:سیاهه_خوشامد
* Korean Wikipedia: https://ko.wikipedia.org/wiki/위키백과:Welcome_log
Everything that needs customisation to support additional projects is
indicated by comments.
Description of basic functionality:
* Request a list of new users every period (default: 3600 seconds)
You can choose to break the script after the first check (see arguments)
* Check if new user has passed a threshold for a number of edits
(default: 1 edit)
* Optional: check username for bad words in the username or if the username
consists solely of numbers; log this somewhere on the wiki (default: False)
Update: Added a whitelist (explanation below).
* If user has made enough edits (it can be also 0), check if user has an empty
talk page
* If user has an empty talk page, add a welcome message.
* Optional: Once the set number of users have been welcomed, add this to the
configured log page, one for each day (default: True)
* If no log page exists, create a header for the log page first.
This script (by default not yet implemented) uses two templates that need to
be on the local wiki:
* {{WLE}}: contains mark up code for log entries (just copy it from Commons)
* {{welcome}}: contains the information for new users
This script understands the following command-line arguments:
-edit[:#] Define how many edits a new user needs to be welcomed
(default: 1, max: 50)
-time[:#] Define how many seconds the bot sleeps before restart
(default: 3600)
-break Use it if you don't want that the Bot restart at the end
(it will break) (default: False)
-nlog Use this parameter if you do not want the bot to log all
welcomed users (default: False)
-limit[:#] Use this parameter to define how may users should be
checked (default:50)
-offset[:TIME] Skip the latest new users (those newer than TIME)
to give interactive users a chance to welcome the
new users (default: now)
Timezone is the server timezone, GMT for Wikimedia
TIME format : yyyymmddhhmmss
-timeoffset[:#] Skip the latest new users, accounts newer than
# minutes
-numberlog[:#] The number of users to welcome before refreshing the
welcome log (default: 4)
-filter Enable the username checks for bad names (default: False)
-ask Use this parameter if you want to confirm each possible
bad username (default: False)
-random Use a random signature, taking the signatures from a wiki
page (for instruction, see below).
-file[:#] Use a file instead of a wikipage to take the random sign.
If you use this parameter, you don't need to use -random.
-sign Use one signature from command line instead of the default
-savedata This feature saves the random signature index to allow to
continue to welcome with the last signature used.
-sul Welcome the auto-created users (default: False)
-quiet Prevents users without contributions are displayed
-quick Provide quick check by API bulk-retrieve user datas
********************************* GUIDE ***********************************
Report, Bad and white list guide:
1) Set in the code which page it will use to load the badword, the
whitelist and the report
2) In these page you have to add a "tuple" with the names that you want to
add in the two list. For example: ('cat', 'mouse', 'dog')
You can write also other text in the page, it will work without problem.
3) What will do the two pages? Well, the Bot will check if a badword is in
the username and set the "warning" as True. Then the Bot check if a word
of the whitelist is in the username. If yes it remove the word and
recheck in the bad word list to see if there are other badword in the
username.
Example:
* dio is a badword
* Claudio is a normal name
* The username is "Claudio90 fuck!"
* The Bot finds dio and sets "warning"
* The Bot finds Claudio and sets "ok"
* The Bot finds fuck at the end and sets "warning"
* Result: The username is reported.
4) When a user is reported you have to check him and do:
* If he's ok, put the {{welcome}}
* If he's not, block him
* You can decide to put a "you are blocked, change another username"
template or not.
* Delete the username from the page.
IMPORTANT : The Bot check the user in this order:
* Search if he has a talkpage (if yes, skip)
* Search if he's blocked, if yes he will be skipped
* Search if he's in the report page, if yes he will be skipped
* If no, he will be reported.
Random signature guide:
Some welcomed users will answer to the one who has signed the welcome message.
When you welcome many new users, you might be overwhelmed with such answers.
Therefore you can define usernames of other users who are willing to receive
some of these messages from newbies.
1) Set the page that the bot will load
2) Add the signatures in this way:
*<SPACE>SIGNATURE
<NEW LINE>
Example:
<pre>
* [[User:Filnik|Filnik]]
* [[User:Rock|Rock]]
</pre>
NOTE: The white space and <pre></pre> aren't required but I suggest you to
use them.
*************************** Known issues/FIXMEs ****************************
* *
* The regex to load the user might be slightly different from project to *
* project. (In this case, write to Filnik or the PWRF for help...) *
* Use a class to group toghether the functions used. *
* *
******************************** Badwords **********************************
The list of Badwords of the code is opened. If you think that a word is
international and it must be blocked in all the projects feel free to add it.
If also you think that a word isn't so international, feel free to delete it.
However, there is a dinamic-wikipage to load that badwords of your project or
you can add them directly in the source code that you are using without adding
or deleting.
Some words, like "Administrator" or "Dio" (God in italian) or "Jimbo" aren't
badword at all but can be used for some bad-nickname.
Global arguments available for all bots:
-dir:PATH Read the bot's configuration data from directory given by
PATH, instead of from the default directory.
-lang:xx Set the language of the wiki you want to work on, overriding
the configuration in user-config.py. xx should be the
language code.
-family:xyz Set the family of the wiki you want to work on, e.g.
wikipedia, wiktionary, wikitravel, ...
This will override the configuration in user-config.py.
-user:xyz Log in as user 'xyz' instead of the default username.
-daemonize:xyz Immediately return control to the terminal and redirect
stdout and stderr to file xyz.
(only use for bots that require no input from stdin).
-help Show this help text.
-log Enable the log file, using the default filename
'welcome-bot.log'
Logs will be stored in the logs subdirectory.
-log:xyz Enable the log file, using 'xyz' as the filename.
-nolog Disable the log file (if it is enabled by default).
-maxlag Sets a new maxlag parameter to a number of seconds. Defer bot
edits during periods of database server lag. Default is set by
config.py
-putthrottle:n Set the minimum time (in seconds) the bot will wait between
-pt:n saving pages.
-put_throttle:n
-debug:item Enable the log file and include extensive debugging data
-debug for component "item" (for all components if the second form
is used).
-verbose Have the bot provide additional console output that may be
-v useful in debugging.
-cosmeticchanges Toggles the cosmetic_changes setting made in config.py or
-cc user_config.py to its inverse and overrules it. All other
settings and restrictions are untouched.
-simulate Disables writing to the server. Useful for testing and
debugging of new code (if given, doesn't do any real
changes, but only shows what would have been changed).
-<config var>:n You may use all given numeric config variables as option and
modify it with command line.
WARNING: u'Site wikinews:ar not managed by welcome.py: lang "ar" missing in netext[wikinews].'

Event Timeline

Meno25 changed the title of this paste from untitled to arwikinews core pwb welcome.py.
Meno25 updated the paste's language from autodetect to autodetect.
Meno25 added a project: Pywikibot.
Meno25 updated the paste's language from autodetect to text.Aug 7 2015, 11:41 AM