timbus / net--irc Goto Github PK
View Code? Open in Web Editor NEWA simple and easy to use IRC Bot framework for Perl 6
License: ISC License
A simple and easy to use IRC Bot framework for Perl 6
License: ISC License
Readme says:
It's currently in active development, but it is mostly stable until perl 6 implements either threads or async I/O so it can work correctly as a bot (timed events and things that block the runtime are not possible yet.)
That's from 2010. It seems like all of that stuff works quite well on MoarVM (or at least it is good enough!).
I need timed events…
Hi I'm trying to write a simple bot using your library. The example code you give has a typo at: Net::IRC::DefaultHandlers.new() should be Net::IRC::Handlers::Default.new() after I fixed this I still get an error with the Event class not having a .reply(). Has everything changed since your documentation? Any help you can pass along would be much appreciated. I'll try using the source, in the meantime :) Thanks for your efforts on this! Using a grammar appears to be a really clean mechanism for creating libraries of this kind! Exciting stuff.
No such method 'reply' for invocant of type 'Net::IRC::Event'
in method joined at ./echo.p6:17
in sub METAOP_HYPER_CALL at src/gen/CORE.setting:11943
in block at lib/Net/IRC/Bot.pm:163
in method reify at src/gen/CORE.setting:5186
in method reify at src/gen/CORE.setting:5088
in method reify at src/gen/CORE.setting:5088
in method gimme at src/gen/CORE.setting:5466
in method eager at src/gen/CORE.setting:5445
in method eager at src/gen/CORE.setting:1099
in sub eager at src/gen/CORE.setting:5730
in method do_dispatch at lib/Net/IRC/Bot.pm:161
in block at lib/Net/IRC/Bot.pm:146
in method dispatch at lib/Net/IRC/Bot.pm:115
in method run at lib/Net/IRC/Bot.pm:89
in block at ./echo.p6:29
The panda info for your library reads:
PROJECT LIST:
"Net::IRC::Bot" => "0.9"
"State" => "installed"
"Source-url" => "git://github.com/TiMBuS/Net--IRC.git"
"Description" => "An IRC bot framework"
INSTALLED VERSION:
"depends" => []
"description" => "An IRC bot framework"
"name" => "Net::IRC::Bot"
"source-revision" => "99e638d"
"source-type" => "git"
"source-url" => "git://github.com/TiMBuS/Net--IRC.git"
"version" => "0.9"
Your example with my modification looks like (echo.p6):
use Net::IRC::Bot;
#Roles can let you break up large event handler modules into smaller ones.
role ExtraAnnoying {
has %enemies = ('bob', 'sam', 'chanserv') X=> 1;
#Magical type constraints only let this event be called when $e.who is an enemy
multi method said ($e where {.who ~~ %enemies}) {
$e.reply($e.msg); #Parrot back what was said;
}
}
class AnnoyUsers does ExtraAnnoying {
#Will be called when the bot gets a join event
multi method joined ($e) {
$e.reply("Hi there, {$e.who}!");
}
}
Net::IRC::Bot.new(
nick => 'blargh',
server => 'irc.ivixor.net',
channels => <#bots>,
modules => (
Net::IRC::Handlers::Default.new(),
AnnoyUsers.new(),
),
).run;
Like the title says, for some reason I can't make CommandHandler work with a module of my own. Trying to write my own kind of 8-ball as an example, if I make my own said
multimethod that will work (of course using nextsame
to get to the CommandHandler anyway), but the CommandHandler's dispatcher doesn't. For now I'll have to workaround by essentially doing command handling manually.
It's also worth noting that using the supplied modules works as expected, so it really is just a problem with using CommandHandler myself.
Here's some example code:
class Foobar does Net::IRC::CommandHandler {
my @replies = "a", "b", "bar";
multi method cueball($ev, $match) is cmd {
$ev.msg("{$ev.who}: {@replies.pick}");
}
}
I cannot find it, it looks like the license is not specified at all.
I kinda expect GPL or AGPL, but I understand that Artistic License (or more like a disjunction of Artistic and GPL) is somewhat preferred in perl community. Any license is fine as long as it is specified.
Thanks!
It seems like all of the modules are broken. f063741 introduces is cmd
, which in turn breaks all existing code.
What was
method command_tell ( $ev, $match ) {
should now be written as
method tell ( $ev, $match ) is cmd {
This, however, is not necessarily the best move. I've tried fixing it, but method 8ball
starts with a digit (which is not a valid name). Also, Help.pm
still relies on command_
prefixes.
I don't really get it. This change was made more than a year ago, how come the code base is not adapted?
It seems like if you are using more than one module that is using CommandHandler
you will be getting pointless “Nothing to dispatch” warnings (command exists, but in another module. Therefore CommandHandler of the current module decides to throw a warning).
Possible workaround is to use inheritance and smash everything into one module. I don't really want to do that though.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.