mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Add luaC2SendMsg
This commit is contained in:
parent
714f961f59
commit
82593a585b
1 changed files with 21 additions and 0 deletions
|
@ -217,11 +217,32 @@ int luaC2RegisterCommand(lua_State *L)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
int luaC2SendMsg(lua_State *L)
|
||||||
|
{
|
||||||
|
const char *channel = luaL_optstring(L, 1, NULL);
|
||||||
|
const char *text = luaL_optstring(L, 2, NULL);
|
||||||
|
lua_pop(L, 2);
|
||||||
|
|
||||||
|
const auto chn = getApp()->twitch->getChannelOrEmpty(channel);
|
||||||
|
if (chn->isEmpty())
|
||||||
|
{
|
||||||
|
qCDebug(chatterinoLua) << "send_msg: no channel" << channel;
|
||||||
|
lua_pushboolean(L, C_FALSE);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
QString message = text;
|
||||||
|
message = message.replace('\n', ' ');
|
||||||
|
QString outText = getApp()->commands->execCommand(message, chn, false);
|
||||||
|
chn->sendMessage(outText);
|
||||||
|
lua_pushboolean(L, C_TRUE);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// NOLINTNEXTLINE
|
// NOLINTNEXTLINE
|
||||||
static const luaL_Reg C2LIB[] = {
|
static const luaL_Reg C2LIB[] = {
|
||||||
{"system_msg", luaC2SystemMsg},
|
{"system_msg", luaC2SystemMsg},
|
||||||
{"register_command", luaC2RegisterCommand},
|
{"register_command", luaC2RegisterCommand},
|
||||||
|
{"send_msg", luaC2SendMsg},
|
||||||
{nullptr, nullptr},
|
{nullptr, nullptr},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue