Closed zerocarbthirty closed 8 years ago
Hi, I think I've gotten a little further along in this the only thing I need to know now is how i can use the command that called the plugin in the plugin for example say you have @command(['wonka', 'crazy']) how can I use that like this:
cardinal.sendMsg(channel, "%s: The command issued was" % command)
Thanks for pointing out that the decorator imports are not documented on the wiki. I will update it tonight.
To see what command was called, you should inspect msg
. The msg
variable contains the complete message that the command triggered on. An easy way of getting only the command (including the .
prefix) is to use command = msg.split(' ')[0]
. Then just remove the first character to see it without the .
However, give this page another read: https://github.com/JohnMaguire/Cardinal/wiki/Writing-Plugins
You'll notice that the @command
decorator is specifically for creating commands with the .
prefix. To respond to a custom string, you'll probably want to look at this section here: https://github.com/JohnMaguire/Cardinal/wiki/Writing-Plugins#responding-to-regular-expressions
And since you mentioned the ping plugin, here's the relevant line: https://github.com/JohnMaguire/Cardinal/blob/master/plugins/ping/plugin.py#L8
thanks, I ended up changing the . to a ! because . appears to be a 'special character' to twitch's chat
:+1: I'd like to make that a configurable option one day. Thanks for pointing out a use case where it's actually necessary!
Hi, so I've been struggling to write what I think is a very simple plugin which simply opens a different URL depending on what command is received in IRC so if someone types !thingy it will open URL/thingy if they type whee it will open URL/whee (or whatever urls i define per command). it's a way to tie IRC into an API basically.
anyway, I can't get it to work at all so I tried using the code from the wiki:
that code above actually doesn't work apparently you have to add : from cardinal.decorators import command, help to the top of it in order for @command and @help to function but even with that in there typing hello or hi in IRC doesn't do anything.
I also tried simply modifying the 'ping' plugin as such:
anyway, if anyone knows what i'm doing wrong I would greatly appreciate it.
The thing I can't figure out is why the default "ping" command works fine.. driving me crazy