-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |