你现在尚未登录,许多功能可能无法正常使用,若已有账号,请登录,若没有,请先注册Twitch账号
目前我们有非常多的待翻译条目,你也可以看一下目前我们需要优先处理的有哪些目前我们有非常多的待翻译条目,你也可以看一下目前我们需要优先处理的有哪些英雄页面的攻略、克制和物品页面的推荐英雄、小贴士等均为社区玩家编写的,你也可以把自己的心得写上去哦。英雄页面的攻略、克制和物品页面的推荐英雄、小贴士等均为社区玩家编写的,你也可以把自己的心得写上去哦。看不懂bkb文本中debuff技能免疫之前施加并且没有被驱散雪球战斗嚎叫是少数几个不带驱散的技能免疫,亲自试一下战斗嚎叫过程中还有没有debuff吧。看不懂bkb文本中debuff技能免疫之前施加并且没有被驱散雪球战斗嚎叫是少数几个不带驱散的技能免疫,亲自试一下战斗嚎叫过程中还有没有debuff吧。看不懂技能的buff/debuff是哪个跟哪个?鼠标移动到名称上就能看到游戏内显示的名字了。看不懂技能的buff/debuff是哪个跟哪个?鼠标移动到名称上就能看到游戏内显示的名字了。目前我們沒有善於製作其他中文變體的人員,如果您善於或擁有相關技術,請幫忙補充其他中文變體的空白。目前我們沒有善於製作其他中文變體的人員,如果您善於或擁有相關技術,請幫忙補充其他中文變體的空白。

Help:Bots

来自Dota 2 Wiki
跳转至: 导航搜索
Robot.png

A bot is a computer program that automatically retrieves or updates wiki pages when it is executed. In general, bots are used for repetitive maintenance tasks, whose volume and characteristics are too large to be performed manually by users.

Developing and executing bots is usually outside the role of normal users, requires programming experience, and must be done in coordination with the wiki's admins or other staff.

Bot user accounts

It is recommended that users that intend to do a lot of automation using bots create a separate user account for performing bot actions. Bot accounts should recognizably indicate which user they belong to, usually by appending "bot" to the user's primary account name.

Users that wish to create a bot user account should notify a bureaucrat or Gamepedia staff on the wiki before doing so, as they can add the bot user group to the account using Special:UserRights.

Having a separate bot account is beneficial for a few reasons. First, it allows the bot operator to more easily recognize and revert their bot's edits if necessary, without accidentally reverting any of the edits made by their primary account. Additionally, bot accounts can be flagged with the bot user group. By default, edits by bot users performed with the API or a third party tool are hidden in Special:RecentChanges, which reduces clutter in the recent changes. Any edits made by an account marked with the bot user group will be marked by an lowercase letter B (b) next to their edits when viewed in Recent changes, and the visibility of these changes can be toggled using the "Show/hide bots" option.

Accessing the wiki with a bot

Bots do not access the wiki through the normal user interface. MediaWiki has an API (Application Programming Interface) available for this purpose. An API is a protocol for standardized communication between two computer programs.

Bots use several different tools and frameworks, the most popular being AutoWikiBrowser and Pywikibot. Several bot operators create their own frameworks, for fun or because of the many limitations that existing frameworks have.

Authentication

Because bots do not access the wiki the same as a regular user, they also use a special authentication system. This uses a password generator to create a special login for automated tools, accessible at Special:BotPasswords on any Gamepedia wiki. For more information on using the bot password for each bot tool, see Pywikibot and AutoWikiBrowser.

This method for setting up an account to use a bot or other external editors using the API interface was implemented on Gamepedia on March 1, 2017.

AutoWikiBrowser or Pywikibot?

When getting started with automation, one of the first decisions you must make is which bot tool to use. For most users, the choice is between AutoWikiBrowser, commonly abbreviated "AWB", and Pywikibot, commonly abbreviated "PWB". While many people use both, depending on the task, each tool has its pros and cons.

AWB

Pros:

  • Has a GUI instead of just being done through command prompt
  • Easier setup & lower barrier to entry as a result
  • Better at doing complex find-and-replace options

Cons:

  • Limited selection of generators, so editing lists of pages with complex criteria sometimes requires several steps
  • AWB is Windows-only (but can be run in Wine on Mac and Linux)

PWB

Pros:

  • Can delete, move, and create pages easily instead of just editing
  • Once you are familiar with the command line interface & available options, it's fewer clicks to accomplish some of the tasks that both tools can do
  • Can use a wider variety of page list generators
  • Can be run on most operating systems without requiring extra tools

Cons:

  • More difficult to set up and more difficult to learn
  • Harder to preview changes before making them

Custom bot development

Some advanced users have created their own bots and scripts to edit the wiki. These can be written in several languages, some of the most commonly used being JavaScript and Python. See mw:API:Client code for more information.

See also

