|
@@ -24,6 +24,9 @@
|
|
|
*
|
|
*
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
|
|
+#include <bdlib/src/Stream.h>
|
|
|
|
|
+#include <bdlib/src/String.h>
|
|
|
|
|
+#include "src/misc_file.h"
|
|
|
|
|
|
|
|
/* Do we have any flags that will allow us ops on a channel?
|
|
/* Do we have any flags that will allow us ops on a channel?
|
|
|
*/
|
|
*/
|
|
@@ -1908,6 +1911,68 @@ static void cmd_reset(int idx, char *par)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static void cmd_play(int idx, char *par)
|
|
|
|
|
+{
|
|
|
|
|
+ if (!par[0]) {
|
|
|
|
|
+ dprintf(idx, "Usage: play [channel] <file>\n");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ char *chname = NULL;
|
|
|
|
|
+ struct chanset_t *chan = NULL;
|
|
|
|
|
+
|
|
|
|
|
+ if (strchr(CHANMETA, par[0]) != NULL)
|
|
|
|
|
+ chname = newsplit(&par);
|
|
|
|
|
+ else
|
|
|
|
|
+ chname = 0;
|
|
|
|
|
+ chan = get_channel(idx, chname);
|
|
|
|
|
+ if (!chan)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ if (!par[0]) {
|
|
|
|
|
+ dprintf(idx, "Usage: play [channel] <file>\n");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ memberlist *m = ismember(chan, botname);
|
|
|
|
|
+
|
|
|
|
|
+ if (!m) {
|
|
|
|
|
+ dprintf(idx, "Cannot play to %s: I'm not on that channel.\n", chan->dname);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ get_user_flagrec(dcc[idx].user, &user, chan->dname);
|
|
|
|
|
+
|
|
|
|
|
+ if (!me_op(chan) && !me_voice(chan)) {
|
|
|
|
|
+ dprintf(idx, "Cannot play to %s: I am not voiced or opped.\n", chan->dname);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ putlog(LOG_CMDS, "*", "#%s# (%s) play %s", dcc[idx].nick, chan->dname, par);
|
|
|
|
|
+
|
|
|
|
|
+ // Ensure file exists and is within proper path
|
|
|
|
|
+ bd::String file(par);
|
|
|
|
|
+
|
|
|
|
|
+ if (file[0] == '/' || file(0, 2) == "..") {
|
|
|
|
|
+ dprintf(idx, "Cannot play '%s': Illegal path.\n", par);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!can_stat(par)) {
|
|
|
|
|
+ dprintf(idx, "Cannot play '%s': Cannot access file.\n", par);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ bd::String prefix;
|
|
|
|
|
+ bd::Stream stream;
|
|
|
|
|
+ stream.loadFile(par);
|
|
|
|
|
+ bd::String str;
|
|
|
|
|
+ while (stream.tell() < stream.length()) {
|
|
|
|
|
+ str = stream.getline().chomp();
|
|
|
|
|
+ if (str.length())
|
|
|
|
|
+ dprintf(DP_PLAY, "PRIVMSG %s :%s\n", chan->name, str.c_str());
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static cmd_t irc_dcc[] =
|
|
static cmd_t irc_dcc[] =
|
|
|
{
|
|
{
|
|
|
{"act", "o|o", (Function) cmd_act, NULL, LEAF},
|
|
{"act", "o|o", (Function) cmd_act, NULL, LEAF},
|
|
@@ -1930,6 +1995,7 @@ static cmd_t irc_dcc[] =
|
|
|
{"msg", "o", (Function) cmd_msg, NULL, LEAF|AUTH},
|
|
{"msg", "o", (Function) cmd_msg, NULL, LEAF|AUTH},
|
|
|
{"nick", "m", (Function) cmd_nick, NULL, LEAF},
|
|
{"nick", "m", (Function) cmd_nick, NULL, LEAF},
|
|
|
{"op", "o|o", (Function) cmd_op, NULL, LEAF|AUTH},
|
|
{"op", "o|o", (Function) cmd_op, NULL, LEAF|AUTH},
|
|
|
|
|
+ {"play", "m|m", (Function) cmd_play, NULL, LEAF|AUTH},
|
|
|
{"reset", "m|m", (Function) cmd_reset, NULL, LEAF|AUTH},
|
|
{"reset", "m|m", (Function) cmd_reset, NULL, LEAF|AUTH},
|
|
|
{"resetbans", "o|o", (Function) cmd_resetbans, NULL, LEAF|AUTH},
|
|
{"resetbans", "o|o", (Function) cmd_resetbans, NULL, LEAF|AUTH},
|
|
|
{"resetexempts", "o|o", (Function) cmd_resetexempts, NULL, LEAF|AUTH},
|
|
{"resetexempts", "o|o", (Function) cmd_resetexempts, NULL, LEAF|AUTH},
|