[MediaWiki-commits] [Gerrit] labs...ZppixBot[master]: Add guides for maintainers
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/402604 ) Change subject: Add guides for maintainers .. Add guides for maintainers Change-Id: I07468f25d931250d18859c50a74db74e5d2a821a --- M public_html/documentation.html 1 file changed, 69 insertions(+), 19 deletions(-) Approvals: MacFan4000: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/public_html/documentation.html b/public_html/documentation.html index 6516771..662337b 100644 --- a/public_html/documentation.html +++ b/public_html/documentation.html @@ -10,6 +10,14 @@ List of commands Module Development +Managing the bot (for maintainers) + + Restarting the bot + Making changes to modules + Making config changes + Canceling a reminder + Updateing the website for ZppixBot + List of commands @@ -92,7 +100,7 @@ tld -.task> +.task Gives a link to the specified task on Miraheze Phabricator .task 1 mh_phab @@ -373,13 +381,13 @@ - + Module development If you decided to extend ZppixBot with some functionality, you will need to create a new module. This instruction will guide you through the process of custom module development First of all, create a new file in modules directory with name your_module.py Bot modules are python scripts, so we shall start with importing required libraries (bot is using sopel) for your module to work. Here is the list of imports typically used: - + from __future__ import unicode_literals, absolute_import, print_function, division import sopel @@ -388,15 +396,15 @@ import sopel.tools from sopel.module import rule, priority, thread, commands, example - + Let's define a function, which replies to ".hi" command with a greeting: - + @commands('hi') def bot_hi(bot, trigger): bot.say('Hi ' + trigger.nick + '!') - + Explanation: using @commands we specify which command bot should react to (in our case ".hi") Handler function has two parameters: @@ -408,43 +416,43 @@ Unluckily, our bot will react only to ".hi" messages, but you may want it to react to ".hello" and ".hey" as well In order to achieve that, we may set multiple command variations bot will respond to by specifying all of them in the decorator: - + @commands('hi', 'hello', 'hey') def bot_hi(bot, trigger): bot.say('Hi ' + trigger.nick + '!') - + You may try running that code and see that bot will react to all commands mentioned by saying "hi" to message sender. Finally, you may want bot to accept some input from user. To demonstrate how to achieve that, let's develop a function which will welcome chat newcomers For example, if John joins your chat, you may ask bot to welcome him with command ".welcome John" and bot will send a message saying "Welcome, John! Enjoy yourself in this chat!" Similarly, you may ask bot to welcome Bob my saying ".welcome Bob" and bot will say "Welcome, Bob! Enjoy yourself in this chat!" Let's also use @example decorator to provide command usage example: - + @commands('welcome') @example('.welcome John') def bot_welcome(bot, trigger): bot.say('Welcome ' + trigger.group(2) + '! Enjoy yourself in this chat!') - + Explanation: we use trigger.group(2) to get the text after the command (in our example - name of user to welcome) Additionally, you may use bot.reply, which is similar to bot.say, but puts message sender name in the beginning of the message To demonstrate that, let's create an "echo" function - it will send back to you your message, which will be starting with you name (i.e mention you): - + @commands('echo') @example('.echo hello world!') def bot_welcome(bot, trigger): bot.reply('You said: ' + trigger.group(2)) - + That was an example of simple module. We recommend you visiting https://github.com/sopel-irc/sopel/wiki;>Sopel Wiki for more info on this topic. Complete source code of this example (file simple_module.py): - + from __future__ import unicode_literals, absolute_import, print_function, division import sopel @@ -452,23 +460,65 @@ import requests import sopel.tools from sopel.module import rule, priority, thread, commands, example - + @commands('hi', 'hello', 'hey') def bot_hi(bot, trigger): bot.say('Hi ' + trigger.nick + '!') - - + + commands('welcome') @example('.welcome John') def bot_welcome(bot, trigger): bot.say('Welcome ' + trigger.group(2) + '! Enjoy yourself in this chat!') - - + + @commands('echo') @example('.echo hello world!') def bot_welcome(bot, trigger):
[MediaWiki-commits] [Gerrit] labs...ZppixBot[master]: Add guides for maintainers
MacFan4000 has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/402604 ) Change subject: Add guides for maintainers .. Add guides for maintainers Change-Id: I07468f25d931250d18859c50a74db74e5d2a821a --- M public_html/documentation.html 1 file changed, 69 insertions(+), 19 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/labs/tools/ZppixBot refs/changes/04/402604/2 diff --git a/public_html/documentation.html b/public_html/documentation.html index 6516771..662337b 100644 --- a/public_html/documentation.html +++ b/public_html/documentation.html @@ -10,6 +10,14 @@ List of commands Module Development +Managing the bot (for maintainers) + + Restarting the bot + Making changes to modules + Making config changes + Canceling a reminder + Updateing the website for ZppixBot + List of commands @@ -92,7 +100,7 @@ tld -.task> +.task Gives a link to the specified task on Miraheze Phabricator .task 1 mh_phab @@ -373,13 +381,13 @@ - + Module development If you decided to extend ZppixBot with some functionality, you will need to create a new module. This instruction will guide you through the process of custom module development First of all, create a new file in modules directory with name your_module.py Bot modules are python scripts, so we shall start with importing required libraries (bot is using sopel) for your module to work. Here is the list of imports typically used: - + from __future__ import unicode_literals, absolute_import, print_function, division import sopel @@ -388,15 +396,15 @@ import sopel.tools from sopel.module import rule, priority, thread, commands, example - + Let's define a function, which replies to ".hi" command with a greeting: - + @commands('hi') def bot_hi(bot, trigger): bot.say('Hi ' + trigger.nick + '!') - + Explanation: using @commands we specify which command bot should react to (in our case ".hi") Handler function has two parameters: @@ -408,43 +416,43 @@ Unluckily, our bot will react only to ".hi" messages, but you may want it to react to ".hello" and ".hey" as well In order to achieve that, we may set multiple command variations bot will respond to by specifying all of them in the decorator: - + @commands('hi', 'hello', 'hey') def bot_hi(bot, trigger): bot.say('Hi ' + trigger.nick + '!') - + You may try running that code and see that bot will react to all commands mentioned by saying "hi" to message sender. Finally, you may want bot to accept some input from user. To demonstrate how to achieve that, let's develop a function which will welcome chat newcomers For example, if John joins your chat, you may ask bot to welcome him with command ".welcome John" and bot will send a message saying "Welcome, John! Enjoy yourself in this chat!" Similarly, you may ask bot to welcome Bob my saying ".welcome Bob" and bot will say "Welcome, Bob! Enjoy yourself in this chat!" Let's also use @example decorator to provide command usage example: - + @commands('welcome') @example('.welcome John') def bot_welcome(bot, trigger): bot.say('Welcome ' + trigger.group(2) + '! Enjoy yourself in this chat!') - + Explanation: we use trigger.group(2) to get the text after the command (in our example - name of user to welcome) Additionally, you may use bot.reply, which is similar to bot.say, but puts message sender name in the beginning of the message To demonstrate that, let's create an "echo" function - it will send back to you your message, which will be starting with you name (i.e mention you): - + @commands('echo') @example('.echo hello world!') def bot_welcome(bot, trigger): bot.reply('You said: ' + trigger.group(2)) - + That was an example of simple module. We recommend you visiting https://github.com/sopel-irc/sopel/wiki;>Sopel Wiki for more info on this topic. Complete source code of this example (file simple_module.py): - + from __future__ import unicode_literals, absolute_import, print_function, division import sopel @@ -452,23 +460,65 @@ import requests import sopel.tools from sopel.module import rule, priority, thread, commands, example - + @commands('hi', 'hello', 'hey') def bot_hi(bot, trigger): bot.say('Hi ' + trigger.nick + '!') - - + + commands('welcome') @example('.welcome John') def bot_welcome(bot, trigger): bot.say('Welcome ' + trigger.group(2) + '! Enjoy yourself in this chat!') - - + + @commands('echo') @example('.echo hello world!') def bot_welcome(bot, trigger): bot.reply('You