MyChat Scripts: function mGetConfUsersList, get the list of users in a conference
Get the list of users in the specified conference, who are currently connected to the server (online).
Syntax
function mGetConfUsersList(const iUID: integer): string;
Parameters and return values
Parameter |
Type |
Value |
iUID |
integer |
conference numeric ID (UID). |
Function result
A list of users UINs divided by commas. If UID specified incorrectly or the conference does not exist an empty string returns.
Example
The script on the event OnConfMessage that works only in the conference "main", and triggered on the command "!spin".
// ---------------------------------------
// Script created by Alexey Pikurov (support@nsoft-s.com)
// 13.01.2021 15:03:15
// ---------------------------------------
const
CONF_NAME = 'main';
ACTIONS_COUNT = 18;
ACTION_TEXT = 'hug|smoke with|dance with|smile to|spank|do everything with|tell a joke to|make a gift for|kiss|' +
'smooch|punch|pinch|buy drinks for|give $100 to|' +
'lick|scratch|ignore|wink to|give flowers to|';
function GetSpin(iUID, iUIN: integer): boolean;
var
sUsersList, sUser1, sUser2, sMsg, sWhat, sData: string;
UsersList: array of integer;
iCount, iUserUIN, iWhat, i: integer;
begin
sUsersList := mGetConfUsersList(iUID);
SetArrayLength(UsersList, 0);
iCount := 0;
while length(sUsersList) > 0 do begin
iUserUIN := StrToIntDef(Fetch(sUsersList, ','), -1);
if (iUserUIN <> -1) and (iUserUIN <> iUIN) then begin
inc(iCount);
SetArrayLength(UsersList, iCount);
UsersList[iCount - 1] := iUserUIN;
end;
end;
sUser1 := mGetUserAttribute(iUIN, 'DisplayName');
if iCount = 0 then begin
mSendConfMessage(iUID, 0, sUser1 + ', no people for playing the bottle :)', 1);
result := false;
end else begin
iUserUIN := UsersList[Random(iCount)];
sUser2 := mGetUserAttribute(iUserUIN, 'DisplayName');
mSendConfMessage(iUID, iUIN, '!spin', 1);
mSendConfMessage(iUID, 0, sUser1 + ' is spinning the bottle...', 1);
mSendConfMessage(iUID, 0, 'It is spinning... spinning... stoping... and pointing on...', 1);
mSendConfMessage(iUID, 0, 'On... on... So, the bottle pointed on — ' + sUser2, 1);
iWhat := Random(ACTIONS_COUNT) + 1;
sData := ACTION_TEXT;
for i := 1 to iWhat do sWhat := Fetch(sData, '|');
mSendConfMessage(iUID, 0, 'And now, ' + sUser1 + ', you need to ' + sWhat + ' ' + sUser2, 1);
result := true;
end;
end;
function OnConfMessage(iCID, iUIN, iUID, iMsgType: integer; sConfName, sMsg: string): boolean;
var
sOutMsg: string;
begin
if (mGetConfNameByUID(iUID) = CONF_NAME) and (LowerCase(sMsg) = '!spin') then begin
GetSpin(iUID, iUIN);
result := false;
end else result := true;
end;
begin
end.
Script work result
Alexander
!spin
Elisa
Alexander is spinning the bottle...
It is spinning... spinning... stopping... and pointing on...
On... on... So, the bottle pointed on Helen
And now, Alexander, you need to hug Helen