jakobovrum / diggler Goto Github PK
View Code? Open in Web Editor NEWIRC bot framework for the D programming language
Home Page: http://jakobovrum.github.io/Diggler/
License: Other
IRC bot framework for the D programming language
Home Page: http://jakobovrum.github.io/Diggler/
License: Other
If a variadic function is called with no arguments, it will error instead of calling the function with an empty array.
@usage("Choose from two or more items separated by spaces")
public void choose(string[] arg...){
import std.random;
if(arg.length<2) reply("Need at least two arguments");
else reply("Result: %s", arg[uniform(0, arg.length)]);
}
If `choose is called with no arguments, it will respond
error: got 0 argument(s), expected at least 1 for command "choose"
instead of
Need at least two arguments
For the default help command, I suggest that it echoes only the added command sets, instead of echoing every command set and their commands on a separate line. This will avoid flooding a channel if a large number of command sets have been added to the bot. The help command should also be modified so you can ask for help for a specific command set, and get the commands it defines.
Hey guys, I was wondering what the best way to go about keeping the bot online is.
Thanks.
When a function is overloaded in a CommandSet class, the following error is produced and compilation fails:
~/.dub/packages/diggler-master/src/diggler/command.d(431): Error: cannot infer type from overloaded function symbol &cmdSet.Echo
Error is produced from the following code.
class TestCommands : CommandSet!TestCommands {
mixin CommandContext!();
public void Echo(){
Echo("This is a test");
}
private void Echo(string input){
reply(input);
}
}
.....
bot.registerCommands(new TestCommands);
For example, the same authentication mechanism could be used to separate users into access levels.
Hi,
I came across your framework and thought on giving it a try but for some odd reason I am getting "Error: module bot is in file 'diggler/bot.d' which cannot be read" but the file is readable and does exist.
Compiling...
source/app.d(1): Error: module bot is in file 'diggler/bot.d' which cannot be read
import path[0] = source
import path[1] = ../../../darius/.dub/packages/diggler-master/dirk
import path[2] = ../../../darius/.dub/packages/diggler-master/dirk/libev
import path[3] = ../../../darius/.dub/packages/dirk-master
import path[4] = ../../../darius/.dub/packages/dirk-master/libev
import path[5] = /usr/include/dmd/phobos
import path[6] = /usr/include/dmd/druntime/import
Any idea?
Test bot code that triggers this issue
import diggler.bot;
import irc.client;
import irc.eventloop;
void main()
{
Bot.Configuration conf;
conf.nickName = "foo";
conf.userName = "foo";
conf.realName = "foo";
conf.commandPrefix = "!";
Bot bot = new Bot(conf);
IrcClient client = bot.connect("irc://foo");
client.onNickInUse ~= badNick => badNick ~ "_";
client.onConnect ~= delegate void() { client.join("#foo"); };
bot.eventLoop.postTimer(delegate void() { client.send("#foo", "Hi!"); }, 1.0, IrcEventLoop.TimerRepeat.yes);
bot.run();
}
Built with:
dub build --build=unittest
Build failure message:
../../.dub/packages/dirk-master/irc/tracker.d(452): Error: static assert (is(CustomTrackedChannel!void == CustomTrackedChannel!(UserInfo))) is false
../../.dub/packages/diggler-master/src/diggler/tracker.d(15): instantiated from here: CustomIrcTracker!(UserInfo)
FAIL ../../.dub/packages/diggler-master/.dub/build/library-unittest-linux.posix-x86_64-dmd_2066-7DC1260DB7DE0CFE87BD4B2292C2DD2B/ diggler staticLibrary
Everything runs fine if just built in debug mode though.
Hi,
it seems it's not possible in the crurent code of diggler/dirk to join a network with an account that has a password. Am I missing something? A github code search only brings up dirk's "join channel with a password".
Thanks!
run
should probably trap SIGINT to shut down bots properly on Ctrl+C.
Using the example code found here http://jakobovrum.github.io/Diggler/index.html , if I connect to an IRC serer (tested on Rizon & Esper) where the nick is already in use, the client sends "NICK *_" instead of the original nick with an appended underscore.
Log from running with "debugVersions": ["Dirk"]
":irc.losslessone.com 433 * mitch_ :Nickname is already in use." pos: 318
<< "NICK *" (length: 7)
":irc.losslessone.com 432 * * :Erroneous Nickname" pos: 369
Unhandled command "432"
The Diggler bot will still accept commands through private message even if allowPMCommands is explicitly set to false.
Using the example code found here http://pastebin.com/bazpL0AU , run the bot, and /msg DebugBot !echo foobar
The bot will respond as it normally would in a channel, which it should not.
A command such as !time may require several options: One to add, another to remove, and one to show. They may be called by !time add [nick] [zone], !time remove [nick], and !time [nick]. Currently, to implement this, you may do something like
void time(string[] args...){
switch(args[0].toLower){
case "add": ... break;
case "remove": ... break;
default: ... break;
}
}
My suggestion is to define multiple functions which state which option they accept, delimited by an underscore
void time_add(string nick, string zone){ ... }
void time_remove(string nick){ ... }
void time(string nick){ ... }
In addition to better code readability, this change would make the options for a command more visible when using !help.
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.