PyWikiBot[编辑]

这是为对PWB感兴趣的所写的,每步指引:

  • 检查Python有没有添加到你的系统路径。;C:\Python3x
永久修改默认环境变量,请在开始菜单中搜索‘编辑系统环境变量’,或打开系统属性,高级系统设置,点击环境变量按钮。在对话框中,你可以增加或修改用户变量和系统变量。修改系统变量时,你需要对你的机器获得无限制的权限(比如管理员权限)
  • 从这里开始,你需要CMD,即windows控制台命令行。通过python setup.py install安装"request"模组。你可以通过cd把当前路径修改为解压"request" setup.py时的路径
  • 下载PWB并将其解压到任意位置(比如C:/Programs/PWB)
  • 创建一个空的文件,命名为"dota2_family.py",放置在C:/Programs/PWB/pywikibot/families/目录下,并粘贴以下内容:
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, unicode_literals

from pywikibot import family
from pywikibot.tools import deprecated


class Family(family.Family):  # noqa: D101

    name = 'dota2'
    langs = {
        'en': 'dota2.gamepedia.com',
        'ru': 'dota2-ru.gamepedia.com',
        'pt': 'dota2-pt.gamepedia.com',
        'zh': 'dota2-zh.gamepedia.com',
    }

    def scriptpath(self, code):
        return {
            'en': '',
            'ru': '',
            'pt': '',
            'zh': '',
        }[code]

    @deprecated('APISite.version()')
    def version(self, code):
        return {
            'en': '1.31.2',
            'ru': '1.31.2',
            'pt': '1.31.2',
            'zh': '1.31.2',
        }[code]

    def protocol(self, code):
        return {
            'en': 'https',
            'ru': 'https',
            'pt': 'https',
            'zh': 'https',
        }[code]
  • 通过CMD运行PWB目录下的python generate_user_files.py,根据程序指引进行操作
  • (可选)删除两个example文件
  • 打开user-config.py并作出以下修改:这是我(Molldust)的修改,当然你可能不是管理员(sysop),也可能不需要这里列出的所有语言。根据自己需求修改即可:
# If you use either of these functions to define the family to work on by
# default (the ‘family’ variable below), you must place the function call
# before the definition of the ‘family’ variable.
family = 'dota2'

# The language code of the site we're working on.
mylang = 'en'

# The dictionary usernames should contain a username for each site where you
# have a bot account. If you have a unique username for all languages of a
# family , you can use '*'

password_file = "user-password.py"

usernames['dota2']['en'] = u'Username'
usernames['dota2']['pt'] = u'Username'
usernames['dota2']['ru'] = u'Username'
usernames['dota2']['zh'] = u'Username'
sysopnames['dota2']['en'] = u'Username'
sysopnames['dota2']['pt'] = u'Username'
sysopnames['dota2']['ru'] = u'Username'
sysopnames['dota2']['zh'] = u'Username'
  • 创建一个新的密码文件,命名为user-password.py,放置在当前目录下,并粘贴以下内容。将<>内的内容替换为你在机器人权限中定义的:
("<用户名>", BotPassword("<机器人名称>", "<机器人密码>"))
  • 所有步骤已经完成,你可以通过这条命令检查一下是否可用。这会列出所有包含"斯拉"的页面(比如,斯拉克和斯拉达):

python pwb.py listpages -format:3 -titleregex:"斯拉" -start:!

AutoWikiBot[编辑]

Grow icon.png
▶️ 他们叫我小小。
这篇文章目前不完整。即文章尚未完成。
可以通过编辑、拓展来帮助 Dota 2 Wiki 完成本文。

mwclient[编辑]

官方文档:请阅读文档

mwclient是一个更加轻量级版本的PyWikiBot。没有预先安装的脚本。

  1. 下载Python (版本 >2.7 即可)。
  2. 通过键入pip3 install mwclient (pip install mwclient 如果用的是Python 2.x)安装mwclient。
  3. 新建一个新的文本文件并另存为.py扩展名。
  4. 在你刚新建的文件中编写你的脚本。
  5. 通过键入python3 path/to/your/file.py (python path/to/your/file.py Python version 2.x)运行。

说明[编辑]

mwclient模块是基于Site()对象的。这个对象需要在你的脚本开始之前配置:

import mwclient


site = mwclient.Site('dota2.gamepedia.com', path='/')

通过Site.login()方法验证你的账户。所需的机器人账号可以从Special:BotPasswords中创建。

site.login('bot_user_name', 'bot_password')

自此你就可以使用文档中提到的方法了。

示例[编辑]

import mwclient


site = mwclient.Site('dota2.gamepedia.com', path='/')
site.login('bot_user_name', 'bot_password')


page = site.Pages['Evil Geniuses']
text = page.text()
text = text.replace('Arteezy', 'Fear')
page.save(text, summary='Bot: Arteezy left the team.')