Skip to content

Commit

Permalink
new command get group members
Browse files Browse the repository at this point in the history
  • Loading branch information
Madpeterz committed Oct 23, 2020
1 parent 96d4d10 commit 4735697
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions Core/Commands/Group/getGroupMembers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;

namespace BSB.Commands.Group
{
public class GetGroupMembers : CoreCommand_2arg
{
public override string[] ArgTypes { get { return new[] { "UUID", "Mixed" }; } }
public override string[] ArgHints { get { return new[] { "Group", "Smart reply [Channel|IM uuid|http url]" }; } }
public override string Helpfile { get { return "Gets membership of a group plus online status "; } }
public override bool CallFunction(string[] args)
{
if (base.CallFunction(args) == true)
{
if (UUID.TryParse(args[0], out UUID targetgroup) == true)
{
if (bot.MyGroups.ContainsKey(targetgroup) == true)
{
if (bot.CreateAwaitEventReply("groupmembersreply", this, args) == true)
{
bot.GetClient.Groups.RequestGroupMembers(targetgroup);
InfoBlob = "Requesting group membership";
return true;
}
else
{
return Failed("Unable to await reply");
}

}
else
{
return Failed("Unknown group");
}
}
else
{
return Failed("Invaild UUID");
}
}
return false;
}

public override void Callback(string[] args, EventArgs e)
{
GroupMembersReplyEventArgs members_reply = (GroupMembersReplyEventArgs)e;
Dictionary<string, string> collection = new Dictionary<string, string>();
foreach (KeyValuePair<UUID, GroupMember> data in members_reply.Members)
{
collection.Add(data.Key.ToString(), data.Value.OnlineStatus);
}
bot.GetCommandsInterface.SmartCommandReply(true, args[1], "group=" + args[0], CommandName, collection);
base.Callback(args, e);
}
}
}

0 comments on commit 4735697

Please sign in to comment.