dominikh changed the topic of #cinch to: The IRC Framework | Latest version: Cinch 2.0.5
v0n has joined #cinch
space_ has quit [Ping timeout: 248 seconds]
rickmasta has joined #cinch
awkisopen has joined #cinch
<awkisopen>
fellow cinch lovers: any recommendations for a command parser? the more complex the IRC commands get the less sense it makes to use a regex/logic for all of them
<dominikh>
postmodern whipped up some "command" thing, I don't know if it comes with its own pattern language or not, but personally I don't see why regular expressions aren't adequate, seeing that commands are regular languages
<awkisopen>
well, can I give a situation I'm dealing with right now as an example?
<dominikh>
sure
jonahR has joined #cinch
<awkisopen>
I use an IRC bot to watch changes on subreddits of reddit. now, there are multiple ways to watch or stop watching a subreddit, the command syntax coming down to something much like: !(un)watch [channel] <subreddit> [posts|comments]
<awkisopen>
if you don't provide the [channel] option, it defaults to the current channel, and if you don't provide posts or comments, it defaults to watching both.
<awkisopen>
pretty simple to use, but it results in some ugly regexes and logic. I've whipped up a little command parser for myself to handle situations like this (you can define multiple arguments and whether they are required/what their default value should be) and it works alright, but I didn't know if there was a more full-featured library out there.
<dominikh>
a) with some optional capture groups and the fact that those arguments will then be nil if missing it's fairly straightforward, but that's coming from someone who loves regular expressions. b) you could have multiple matchers, that are grouped. only the first one to match will be executed, so you could go from most precise to least precise pattern. c) https://github.com/postmodern/cinch-commands it does have
<dominikh>
it's own way to define arguments, but I have no idea how complex it is, or if it even supports optional arguments
<awkisopen>
trust me, I love regexes as much as the next guy, but I can't help but look at the monstrosities I have created and wonder, is this best practice?
<awkisopen>
this looks cute
<dominikh>
"best practice" is a funny question for a project whose users mostly aren't concerned with best practice.
<awkisopen>
is there a better IRC library you'd recommend?
<dominikh>
I'd probably go for multiple matchers in that particular case
<awkisopen>
(not being sarcastic, I'm all ears)
<dominikh>
this has little to do with the library, this has to do with the people who use it :) There's no community of expert programmers who write IRC bots.
<dominikh>
by the way, I'm the author of Cinch, I probably won't recommend a different library ;)
<awkisopen>
oic. hahaha that's fair enough! I am trying my best, though.
<awkisopen>
well I don't know maybe you hate yourself?
<awkisopen>
it can happen!
<dominikh>
haha
<awkisopen>
srsly though I am a huge fan of the library in general. this threading is sexy as hell
<dominikh>
well, be glad you're not the one who had to implement it. That's probably the part I hate myself for ;)
<awkisopen>
I don't blame ya, threads can be a headache. but, not to kiss ass or anything, you made it easy to deal with
<dominikh>
thanks
<awkisopen>
this is turning into a large project though, I've been kicking around the idea of writing a larger parser that would kick the appropriate command to the appropriate plugin
<dominikh>
(the amount of people who write bots for reddit is amusing)
<awkisopen>
i.e. !plugin command arg1 arg2 would then call command(arg1, arg2) in the plugin registered to respond to (plugin)
<awkisopen>
the amount of people who suck at it is also amusing
<awkisopen>
I mean uhhh... yeah! reddit. it's cool
<dominikh>
heh
<dominikh>
that kind of command dispatching should be fairly straightforward
<dominikh>
darn easy if ignoring security, still trivial if going for a secure implementation
<awkisopen>
indeed. it would make me sad, though, to just have one megaplugin that would do that, it seems like it'd go against the whole design of cinch
<dominikh>
you have one plugin per component/feature of the bot. so if you had !foo <command> I'd assume foo is the feature and command is, well, a command of that
<dominikh>
naturally if you have !bar <command> as well, you'd have a second plugin bar, with its own dispatching
<awkisopen>
yeah, that's what I'm considering doing. I'm just not sure how to accomplish that without modifying the library itself
<dominikh>
I don't see why you'd need to modify the library
<awkisopen>
because I am dumb and I don't see the super obvious way of doing it that is probably super obvious?
<dominikh>
you could e.g. write a module that adds methods to register the mappings, a generic matcher and a method with that that figures out which method to dispatch to. then you include that module in your plugin classes, set the mapping and write your commands
<awkisopen>
oh yeah I forgot modules existed
<dominikh>
(it's how I implemented ACLs in my own bot. a mixin that registers hooks and drops/accepts messages based on a globally defined set of rules)
<dominikh>
(all plugins that would want to make use of ACLs would just include that module)
<awkisopen>
niiiice
<awkisopen>
I think I will steal that idea because it is super sensible
<dominikh>
to be fair, I cheated and didn't use a mixin but did change the library (via monkey patching), but that's because I know what I am doing :P
<dominikh>
a mixin would've worked equally well
<awkisopen>
> that's because I know what I am doing :P
<awkisopen>
you, sir, are a butt
<awkisopen>
but really, thanks for the advice
<dominikh>
monkey patching libraries of other people is silly. monkey patching your own libraries is safe. hence I know what I am doing ;)
<dominikh>
I am almost positive I won't break my own hacks
rickmasta has quit [Quit: Leaving...]
<awkisopen>
who's to say I don't enjoy living on The Edge
<dominikh>
well, by all means ;) But don't complain when one day the edge will break off
<awkisopen>
haha that would be terrible
<awkisopen>
in all seriousness, though, the module makes more sense
* dominikh
nods
rickmasta has joined #cinch
rickmasta has quit [Quit: Leaving...]
rickmasta has joined #cinch
rickmasta has quit [Quit: Leaving...]
rickmasta has joined #cinch
sleetdrop has joined #cinch
sleetdrop has quit [Client Quit]
sleetdrop has joined #cinch
sleetdrop has quit [Max SendQ exceeded]
sleetdrop has joined #cinch
sleetdrop has quit [Max SendQ exceeded]
sleetdrop has joined #cinch
sleetdrop has quit [Client Quit]
sleetdrop has joined #cinch
rickmasta has quit [Quit: Leaving...]
sleetdrop has quit [Quit: Computer has gone to sleep.]
jonahR has quit [Quit: jonahR]
v0n has quit [Ping timeout: 264 seconds]
rickmasta has joined #cinch
Space has joined #cinch
tennel has quit [Quit: I'm gone!]
tennel has joined #cinch
<tennel>
hello, is it possible to control the command line output of a bot?
txdv_ has quit [Ping timeout: 245 seconds]
oddmunds1 has joined #cinch
oddmunds has quit [Ping timeout: 240 seconds]
Space has quit [Read error: Connection reset by peer]
Space has joined #cinch
rickmasta has quit [Quit: Leaving...]
maetthew has joined #cinch
oddmunds1 is now known as oddmunds
postmodern has quit [Quit: Leaving]
maetthew has quit [Quit: maetthew]
<tennel>
hello, can i use timers in a bot without creating a plugin?
<tennel>
yes i can :)
Azure has quit [Ping timeout: 248 seconds]
Azure has joined #cinch
tennel has left #cinch ["WeeChat 0.4.1"]
v0n has joined #cinch
Spami has joined #cinch
v0n has quit [Quit: WeeChat 0.4.1]
v0n has joined #cinch
kx has quit [Ping timeout: 256 seconds]
kx has joined #cinch
ayonix has quit [Quit: No Ping reply in 180 seconds.]
jonahR has joined #cinch
v0n has quit [Ping timeout: 276 seconds]
v0n has joined #cinch
jonahR has quit [Quit: jonahR]
v0n has quit [Quit: WeeChat 0.4.1]
v0n has joined #cinch
v0n has quit [Read error: Operation timed out]
v0n has joined #cinch
postmodern has joined #cinch
jonahR has joined #cinch
jonahR has quit [Quit: jonahR]
Space has quit [Read error: Connection reset by peer]
Space has joined #cinch
jonahR has joined #cinch
Spami has quit [Quit: This computer has gone to sleep]