De Pontão Nós Digitais
- 1 0) Instale o supybot:
- 2 1) Crie o bot, primeiro criando o diretório e então, dentro dele, rodando o supybot-wizard
- 3 2) Crie um plugin, tipicamente
- 4 3) Inicie o bot, em nosso caso
- 5 4) No cliente irc, mande uma mensagem de identificação de dono do bot:
- 6 5) Mande-o carregar o plugin:
- 7 6) Veja na listagem que o plugin está existente
- 8 x) Pronto! Seu plugin mínimo está feito. Agora é fazer ele responder, que é o próximo microtutorial.
0) Instale o supybot:
$ git clone git://supybot.git.sourceforge.net/gitroot/supybot/supybot $ cd supybot $ sudo python setup.py install
1) Crie o bot, primeiro criando o diretório e então, dentro dele, rodando o supybot-wizard
renato@renatolab:~/repos$ mkdir coBot renato@renatolab:~/repos$ cd coBot/ renato@renatolab:~/repos/coBot$ supybot-wizard ERROR 2011-12-10T21:47:49 Invalid user dictionary file, resetting to empty. ERROR 2011-12-10T21:47:49 Exact error: IOError: [Errno 2] No such file or directory: 'conf/users.conf' ERROR 2011-12-10T21:47:49 Invalid channel database, resetting to empty. ERROR 2011-12-10T21:47:49 Exact error: IOError: [Errno 2] No such file or directory: 'conf/channels.conf' WARNING 2011-12-10T21:47:49 Couldn't open ignore database: [Errno 2] No such file or directory: 'conf/ignores.conf' This is a wizard to help you start running supybot. What it will do is create the necessary config files based on the options you select here. So hold on tight and be ready to be interrogated :) First of all, we can bold the questions you're asked so you can easily distinguish the mostly useless blather (like this) from the questions that you actually have to answer. Would you like to try this bolding? [y/n] (default: y) Do you see this in bold? [y/n] y Great! We've got some preliminary things to get out of the way before we can really start asking you questions that directly relate to what your bot is going to be like. We want to know if you consider yourself an advanced Supybot user because some questions are just utterly boring and useless for new users. Others might not make sense unless you've used Supybot for some time. Are you an advanced Supybot user? [y/n] (default: n) Your bot needs to create some directories in order to store the various log, config, and data files. Where would you like to create these directories? (default: .) Good! We're done with the directory stuff. Now we're going to ask you things that actually relate to the bot you'll be running. First, we need to know the name of the network you'd like to connect to. Not the server host, mind you, but the name of the network. If you plan to connect to irc.freenode.net, for instance, you should answer this question with 'freenode' (without the quotes). What IRC network will you be connecting to? freenode What server would you like to connect to? irc.freenode.net Found irc.freenode.net (no network available). IRC Servers almost always accept connections on port 6667. They can, however, accept connections anywhere their admin feels like he wants to accept connections from. Does this server require connection on a non-standard port? [y/ n] (default: n) What nick would you like your bot to use? coBot205 Some servers require a password to connect to them. Most public servers don't. If you try to connect to a server and for some reason it just won't work, it might be that you need to set a password. Do you want to set such a password? [y/n] (default: n) Of course, having an IRC bot isn't the most useful thing in the world unless you can make that bot join some channels. Do you want your bot to join some channels when he connects? [y/ n] (default: y) Separate channels with spaces. If the channel is locked with a key, follow the channel name with the key separated by a comma. For example: #supybot-bots #mychannel,mykey #otherchannel What channels? (default: ) #labmacambira #metareciclagem #estudiolivre Beginning configuration for Admin... Done! Beginning configuration for User... Done! Beginning configuration for Channel... Done! Beginning configuration for Misc... Done! Beginning configuration for Config... Done! Now we're going to run you through plugin configuration. There's a variety of plugins in supybot by default, but you can create and add your own, of course. We'll allow you to take a look at the known plugins' descriptions and configure them if you like what you see. Would you like to look at plugins individually? [y/n] n Although supybot offers a supybot-adduser script, with which you can add users to your bot's user database, it's *very* important that you have an owner user for you bot. Would you like to add an owner user for your bot? [y/n] (default: y) What should the owner's username be? o0o0o What should the owner's password be? Re-enter password: Of course, when you're in an IRC channel you can address the bot by its nick and it will respond, if you give it a valid command (it may or may not respond, depending on what your config variable replyWhenNotCommand is set to). But your bot can also respond to a short "prefix character," so instead of saying "bot: do this," you can say, "@do this" and achieve the same effect. Of course, you don't *have* to have a prefix char, but if the bot ends up participating significantly in your channel, it'll ease things. Would you like to set the prefix char(s) for your bot? [y/n] (default: y) Enter any characters you want here, but be careful: they should be rare enough that people don't accidentally address the bot (simply because they'll probably be annoyed if they do address the bot on accident). You can even have more than one. I (jemfinch) am quite partial to @, but that's because I've been using it since my ocamlbot days. What would you like your bot's prefix character(s) to be? , There are a lot of options we didn't ask you about simply because we'd rather you get up and running and have time left to play around with your bot. But come back and see us! When you've played around with your bot enough to know what you like, what you don't like, what you'd like to change, then take a look at your configuration file when your bot isn't running and read the comments, tweaking values to your heart's desire. All done! Your new bot configuration is coBot205.conf. If you're running a *nix based OS, you can probably start your bot with the command line "supybot coBot205.conf". If you're not running a *nix or similar machine, you'll just have to start it like you start all your other Python scripts. renato@renatolab:~/repos/coBot$
2) Crie um plugin, tipicamente
$ cd plugins $ supybot-plugin-create
renato@renatolab:~/repos/coBot/plugins$ supybot-plugin-create What should the name of the plugin be? Minimum Sometimes you'll want a callback to be threaded. If its methods (command or regexp-based, either one) will take a significant amount of time to run, you'll want to thread them so they don't block the entire bot. Does your plugin need to be threaded? [y/n] n What is your real name, so I can fill in the copyright and license appropriately? o0o0o Do you wish to use Supybot's license for your plugin? [y/n] n Your new plugin template is in the Minimum directory. renato@renatolab:~/repos/coBot/plugins$
3) Inicie o bot, em nosso caso
$ supybot coBot205.conf <pre>INFO 2011-12-10T21:58:03 Creating new Irc for freenode. INFO 2011-12-10T21:58:03 Connecting to irc.freenode.net:6667. INFO 2011-12-10T21:58:03 Loading plugins (connecting to freenode). INFO 2011-12-10T21:58:10 Server pratchett.freenode.net has version ircd- seven-1.1.3 INFO 2011-12-10T21:58:10 Got end of MOTD from pratchett.freenode.net INFO 2011-12-10T21:58:20 Join to #labmacambira on freenode synced in 5.63 seconds. INFO 2011-12-10T21:58:21 Join to #metareciclagem on freenode synced in 6.80 seconds. INFO 2011-12-10T21:58:23 Join to #estudiolivre on freenode synced in 8.39 seconds.
4) No cliente irc, mande uma mensagem de identificação de dono do bot:
[#estudiolivre] /msg coBot205 identify o0o0o <PASSWORD>
5) Mande-o carregar o plugin:
[#estudiolivre] /msg coBot205 load Minimum
22:02 <coBot205> The operation succeeded.
6) Veja na listagem que o plugin está existente
22:08 < o0o0o> coBot205: list 22:08 < coBot205> o0o0o: Admin, Channel, Config, Minimum, Misc, Owner, and User
x) Pronto! Seu plugin mínimo está feito. Agora é fazer ele responder, que é o próximo microtutorial.
Você pode baixar o plugin como ele deve estar neste repositório:
No seu primeiro commit (ATENÇÂO: o supyTutorial apresenta versões posteriores do coBot205, use uma ferramenta de visualisação para Git).