Exemplo n.º 1
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with FatBotSlim. If not, see <http://www.gnu.org/licenses/>.
#
"""
This is a sample script to demonstrate how to create an IRC bot
using FatBotSlim.
"""

from fatbotslim.cli import make_bot, main
from fatbotslim.handlers import CommandHandler, EVT_PUBLIC


class HelloCommand(CommandHandler):
    """
    A sample command handler that makes the bot answer "Hello <user>!"
    when someone uses the "!hello" command (only in public messages).
    """
    triggers = {
        u'hello': [EVT_PUBLIC],
    }

    def hello(self, msg):
        self.irc.msg(msg.dst, u"Hello {0}!".format(msg.src.name))


bot = make_bot()  # create a bot instance
bot.add_handler(HelloCommand)  # register as many handlers as needed
main(bot)  # start the bot
Exemplo n.º 2
0
from fatbotslim.cli import make_bot, main
from fatbotslim.handlers import CommandHandler, EVT_PUBLIC


class HelloCommand(CommandHandler):
    triggers = {
        u'hello': [EVT_PUBLIC],
    }

    def hello(self, msg):
        self.irc.msg(msg.dst, u"Hello {0}!".format(msg.src.name))


bot = make_bot()
bot.add_handler(HelloCommand)
main(bot)