Group chat listener
From SmartBots Developers Docs
This example demonstrates how to reply to each IM which appears on group chat:
//////////////////////////////////////////////////////////////////////
// SmartBots AdminBot for Groups, https://www.mysmartbots.com
// Documentation and help: https://www.mysmartbots.com/dev/docs/AdminBot_for_LSL
//////////////////////////////////////////////////////////////////////
string SB_VERSION="2.0";
// Setup and startup
integer SB_SETUP_SETGROUP=180101;
integer SB_SETUP_SETGROUPUUID=180102;
integer SB_SETUP_DEBUG=180103;
integer SB_STATUS_QUERY=180104;
integer SB_SETUP_DEVICENAME=180111;
integer SB_SETUP_BOTNAME=180112;
integer SB_SETUP_SETOPTIONS=180113;
// Group members control
integer SB_INVITE_SEND=180105;
integer SB_GROUP_EJECT=180107;
integer SB_AVATAR_GROUP=180114;
integer SB_ADJUST_GROUP_ROLE=180120;
integer SB_GET_GROUP_ROLES=180121;
// Group chat
integer SB_CHAT_SAY=180106;
integer SB_CHAT_LISTEN=180108;
integer SB_CHAT_MUTE=180115;
// Notices
integer SB_NOTICE_SEND=180109;
// Misc. commands
integer SB_RESET_ADMINBOT=9996660;
integer SB_SETUP_SETLINK=180110;
// EVENTS
integer SB_COMMAND_FAILED=180201;
integer SB_STATUS_REPLY=180202;
integer SB_CHAT_MESSAGE=180203;
integer SB_SETUP_SUCCESS=180204;
integer SB_SETUP_FAILED=180205;
integer SB_CHAT_SUCCESS=180206;
integer SB_GROUP_CHECKED=180207;
default
{
state_entry() {
llMessageLinked(LINK_SET,SB_SETUP_SETGROUP,"Your group name","SECURITY CODE");
}
// This event parses different replies from AdminBot
link_message(integer sender,integer cmd, string data, key id) {
/////////////////// Group setup failed
if(cmd==SB_COMMAND_FAILED) {
list parts=llParseString2List(data,["\n"],[]);
string status=llList2String(parts,0);
string expires=llList2String(parts,1);
llOwnerSay("AdminBot command failed, error code: "+status);
}
/////////////////// Group setup failed
if(cmd==SB_SETUP_FAILED) {
list parts=llParseString2List(data,["\n"],[]);
string status=llList2String(parts,0);
string expires=llList2String(parts,1);
llOwnerSay("AdminBot group setup failed:\n"+
"status: "+status+"\n"+
"expired: "+expires);
}
/////////////////// Group successfully set
if(cmd==SB_SETUP_SUCCESS) {
llOwnerSay("AdminBot group successfully set, asking to the listen group chat");
// Start listening to a group chat
llMessageLinked(LINK_SET,SB_CHAT_LISTEN,"1",NULL_KEY);
// Say something over group chat
llMessageLinked(LINK_SET,SB_CHAT_SAY,"I'm listening on group chat, please talk to me!",NULL_KEY);
}
/////////////////// Group chat message
if(cmd==SB_CHAT_MESSAGE) {
llOwnerSay("We've got the group chat message: "+data);
llMessageLinked(LINK_SET,SB_CHAT_SAY,"Magic box replies to you, master!",NULL_KEY);
}
}
}