From de5f0cf173df8a285f5e4f7fc0b3cd8a6f334453 Mon Sep 17 00:00:00 2001
From: Madpeterz <57852827+Madpeterz@users.noreply.github.com>
Date: Wed, 17 Feb 2021 05:03:50 +0000
Subject: [PATCH] the old core is dying :( http is better thou :)
---
BetterSecondbot/HttpService/Avatars.cs | 33 +-
BetterSecondbot/HttpService/Core.cs | 118 +---
BetterSecondbot/HttpService/Discord.cs | 626 +++++++++++++++++-
BetterSecondbot/HttpService/Estate.cs | 176 ++++-
BetterSecondbot/HttpService/Friends.cs | 114 ++++
BetterSecondbot/HttpService/Funds.cs | 112 ++++
BetterSecondbot/HttpService/Group.cs | 571 +++++++++++++---
BetterSecondbot/HttpService/Home.cs | 33 +
BetterSecondbot/HttpService/HttpAsService.cs | 9 +-
BetterSecondbot/HttpService/Info.cs | 116 ++++
BetterSecondbot/HttpService/Self.cs | 131 ++++
.../Commands/DiscordAPI/BulkClear_Messages.cs | 75 ---
Core/Commands/DiscordAPI/Dm_Member.cs | 65 --
Core/Commands/DiscordAPI/MembersList.cs | 58 --
Core/Commands/DiscordAPI/MessageChannel.cs | 43 --
Core/Commands/DiscordAPI/MuteMember.cs | 57 --
Core/Commands/DiscordAPI/RoleCreate.cs | 47 --
Core/Commands/DiscordAPI/RoleList.cs | 49 --
Core/Commands/DiscordAPI/RoleRemove.cs | 49 --
Core/Commands/DiscordAPI/Role_GetSettings.cs | 84 ---
Core/Commands/DiscordAPI/Role_UpdatePerms.cs | 165 -----
Core/Commands/DiscordAPI/TextChannels_List.cs | 49 --
Core/Commands/Estate/EstateParcelReclaim.cs | 25 -
Core/Commands/Estate/GetSimGlobalPos.cs | 27 -
Core/Commands/Estate/GetSimTexture.cs | 25 -
Core/Commands/Estate/SimMessage.cs | 26 -
Core/Commands/Estate/SimRestart.cs | 45 --
Core/Commands/Friends/FriendFullPerms.cs | 42 --
Core/Commands/Friends/FriendRequest.cs | 28 -
Core/Commands/Friends/Friendslist.cs | 18 -
Core/Commands/Group/GroupActiveGroup.cs | 38 --
Core/Commands/Group/GroupActiveTitle.cs | 31 -
Core/Commands/Group/GroupAddRole.cs | 108 ---
Core/Commands/Group/GroupEject.cs | 45 --
Core/Commands/Group/GroupInvite.cs | 65 --
Core/Commands/Group/GroupInviteNoLimiter.cs | 58 --
Core/Commands/Group/GroupNotice.cs | 53 --
Core/Commands/Group/IsGroupMember.cs | 92 ---
Core/Commands/Group/getGroupList.cs | 20 -
Core/Commands/Group/getGroupMembers.cs | 58 --
Core/Commands/Group/getGroupRoles.cs | 50 --
Core/Commands/Group/group.cs | 58 --
Core/Commands/Group/groupchat.cs | 62 --
Core/Commands/Group/groupchatAnyUnread.cs | 11 -
Core/Commands/Group/groupchatClearAll.cs | 16 -
.../Commands/Group/groupchatGroupHasUnread.cs | 15 -
Core/Commands/Group/groupchatHistory.cs | 22 -
.../Group/groupchatListAllUnreadGroups.cs | 21 -
Core/Commands/Home/GoHome.cs | 16 -
Core/Commands/Home/resetAtHome.cs | 16 -
Core/Commands/Info/Balance.cs | 21 -
Core/Commands/Info/GetPosition.cs | 15 -
Core/Commands/Info/ParcelName.cs | 16 -
Core/Commands/Info/SimName.cs | 15 -
Core/Commands/Info/UnixTimeNow.cs | 17 -
Core/Commands/Self/CickObject.cs | 49 --
Core/Commands/Self/Help.cs | 74 ---
Core/Commands/Self/PayObject.cs | 45 --
Core/Commands/Self/botVersion.cs | 15 -
Core/Commands/Self/logout.cs | 3 +-
Core/Commands/Self/pointAt.cs | 40 --
Core/Commands/Self/sit.cs | 37 --
Core/Commands/Self/stand.cs | 13 -
Core/bottypes/EventsBot.cs | 9 +
64 files changed, 1769 insertions(+), 2471 deletions(-)
create mode 100644 BetterSecondbot/HttpService/Friends.cs
create mode 100644 BetterSecondbot/HttpService/Funds.cs
create mode 100644 BetterSecondbot/HttpService/Home.cs
create mode 100644 BetterSecondbot/HttpService/Info.cs
create mode 100644 BetterSecondbot/HttpService/Self.cs
delete mode 100644 Core/Commands/DiscordAPI/BulkClear_Messages.cs
delete mode 100644 Core/Commands/DiscordAPI/Dm_Member.cs
delete mode 100644 Core/Commands/DiscordAPI/MembersList.cs
delete mode 100644 Core/Commands/DiscordAPI/MessageChannel.cs
delete mode 100644 Core/Commands/DiscordAPI/MuteMember.cs
delete mode 100644 Core/Commands/DiscordAPI/RoleCreate.cs
delete mode 100644 Core/Commands/DiscordAPI/RoleList.cs
delete mode 100644 Core/Commands/DiscordAPI/RoleRemove.cs
delete mode 100644 Core/Commands/DiscordAPI/Role_GetSettings.cs
delete mode 100644 Core/Commands/DiscordAPI/Role_UpdatePerms.cs
delete mode 100644 Core/Commands/DiscordAPI/TextChannels_List.cs
delete mode 100644 Core/Commands/Estate/EstateParcelReclaim.cs
delete mode 100644 Core/Commands/Estate/GetSimGlobalPos.cs
delete mode 100644 Core/Commands/Estate/GetSimTexture.cs
delete mode 100644 Core/Commands/Estate/SimMessage.cs
delete mode 100644 Core/Commands/Estate/SimRestart.cs
delete mode 100644 Core/Commands/Friends/FriendFullPerms.cs
delete mode 100644 Core/Commands/Friends/FriendRequest.cs
delete mode 100644 Core/Commands/Friends/Friendslist.cs
delete mode 100644 Core/Commands/Group/GroupActiveGroup.cs
delete mode 100644 Core/Commands/Group/GroupActiveTitle.cs
delete mode 100644 Core/Commands/Group/GroupAddRole.cs
delete mode 100644 Core/Commands/Group/GroupEject.cs
delete mode 100644 Core/Commands/Group/GroupInvite.cs
delete mode 100644 Core/Commands/Group/GroupInviteNoLimiter.cs
delete mode 100644 Core/Commands/Group/GroupNotice.cs
delete mode 100644 Core/Commands/Group/IsGroupMember.cs
delete mode 100644 Core/Commands/Group/getGroupList.cs
delete mode 100644 Core/Commands/Group/getGroupMembers.cs
delete mode 100644 Core/Commands/Group/getGroupRoles.cs
delete mode 100644 Core/Commands/Group/group.cs
delete mode 100644 Core/Commands/Group/groupchat.cs
delete mode 100644 Core/Commands/Group/groupchatAnyUnread.cs
delete mode 100644 Core/Commands/Group/groupchatClearAll.cs
delete mode 100644 Core/Commands/Group/groupchatGroupHasUnread.cs
delete mode 100644 Core/Commands/Group/groupchatHistory.cs
delete mode 100644 Core/Commands/Group/groupchatListAllUnreadGroups.cs
delete mode 100644 Core/Commands/Home/GoHome.cs
delete mode 100644 Core/Commands/Home/resetAtHome.cs
delete mode 100644 Core/Commands/Info/Balance.cs
delete mode 100644 Core/Commands/Info/GetPosition.cs
delete mode 100644 Core/Commands/Info/ParcelName.cs
delete mode 100644 Core/Commands/Info/SimName.cs
delete mode 100644 Core/Commands/Info/UnixTimeNow.cs
delete mode 100644 Core/Commands/Self/CickObject.cs
delete mode 100644 Core/Commands/Self/Help.cs
delete mode 100644 Core/Commands/Self/PayObject.cs
delete mode 100644 Core/Commands/Self/botVersion.cs
delete mode 100644 Core/Commands/Self/pointAt.cs
delete mode 100644 Core/Commands/Self/sit.cs
delete mode 100644 Core/Commands/Self/stand.cs
diff --git a/BetterSecondbot/HttpService/Avatars.cs b/BetterSecondbot/HttpService/Avatars.cs
index 62903dc..ecba2f6 100644
--- a/BetterSecondbot/HttpService/Avatars.cs
+++ b/BetterSecondbot/HttpService/Avatars.cs
@@ -76,37 +76,6 @@ namespace BetterSecondBot.HttpService
}
- [About("Makes the bot pay a avatar")]
- [ReturnHints("Accepted")]
- [ReturnHints("avatar lookup")]
- [ReturnHints("Invaild amount")]
- [ReturnHints("Transfer funds to avatars disabled")]
- [Route(HttpVerbs.Get, "/PayAvatar/{avatar}/{amount}/{token}")]
- public object PayAvatar(string avatar,string amount,string token)
- {
- if (tokens.Allow(token, "avatars", "payavatar", getClientIP()) == false)
- {
- return BasicReply("Token not accepted");
- }
- if (bot.GetAllowFunds == false)
- {
- return BasicReply("Transfer funds to avatars disabled");
- }
- ProcessAvatar(avatar);
- if (avataruuid == UUID.Zero)
- {
- return BasicReply("avatar lookup");
- }
- if (int.TryParse(amount, out int amountvalue) == false)
- {
- return BasicReply("Invaild amount");
- }
- if(amountvalue < 1)
- {
- return BasicReply("Invaild amount");
- }
- bot.GetClient.Self.GiveAvatarMoney(avataruuid, amountvalue);
- return BasicReply("Accepted");
- }
+
}
}
diff --git a/BetterSecondbot/HttpService/Core.cs b/BetterSecondbot/HttpService/Core.cs
index 3defd91..4b08816 100644
--- a/BetterSecondbot/HttpService/Core.cs
+++ b/BetterSecondbot/HttpService/Core.cs
@@ -47,21 +47,11 @@ namespace BetterSecondBot.HttpService
if(newtoken != null) return BasicReply(newtoken);
}
}
- return BasicReply("Authcode not accepted");
+ return Failure("Authcode not accepted");
}
- [About("Gets the friendslist
Formated as follows
friendreplyobject
- name: String
- id: String
- online: bool
")]
- [ReturnHints("array UUID = friendreplyobject")]
- [Route(HttpVerbs.Get, "/Friends/{token}")]
- public object Friends(string token)
- {
- if (tokens.Allow(token, "core", "friends", getClientIP()) == true)
- {
- return BasicReply(bot.getJsonFriendlist());
- }
- return BasicReply("Token not accepted");
- }
+
[About("uses the AutoPilot to move to a location")]
[ReturnHints("Error Unable to AutoPilot to location")]
@@ -79,9 +69,9 @@ namespace BetterSecondBot.HttpService
{
return BasicReply("Accepted");
}
- return BasicReply("Error Unable to AutoPilot to location");
+ return Failure("Error Unable to AutoPilot to location");
}
- return BasicReply("Token not accepted");
+ return Failure("Token not accepted");
}
@@ -103,33 +93,11 @@ namespace BetterSecondBot.HttpService
{
return BasicReply("Accepted");
}
- return BasicReply("Error Unable to Teleport to location");
+ return Failure("Error Unable to Teleport to location");
}
- return BasicReply("Token not accepted");
+ return Failure("Token not accepted");
}
- [About("Fetchs the regions map tile")]
- [ReturnHints("Unable to find region")]
- [ReturnHints("Texture UUID")]
- [ArgHints("regionname", "URLARG", "the name of the region we are fetching")]
- [Route(HttpVerbs.Get, "/Regiontile/{regionname}/{token}")]
- public object Regiontile(string regionname, string token)
- {
- if (tokens.Allow(token, "core", "regiontile", getClientIP()) == true)
- {
- if (bot.GetClient.Grid.GetGridRegion(regionname, GridLayerType.Objects, out GridRegion region))
- {
- return BasicReply(region.MapImageID.ToString());
- }
- else
- {
- return BasicReply("Unable to find region");
- }
- }
- return BasicReply("Token not accepted");
- }
-
-
[About("Used to check HTTP connections")]
[ReturnHints("world")]
@@ -144,79 +112,19 @@ namespace BetterSecondBot.HttpService
[About("Removes the given token from the accepted token pool")]
[ReturnHints("Failed to remove token")]
[ReturnHints("ok")]
- [Route(HttpVerbs.Get, "/Logout/{token}")]
- public object Logout(string token)
+ [Route(HttpVerbs.Get, "/LogoutUI/{token}")]
+ public object LogoutUI(string token)
{
- if (tokens.Allow(token, "core", "logout", getClientIP()) == true)
+ if (tokens.Allow(token, "core", "LogoutUI", getClientIP()) == true)
{
return tokens.Expire(token);
}
- return BasicReply("Token not accepted");
+ return Failure("Token not accepted");
}
- [About("Fetchs the current bot")]
- [ReturnHints("The build ID of the bot")]
- [Route(HttpVerbs.Get, "/Version/{token}")]
- public object Version(string token)
- {
- if (tokens.Allow(token, "core", "version", getClientIP()) == true)
- {
- return BasicReply(bot.MyVersion);
- }
- return BasicReply("Token not accepted");
- }
- [About("Fetchs the name of the bot")]
- [ReturnHints("Firstname Lastname")]
- [Route(HttpVerbs.Get, "/Name/{token}")]
- public object Name(string token)
- {
- if (tokens.Allow(token, "core", "name", getClientIP()) == true)
- {
- return BasicReply(bot.GetClient.Self.FirstName + " " + bot.GetClient.Self.LastName);
- }
- return BasicReply("Token not accepted");
- }
-
- [About("Fetchs the current region name")]
- [ReturnHints("Regionname")]
- [ReturnHints("Error not in a sim")]
- [Route(HttpVerbs.Get, "/Regionname/{token}")]
- public object Regionname(string token)
- {
- if (tokens.Allow(token, "core", "regionname", getClientIP()) == true)
- {
- if(bot.GetClient.Network.CurrentSim != null)
- {
- return BasicReply(bot.GetClient.Network.CurrentSim.Name);
- }
- return BasicReply("Error not in a sim");
- }
- return BasicReply("Token not accepted");
- }
-
- [About("Fetchs the current location of the bot")]
- [ReturnHints("array of X,Y,Z values")]
- [ReturnHints("Error not in a sim")]
- [Route(HttpVerbs.Get, "/Location/{token}")]
- public object Location(string token)
- {
- if (tokens.Allow(token, "core", "location", getClientIP()) == true)
- {
- if (bot.GetClient.Network.CurrentSim != null)
- {
- Dictionary pos = new Dictionary();
- pos.Add("x", (int)Math.Round(bot.GetClient.Self.SimPosition.X));
- pos.Add("y", (int)Math.Round(bot.GetClient.Self.SimPosition.Y));
- pos.Add("z", (int)Math.Round(bot.GetClient.Self.SimPosition.Z));
- return BasicReply(JsonConvert.SerializeObject(pos));
- }
- return BasicReply("Error not in a sim");
- }
- return BasicReply("Token not accepted");
- }
[About("Makes a request to the core commands lib
See LSL example on how to create a core command auth code")]
@@ -240,11 +148,11 @@ namespace BetterSecondBot.HttpService
{
return BasicReply("accepted");
}
- return BasicReply("Failed");
+ return Failure("Failed");
}
- return BasicReply("Auth not accepted");
+ return Failure("Auth not accepted");
}
- return BasicReply("Token not accepted");
+ return Failure("Token not accepted");
}
}
diff --git a/BetterSecondbot/HttpService/Discord.cs b/BetterSecondbot/HttpService/Discord.cs
index 598a42b..da52785 100644
--- a/BetterSecondbot/HttpService/Discord.cs
+++ b/BetterSecondbot/HttpService/Discord.cs
@@ -12,6 +12,8 @@ using System.Reflection;
using Discord.WebSocket;
using System.Threading.Tasks;
using Discord;
+using BetterSecondBotShared.Static;
+using Discord.Rest;
namespace BetterSecondBot.HttpService
{
@@ -21,8 +23,7 @@ namespace BetterSecondBot.HttpService
[About("Adds a discord server role to the selected member")]
[ReturnHints("Discord client not ready")]
- [ReturnHints("true")]
- [ReturnHints("false")]
+ [ReturnHints("true|false")]
[ArgHints("serverid","URLARG","the server id to apply this action to")]
[ArgHints("roleid", "URLARG", "the role id we are giving")]
[ArgHints("memberid", "URLARG", "who we are giving it to")]
@@ -31,36 +32,640 @@ namespace BetterSecondBot.HttpService
{
if (tokens.Allow(token, "discord", "Discord_AddRole", getClientIP()) == false)
{
- return BasicReply("Token not accepted");
+ return Failure("Token not accepted");
}
if (bot.discordReady() == false)
{
- return BasicReply("Discord client not ready");
+ return Failure("Discord client not ready");
}
return BasicReply(addRoleToMember(serverid, roleid, memberid).Result.ToString());
}
[About("Adds the selected user to the ban list - Disallows rejoining untill they are removed from the list")]
[ReturnHints("Discord client not ready")]
- [ReturnHints("true")]
- [ReturnHints("false")]
+ [ReturnHints("Why empty")]
+ [ReturnHints("true|false")]
[ArgHints("serverid", "URLARG", "the server id to apply this action to")]
[ArgHints("memberid", "URLARG", "who we are giving it to")]
[ArgHints("why", "string", "why they are being banned")]
- [Route(HttpVerbs.Get, "/Discord_BanMember/{serverid}/{memberid}/{token}")]
+ [Route(HttpVerbs.Post, "/Discord_BanMember/{serverid}/{memberid}/{token}")]
public object Discord_BanMember(string serverid, string memberid, [FormField] string why, string token)
{
if (tokens.Allow(token, "discord", "Discord_BanMember", getClientIP()) == false)
{
- return BasicReply("Token not accepted");
+ return Failure("Token not accepted");
}
if (bot.discordReady() == false)
{
- return BasicReply("Discord client not ready");
+ return Failure("Discord client not ready");
+ }
+ if (helpers.notempty(why) == false)
+ {
+ return Failure("Why empty");
}
return BasicReply(BanMember(serverid, memberid, why).Result.ToString());
}
+ [About("Clears messages on the server sent by the member in the last 13 days, 22hours 59mins")]
+ [ReturnHints("Discord client not ready")]
+ [ReturnHints("true|false")]
+ [ArgHints("serverid", "URLARG", "the server id to apply this action to")]
+ [ArgHints("memberid", "URLARG", "who we are giving it to")]
+ [Route(HttpVerbs.Get, "/Discord_BulkClear_Messages/{serverid}/{memberid}/{token}")]
+ public object Discord_BulkClear_Messages(string serverid, string memberid, string token)
+ {
+ if (tokens.Allow(token, "discord", "Discord_BulkClear_Messages", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.discordReady() == false)
+ {
+ return Failure("Discord client not ready");
+ }
+ return ClearMessages(serverid, memberid).Result;
+ }
+
+ [About("Sends a message directly to the user [They must be in the server]\n This command requires the SERVER MEMBERS INTENT found in discord app dev")]
+ [ReturnHints("Discord client not ready")]
+ [ReturnHints("true|false")]
+ [ArgHints("serverid", "URLARG", "the server id to apply this action to")]
+ [ArgHints("memberid", "URLARG", "who we are giving it to")]
+ [ArgHints("message", "Text", "what we are sending")]
+ [Route(HttpVerbs.Post, "/Discord_Dm_Member/{serverid}/{memberid}/{token}")]
+ public object Discord_Dm_Member(string serverid, string memberid, [FormField] string message, string token)
+ {
+ if (tokens.Allow(token, "discord", "Discord_Dm_Member", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.discordReady() == false)
+ {
+ return Failure("Discord client not ready");
+ }
+ return BasicReply(MessageMember(serverid, memberid, message).Result.ToString());
+ }
+
+ [About("Returns a list of members in a server \n collection is userid: username \n if the user has set a nickname: userid: nickname|username \n" +
+ " This command requires Discord full client mode enabled and connected\n !!!! This command also requires: Privileged Gateway Intents / " +
+ "SERVER MEMBERS INTENT set to true on the discord bot api area !!!")]
+ [ReturnHints("Discord client not ready")]
+ [ReturnHints("mixed array of userid: nickname|username or userid:username")]
+ [ArgHints("serverid", "URLARG", "the server id to apply this action to")]
+ [Route(HttpVerbs.Get, "/Discord_MembersList/{serverid}/{token}")]
+ public object Discord_MembersList(string serverid, string token)
+ {
+ if (tokens.Allow(token, "discord", "Discord_MembersList", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.discordReady() == false)
+ {
+ return Failure("Discord client not ready");
+ }
+ return ListMembers(serverid).Result;
+ }
+
+ [About("Sends a message to the selected channel - Optional TTS usage")]
+ [ReturnHints("Discord client not ready")]
+ [ReturnHints("true|false")]
+ [ArgHints("serverid", "URLARG", "the server id to apply this action to")]
+ [ArgHints("channelid", "URLARG", "the channel id to apply this action to")]
+ [ArgHints("tts", "URLARG", "shoud tts be enabled true or false")]
+ [ArgHints("message", "Text", "what we are sending")]
+ [Route(HttpVerbs.Post, "/Discord_MembersList/{serverid}/{tts}/{token}")]
+ public object Discord_MessageChannel(string serverid, string channelid, string tts, [FormField] string message, string token)
+ {
+ if (tokens.Allow(token, "discord", "Discord_MessageChannel", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.discordReady() == false)
+ {
+ return Failure("Discord client not ready");
+ }
+ if (helpers.notempty(message) == false)
+ {
+ return Failure("message empty");
+ }
+ return BasicReply(MessageChannel(serverid, channelid, message, tts).Result.ToString());
+ }
+
+ [About("Sends a message to the selected channel - Optional TTS usage")]
+ [ReturnHints("mixed array of userid: nickname|username or userid:username")]
+ [ReturnHints("Discord client not ready")]
+ [ArgHints("serverid", "URLARG", "the server id to apply this action to")]
+ [ArgHints("memberid", "URLARG", "who we are giving it to")]
+ [ArgHints("mode", "URLARG", "should we mute them \"true\" or unmute \"false\"")]
+ [Route(HttpVerbs.Get, "/Discord_MuteMember/{serverid}/{memberid}/{mode}/{token}")]
+ public object Discord_MuteMember(string serverid, string memberid, string mode, string token)
+ {
+ if (tokens.Allow(token, "discord", "Discord_MuteMember", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.discordReady() == false)
+ {
+ return Failure("Discord client not ready");
+ }
+ return BasicReply(MuteMember(serverid, memberid, mode).Result.ToString());
+ }
+
+ [About("returns a collection of settings for the given role \n This command requires Discord full client mode enabled and connected")]
+ [ReturnHints("KeyPair of status: KeyPair[] item = value")]
+ [ReturnHints("Discord client not ready")]
+ [ArgHints("serverid", "URLARG", "the server id to apply this action to")]
+ [ArgHints("memberid", "URLARG", "who we are giving it to")]
+ [ArgHints("mode", "URLARG", "should we mute them \"true\" or unmute \"false\"")]
+ [Route(HttpVerbs.Get, "/Discord_Role_GetSettings/{serverid}/{roleid}/{token}")]
+ public object Discord_Role_GetSettings(string serverid, string roleid, string token)
+ {
+ if (tokens.Allow(token, "discord", "Discord_Role_GetSettings", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.discordReady() == false)
+ {
+ return Failure("Discord client not ready");
+ }
+ return RoleSettings(serverid,roleid);
+ }
+
+ [About("Updates perm flags for the selected role \n example CSV format: Speak=True,SendMessages=False \n for a full list of perms see output of Discord_Role_GetSettings \n" +
+ " This command requires Discord full client mode enabled and connected")]
+ [ReturnHints("true|false")]
+ [ReturnHints("Discord client not ready")]
+ [ArgHints("serverid", "URLARG", "the server id to apply this action to")]
+ [ArgHints("roleid", "URLARG", "who we are giving it to")]
+ [ArgHints("flagscsv", "Text", "what we are setting")]
+ [Route(HttpVerbs.Post, "/Discord_Role_UpdatePerms/{serverid}/{roleid}/{token}")]
+ public object Discord_Role_UpdatePerms(string serverid, string roleid, [FormField] string flagscsv, string token)
+ {
+ if (tokens.Allow(token, "discord", "Discord_Role_UpdatePerms", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.discordReady() == false)
+ {
+ return Failure("Discord client not ready");
+ }
+ return BasicReply(UpdateRolePerms(serverid, roleid, flagscsv).Result.ToString());
+ }
+
+ [About("Updates perm flags for the selected role \n example CSV format: Speak=True,SendMessages=False \n for a full list of perms see output of Discord_Role_GetSettings \n" +
+ " This command requires Discord full client mode enabled and connected")]
+ [ReturnHints("KeyPair of statusmessage=roleid or 0")]
+ [ReturnHints("Discord client not ready")]
+ [ArgHints("serverid", "URLARG", "the server id to apply this action to")]
+ [ArgHints("role", "URLARG", "the name of the role we are creating")]
+ [Route(HttpVerbs.Get, "/Discord_RoleCreate/{serverid}/{role}/{token}")]
+ public object Discord_RoleCreate(string serverid, string role, string token)
+ {
+ if (tokens.Allow(token, "discord", "Discord_RoleCreate", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.discordReady() == false)
+ {
+ return Failure("Discord client not ready");
+ }
+ return CreateRole(serverid,role).Result;
+ }
+
+ [About("Returns a list of roles and their ids in collection \n This command requires Discord full client mode enabled and connected")]
+ [ReturnHints("KeyPair of status: KeyPair of roleid: rolename")]
+ [ReturnHints("Discord client not ready")]
+ [ArgHints("serverid", "URLARG", "the server id to apply this action to")]
+ [Route(HttpVerbs.Get, "/Discord_RoleList/{serverid}/{token}")]
+ public object Discord_RoleList(string serverid, string token)
+ {
+ if (tokens.Allow(token, "discord", "Discord_RoleList", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.discordReady() == false)
+ {
+ return Failure("Discord client not ready");
+ }
+ return BasicReply(ListRoles(serverid).ToString());
+ }
+
+ [About("Remove a role from a server \n This command requires Discord full client mode enabled and connected")]
+ [ReturnHints("true|false")]
+ [ReturnHints("Discord client not ready")]
+ [ArgHints("serverid", "URLARG", "the server id to apply this action to")]
+ [Route(HttpVerbs.Get, "/Discord_RoleRemove/{serverid}/{roleid}/{token}")]
+ public object Discord_RoleRemove(string serverid, string roleid, string token)
+ {
+ if (tokens.Allow(token, "discord", "Discord_RoleRemove", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.discordReady() == false)
+ {
+ return Failure("Discord client not ready");
+ }
+ return BasicReply(RemoveRole(serverid, roleid).Result.ToString());
+ }
+
+ [About("Returns a list of text channels in a server")]
+ [ReturnHints("array of channelid: name")]
+ [ReturnHints("Discord client not ready")]
+ [ArgHints("serverid", "URLARG", "the server id to apply this action to")]
+ [Route(HttpVerbs.Get, "/Discord_TextChannels_List/{serverid}/{roleid}/{token}")]
+ public object Discord_TextChannels_List(string serverid, string token)
+ {
+ if (tokens.Allow(token, "discord", "Discord_TextChannels_List", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.discordReady() == false)
+ {
+ return Failure("Discord client not ready");
+ }
+ return ListTextChannels(serverid);
+ }
+
+
+ #region discord helper functions
+
+ protected KeyValuePair> ListTextChannels(string givenserverid)
+ {
+ DiscordSocketClient Discord = bot.getDiscordClient();
+ if (ulong.TryParse(givenserverid, out ulong serverid) == true)
+ {
+ return new KeyValuePair>(false, new Dictionary());
+ }
+ SocketGuild server = Discord.GetGuild(serverid);
+ Dictionary textChannels = new Dictionary();
+ foreach (SocketTextChannel channel in server.TextChannels)
+ {
+ textChannels.Add(channel.Id.ToString(), channel.Name);
+ }
+ return new KeyValuePair>(true, textChannels);
+ }
+
+ protected async Task RemoveRole(string givenserverid, string givenroleid)
+ {
+ DiscordSocketClient Discord = bot.getDiscordClient();
+ if (ulong.TryParse(givenserverid, out ulong serverid) == false)
+ {
+ return false;
+ }
+ if (ulong.TryParse(givenroleid, out ulong roleid) == false)
+ {
+ return false;
+ }
+ SocketGuild server = Discord.GetGuild(serverid);
+ SocketRole role = server.GetRole(roleid);
+ await role.DeleteAsync().ConfigureAwait(true);
+ return true;
+ }
+
+ protected KeyValuePair> ListRoles(string givenserverid)
+ {
+ DiscordSocketClient Discord = bot.getDiscordClient();
+ if (ulong.TryParse(givenserverid, out ulong serverid) == false)
+ {
+ return new KeyValuePair>(false, new Dictionary());
+ }
+ SocketGuild server = Discord.GetGuild(serverid);
+ Dictionary rolesList = new Dictionary();
+ foreach (SocketRole role in server.Roles)
+ {
+ rolesList.Add(role.Id.ToString(), role.Name);
+ }
+ return new KeyValuePair>(true, rolesList);
+ }
+
+ protected async Task> CreateRole(string givenserverid, string givenrole)
+ {
+ DiscordSocketClient Discord = bot.getDiscordClient();
+ if (ulong.TryParse(givenserverid, out ulong serverid) == true)
+ {
+ return new KeyValuePair("Unable to process server id", 0);
+ }
+ SocketGuild server = Discord.GetGuild(serverid);
+ RestRole role = await server.CreateRoleAsync(givenrole, new GuildPermissions(), Color.DarkRed, false, null).ConfigureAwait(true);
+ return new KeyValuePair("ok", role.Id);
+ }
+
+ protected async Task UpdateRolePerms(string givenserverid,string givenroleid,string givenflagscsv)
+ {
+ DiscordSocketClient Discord = bot.getDiscordClient();
+ if (ulong.TryParse(givenserverid, out ulong serverid) == false)
+ {
+ return false;
+ }
+ if (ulong.TryParse(givenroleid, out ulong roleid) == true)
+ {
+ return false;
+ }
+ SocketGuild server = Discord.GetGuild(serverid);
+ SocketRole role = server.GetRole(roleid);
+ string[] bits = givenflagscsv.Split(',');
+ GuildPermissions NewPerms = role.Permissions;
+ foreach (String bit in bits)
+ {
+ string[] subbits = bit.Split('=');
+ if (subbits.Length == 2)
+ {
+ if (bool.TryParse(subbits[1], out bool flagValue) == true)
+ {
+ NewPerms = UpdateFlag(NewPerms, subbits[0], flagValue);
+ }
+ }
+ }
+ await role.ModifyAsync(Rp =>
+ {
+ Rp.Permissions = NewPerms;
+ }).ConfigureAwait(true);
+ return true;
+ }
+
+ protected GuildPermissions UpdateFlag(GuildPermissions NewPerms, string flag, bool flagValue)
+ {
+ switch (flag)
+ {
+ case "CreateInstantInvite":
+ NewPerms = NewPerms.Modify(flagValue);
+ break;
+ case "KickMembers":
+ NewPerms = NewPerms.Modify(null, flagValue);
+ break;
+ case "BanMembers":
+ NewPerms = NewPerms.Modify(null, null, flagValue);
+ break;
+ case "Administrator":
+ NewPerms = NewPerms.Modify(null, null, null, flagValue);
+ break;
+ case "ManageChannels":
+ NewPerms = NewPerms.Modify(null, null, null, null, flagValue);
+ break;
+ case "ManageGuild":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, flagValue);
+ break;
+ case "AddReactions":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, flagValue);
+ break;
+ case "ViewAuditLog":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, flagValue);
+ break;
+ case "SendTTSMessages":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "AttachFiles":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "ReadMessageHistory":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "MentionEveryone":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "UseExternalEmojis":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "Connect":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "Speak":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "MuteMembers":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "UseVAD":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "MoveMembers":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "EmbedLinks":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "PrioritySpeaker":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "Stream":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "ChangeNickname":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "ManageNicknames":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "ManageRoles":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "DeafenMembers":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "ManageMessages":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "ViewChannel":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "SendMessages":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "ManageWebhooks":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ case "ManageEmojis":
+ NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
+ break;
+ default:
+ break;
+ }
+ return NewPerms;
+ }
+
+ protected KeyValuePair> RoleSettings(string givenserverid, string givenroleid)
+ {
+ DiscordSocketClient Discord = bot.getDiscordClient();
+ if (ulong.TryParse(givenserverid, out ulong serverid) == false)
+ {
+ return new KeyValuePair>(false, new Dictionary());
+ }
+ if (ulong.TryParse(givenroleid, out ulong roleid) == false)
+ {
+ return new KeyValuePair>(false, new Dictionary());
+ }
+ SocketGuild server = Discord.GetGuild(serverid);
+ SocketRole role = server.GetRole(roleid);
+ Dictionary settings = new Dictionary
+ {
+ { "Config|Color", String.Join(",", new byte[3] { role.Color.R, role.Color.G, role.Color.B }) },
+ { "Config|Name", role.Name },
+ { "Info|AssignedCount", role.Members.ToString() },
+ { "Perm|AttachFiles", role.Permissions.AttachFiles.ToString() },
+ { "Perm|ReadMessageHistory", role.Permissions.ReadMessageHistory.ToString() },
+ { "Perm|MentionEveryone", role.Permissions.MentionEveryone.ToString() },
+ { "Perm|UseExternalEmojis", role.Permissions.UseExternalEmojis.ToString() },
+ { "Perm|Connect", role.Permissions.Connect.ToString() },
+ { "Perm|Speak", role.Permissions.Speak.ToString() },
+ { "Perm|MuteMembers", role.Permissions.MuteMembers.ToString() },
+ { "Perm|UseVAD", role.Permissions.UseVAD.ToString() },
+ { "Perm|MoveMembers", role.Permissions.MoveMembers.ToString() },
+ { "Perm|EmbedLinks", role.Permissions.EmbedLinks.ToString() },
+ { "Perm|PrioritySpeaker", role.Permissions.PrioritySpeaker.ToString() },
+ { "Perm|Stream", role.Permissions.Stream.ToString() },
+ { "Perm|ChangeNickname", role.Permissions.ChangeNickname.ToString() },
+ { "Perm|ManageNicknames", role.Permissions.ManageNicknames.ToString() },
+ { "Perm|ManageRoles", role.Permissions.ManageRoles.ToString() },
+ { "Perm|DeafenMembers", role.Permissions.DeafenMembers.ToString() },
+ { "Perm|ManageMessages", role.Permissions.ManageMessages.ToString() },
+ { "Perm|ViewChannel", role.Permissions.ViewChannel.ToString() },
+ { "Perm|SendMessages", role.Permissions.SendMessages.ToString() },
+ { "Perm|CreateInstantInvite", role.Permissions.CreateInstantInvite.ToString() },
+ { "Perm|BanMembers", role.Permissions.BanMembers.ToString() },
+ { "Perm|SendTTSMessages", role.Permissions.SendTTSMessages.ToString() },
+ { "Perm|Administrator", role.Permissions.Administrator.ToString() },
+ { "Perm|ManageChannels", role.Permissions.ManageChannels.ToString() },
+ { "Perm|KickMembers", role.Permissions.KickMembers.ToString() },
+ { "Perm|AddReactions", role.Permissions.AddReactions.ToString() },
+ { "Perm|ViewAuditLog", role.Permissions.ViewAuditLog.ToString() },
+ { "Perm|ManageWebhooks", role.Permissions.ManageWebhooks.ToString() },
+ { "Perm|ManageGuild", role.Permissions.ManageGuild.ToString() },
+ { "Perm|ManageEmojis", role.Permissions.ManageEmojis.ToString() }
+ };
+ return new KeyValuePair>(true, settings);
+ }
+
+ protected async Task MuteMember(string givenserverid, string givenmemberid, string mode)
+ {
+ DiscordSocketClient Discord = bot.getDiscordClient();
+ if (ulong.TryParse(givenserverid, out ulong serverid) == true)
+ {
+ return false;
+ }
+ if (ulong.TryParse(givenmemberid, out ulong memberid) == true)
+ {
+ return false;
+ }
+ SocketGuild server = Discord.GetGuild(serverid);
+ SocketGuildUser user = server.GetUser(memberid);
+ bool.TryParse(mode, out bool status);
+ await user.ModifyAsync(pr =>
+ {
+ pr.Mute = status;
+ });
+ return true;
+ }
+
+ protected async Task MessageChannel(string givenserverid, string givenchannelid, string givenmessage, string tts)
+ {
+ if (bool.TryParse(tts, out bool useTTS) == false)
+ {
+ return false;
+ }
+ return await bot.SendMessageToDiscord(givenserverid, givenchannelid, givenmessage, useTTS);
+ }
+
+
+ protected async Task>> ListMembers(string givenserverid)
+ {
+ DiscordSocketClient Discord = bot.getDiscordClient();
+ if (ulong.TryParse(givenserverid, out ulong serverid) == false)
+ {
+ return new KeyValuePair>(false, new Dictionary());
+ }
+ SocketGuild server = Discord.GetGuild(serverid);
+ IEnumerable users = await server.GetUsersAsync().FlattenAsync().ConfigureAwait(true);
+ Dictionary membersList = new Dictionary();
+
+ foreach (IGuildUser user in users)
+ {
+ if (user.Nickname != null)
+ {
+ membersList.Add(user.Id.ToString(), user.Nickname + "|" + user.Username);
+ }
+ else
+ {
+ membersList.Add(user.Id.ToString(), user.Username);
+ }
+ }
+ return new KeyValuePair>(true, membersList);
+ }
+
+
+ protected async Task MessageMember(string givenserverid, string givenmemberid, string givenmessage)
+ {
+ DiscordSocketClient Discord = bot.getDiscordClient();
+ if (ulong.TryParse(givenserverid, out ulong serverid) == false)
+ {
+ return false;
+ }
+ if (ulong.TryParse(givenmemberid, out ulong memberid) == false)
+ {
+ return false;
+ }
+ try
+ {
+ SocketGuild server = Discord.GetGuild(serverid);
+ IEnumerable users = await server.GetUsersAsync().FlattenAsync().ConfigureAwait(true);
+ bool sent = false;
+ foreach (IGuildUser user in users)
+ {
+ if (user.Id == memberid)
+ {
+ sent = true;
+ await user.SendMessageAsync(givenmessage);
+ break;
+ }
+ }
+ return sent;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+
+ protected async Task> ClearMessages(string givenserverid, string givenmemberid)
+ {
+ int messagesDeleted = 0;
+ DiscordSocketClient Discord = bot.getDiscordClient();
+ if (ulong.TryParse(givenserverid, out ulong serverid) == false)
+ {
+ return new KeyValuePair(false, 0);
+ }
+ if (ulong.TryParse(givenmemberid, out ulong memberid) == false)
+ {
+ return new KeyValuePair(false, 0);
+ }
+ SocketGuild server = Discord.GetGuild(serverid);
+ SocketGuildUser user = server.GetUser(memberid);
+ TimeSpan somedays = new TimeSpan(13, 22, 59, 59, 0);
+ DateTimeOffset justundertwosweeks = DateTimeOffset.Now;
+ justundertwosweeks = justundertwosweeks.Subtract(somedays);
+ long unixtimelimit = justundertwosweeks.ToUnixTimeSeconds();
+ foreach (SocketTextChannel channel in server.TextChannels)
+ {
+ List DeleteMessages = new List();
+ IEnumerable messages = await channel.GetMessagesAsync(100).FlattenAsync();
+ foreach (IMessage message in messages)
+ {
+ if (message.CreatedAt.ToUnixTimeSeconds() > unixtimelimit)
+ {
+ if (message.Author.Id == user.Id)
+ {
+ DeleteMessages.Add(message);
+ }
+ }
+ }
+ if (DeleteMessages.Count > 0)
+ {
+ messagesDeleted += DeleteMessages.Count;
+ await channel.DeleteMessagesAsync(DeleteMessages);
+ }
+ }
+ return new KeyValuePair(true, messagesDeleted);
+ }
+
+
protected async Task BanMember(string givenserverid, string givenmemberid, string why)
{
@@ -101,5 +706,8 @@ namespace BetterSecondBot.HttpService
await user.AddRoleAsync(role); // ? Irole seems to accept SocketRole ?
return true;
}
+
+
+ #endregion
}
}
diff --git a/BetterSecondbot/HttpService/Estate.cs b/BetterSecondbot/HttpService/Estate.cs
index 863fd4b..9445e7f 100644
--- a/BetterSecondbot/HttpService/Estate.cs
+++ b/BetterSecondbot/HttpService/Estate.cs
@@ -5,6 +5,9 @@ using EmbedIO.Routing;
using System;
using Newtonsoft.Json;
using OpenMetaverse;
+using System.Collections.Generic;
+using EmbedIO.WebApi;
+using BetterSecondBotShared.Static;
namespace BetterSecondBot.HttpService
{
@@ -18,20 +21,137 @@ namespace BetterSecondBot.HttpService
}
+ [About("Sends the message to the current sim")]
+ [ReturnHints("Not an estate manager here")]
+ [ReturnHints("restarting")]
+ [ReturnHints("canceled")]
+ [ArgHints("delay", "URLARG", "How long to delay the restart for (30 to 240 secs) - defaults to 240 if out of bounds \n" +
+ "set to 0 if your canceling!")]
+ [ArgHints("mode", "URLARG", "true to start a restart, false to cancel")]
+ [Route(HttpVerbs.Get, "/SimRestart/{delay}/{mode}/{token}")]
+ public object SimRestart(string delay, string mode, string token)
+ {
+ if (tokens.Allow(token, "estate", "SimMessage", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.GetClient.Network.CurrentSim.IsEstateManager == false)
+ {
+ return Failure("Not an estate manager here");
+ }
+ bool.TryParse(mode, out bool modeflag);
+ if (modeflag == false)
+ {
+ bot.GetClient.Estate.CancelRestart();
+ return BasicReply("canceled");
+ }
+ int delay_restart = 60;
+ int.TryParse(delay, out delay_restart);
+ if((delay_restart < 30) || (delay_restart > 240))
+ {
+ delay_restart = 240;
+ }
+ bot.GetClient.Estate.RestartRegion(delay_restart);
+ return BasicReply("restarting");
+ }
+
+ [About("Sends the message to the current sim")]
+ [ReturnHints("Not an estate manager here")]
+ [ReturnHints("Message empty")]
+ [ReturnHints("ok")]
+ [ArgHints("message", "Text", "What the message is")]
+ [Route(HttpVerbs.Post, "/SimMessage/{token}")]
+ public object SimMessage([FormField] string message, string token)
+ {
+ if (tokens.Allow(token, "estate", "SimMessage", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (helpers.notempty(message) == false)
+ {
+ return Failure("Message empty");
+ }
+ if (bot.GetClient.Network.CurrentSim.IsEstateManager == false)
+ {
+ return Failure("Not an estate manager here");
+ }
+ bot.GetClient.Estate.SimulatorMessage(message);
+ return BasicReply("ok");
+ }
+
+ [About("Fetchs the regions map tile")]
+ [ReturnHints("Unable to find region")]
+ [ReturnHints("Texture UUID")]
+ [ArgHints("regionname", "URLARG", "the name of the region we are fetching")]
+ [Route(HttpVerbs.Get, "/GetSimTexture/{regionname}/{token}")]
+ public object GetSimTexture(string regionname, string token)
+ {
+ if (tokens.Allow(token, "estate", "GetSimTexture", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.GetClient.Grid.GetGridRegion(regionname, GridLayerType.Objects, out GridRegion region) == false)
+ {
+ return Failure("Unable to find region");
+ }
+ return BasicReply(region.MapImageID.ToString());
+ }
+
+ [About("Reclaims ownership of the current parcel")]
+ [ReturnHints("Not an estate manager here")]
+ [ReturnHints("ok")]
+ [Route(HttpVerbs.Get, "/EstateParcelReclaim/{token}")]
+ public Object EstateParcelReclaim(string token)
+ {
+ if (tokens.Allow(token, "estate", "EstateParcelReclaim", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.GetClient.Network.CurrentSim.IsEstateManager == false)
+ {
+ return Failure("Not an estate manager here");
+ }
+ int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition);
+ bot.GetClient.Parcels.Reclaim(bot.GetClient.Network.CurrentSim, localid);
+ return BasicReply("ok");
+ }
+
+ [About("Reclaims ownership of the current parcel")]
+ [ReturnHints("Not an estate manager here")]
+ [ReturnHints("ok")]
+ [Route(HttpVerbs.Get, "/GetSimGlobalPos/{regionname}/{token}")]
+ public Object GetSimGlobalPos(string regionname, string token)
+ {
+ if (tokens.Allow(token, "estate", "GetSimGlobalPos", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.GetClient.Grid.GetGridRegion(regionname, GridLayerType.Objects, out GridRegion region) == false)
+ {
+ return Failure("Unable to find region");
+ }
+ Dictionary reply = new Dictionary();
+ reply.Add("region", regionname);
+ reply.Add("X", region.X.ToString());
+ reply.Add("Y", region.Y.ToString());
+ return reply;
+ }
+
[About("Requests the estate banlist")]
[ReturnHints("")]
[Route(HttpVerbs.Get, "/GetEstateBanList/{token}")]
public Object GetEstateBanList(string token)
{
- if (tokens.Allow(token, "estate", "banlist", getClientIP()) == true)
+ if (tokens.Allow(token, "estate", "banlist", getClientIP()) == false)
{
- return BasicReply(JsonConvert.SerializeObject(bot._lastUpdatedSimBlacklist));
+ return Failure("Token not accepted");
}
- return BasicReply("Token not accepted");
+ return BasicReply(JsonConvert.SerializeObject(bot._lastUpdatedSimBlacklist));
}
[About("Attempts to add/remove the avatar to/from the Estate banlist")]
- [ReturnHints("Request accepted")]
+ [ReturnHints("Unban request accepted")]
+ [ReturnHints("Ban request accepted")]
[ReturnHints("Unable to find avatar UUID")]
[ReturnHints("Unable to process global value please use true or false")]
[ReturnHints("Not an estate manager on region {REGIONNAME}")]
@@ -42,33 +162,31 @@ namespace BetterSecondBot.HttpService
public Object UpdateEstateBanlist(string avatar, string mode, string global, string token)
{
- if (tokens.Allow(token, "estate", "banlist-add", getClientIP()) == true)
+ if (tokens.Allow(token, "estate", "banlist-add", getClientIP()) == false)
{
- if(bot.GetClient.Network.CurrentSim.IsEstateManager == false)
- {
- return BasicReply("Not an estate manager on region "+ bot.GetClient.Network.CurrentSim.Name);
- }
- UUID avataruuid = UUID.Zero;
- if(UUID.TryParse(avatar,out avataruuid) == false)
- {
- return BasicReply("Unable to find avatar UUID");
- }
- bool globalban = false;
- if(bool.TryParse(global,out globalban) == false)
- {
- return BasicReply("Unable to process global value please use true or false");
- }
- if(mode != "add")
- {
- bot.GetClient.Estate.UnbanUser(avataruuid, globalban);
- }
- else
- {
- bot.GetClient.Estate.BanUser(avataruuid, globalban);
- }
- return BasicReply("Request accepted");
+ return Failure("Token not accepted");
}
- return BasicReply("Token not accepted");
+ if (bot.GetClient.Network.CurrentSim.IsEstateManager == false)
+ {
+ return Failure("Not an estate manager on region " + bot.GetClient.Network.CurrentSim.Name);
+ }
+ UUID avataruuid = UUID.Zero;
+ if (UUID.TryParse(avatar, out avataruuid) == false)
+ {
+ return Failure("Unable to find avatar UUID");
+ }
+ bool globalban = false;
+ if (bool.TryParse(global, out globalban) == false)
+ {
+ return Failure("Unable to process global value please use true or false");
+ }
+ if (mode != "add")
+ {
+ bot.GetClient.Estate.UnbanUser(avataruuid, globalban);
+ return BasicReply("Unban request accepted");
+ }
+ bot.GetClient.Estate.BanUser(avataruuid, globalban);
+ return BasicReply("Ban request accepted");
}
}
}
diff --git a/BetterSecondbot/HttpService/Friends.cs b/BetterSecondbot/HttpService/Friends.cs
new file mode 100644
index 0000000..fdf2d7f
--- /dev/null
+++ b/BetterSecondbot/HttpService/Friends.cs
@@ -0,0 +1,114 @@
+using BetterSecondBot.bottypes;
+using BetterSecondBot.Static;
+using EmbedIO;
+using EmbedIO.Routing;
+using EmbedIO.WebApi;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenMetaverse;
+using Newtonsoft.Json;
+using System.Reflection;
+
+namespace BetterSecondBot.HttpService
+{
+ public class HTTP_Friends : WebApiControllerWithTokens
+ {
+ public HTTP_Friends(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { }
+
+ [About("Gets the friendslist
Formated as follows
friendreplyobject
- name: String
- id: String
- online: bool
")]
+ [ReturnHints("array UUID = friendreplyobject")]
+ [Route(HttpVerbs.Get, "/Friendslist/{token}")]
+ public object Friendslist(string token)
+ {
+ if (tokens.Allow(token, "friends", "Friendslist", getClientIP()) == true)
+ {
+ return Failure("Token not accepted");
+ }
+ return BasicReply(bot.getJsonFriendlist());
+ }
+
+ [About("Updates the friend perms for avatar avatar to State \n if true grants (Online/Map/Modify) perms")]
+ [ArgHints("avatar", "URLARG", "A avatar uuid or Firstname Lastname")]
+ [ArgHints("state", "URLARG", "true: Grant perms, false: Remove perms")]
+ [ReturnHints("granted")]
+ [ReturnHints("removed")]
+ [ReturnHints("Not A friend")]
+ [ReturnHints("state invaild")]
+ [ReturnHints("avatar lookup")]
+ [Route(HttpVerbs.Get, "/FriendFullPerms/{avatar}/{state}/{token}")]
+ public object FriendFullPerms(string avatar, string state, string token)
+ {
+ if (tokens.Allow(token, "friends", "FriendFullPerms", getClientIP()) == true)
+ {
+ return Failure("Token not accepted");
+ }
+ ProcessAvatar(avatar);
+ if (avataruuid == UUID.Zero)
+ {
+ return Failure("avatar lookup");
+ }
+ bool status = false;
+ if (bool.TryParse(state, out status) == false)
+ {
+ return Failure("state invaild");
+ }
+ if (bot.GetClient.Friends.FriendList.ContainsKey(avataruuid) == false)
+ {
+ return Failure("Not A friend");
+ }
+ if (status == true)
+ {
+ bot.GetClient.Friends.GrantRights(avataruuid, FriendRights.CanSeeOnline | FriendRights.CanSeeOnMap | FriendRights.CanModifyObjects);
+ return BasicReply("granted");
+ }
+ bot.GetClient.Friends.GrantRights(avataruuid, FriendRights.None);
+ return BasicReply("removed");
+ }
+
+ [About("Updates the friend perms for avatar avatar to State \n if true grants (Online/Map/Modify) perms")]
+ [ReturnHints("Request sent")]
+ [ReturnHints("Removed")]
+ [ReturnHints("Already a friend")]
+ [ReturnHints("Not in friendslist")]
+ [ReturnHints("state invaild")]
+ [ReturnHints("avatar lookup")]
+ [ArgHints("avatar", "URLARG", "A avatar uuid or Firstname Lastname")]
+ [ArgHints("state", "URLARG", "true: Send invite, false: Remove from friendslist")]
+ [Route(HttpVerbs.Get, "/FriendRequest/{avatar}/{state}/{token}")]
+ public object FriendRequest(string avatar, string state, string token)
+ {
+ if (tokens.Allow(token, "friends", "FriendRequest", getClientIP()) == true)
+ {
+ return Failure("Token not accepted");
+ }
+ ProcessAvatar(avatar);
+ if (avataruuid == UUID.Zero)
+ {
+ return Failure("avatar lookup");
+ }
+ bool status = false;
+ if (bool.TryParse(state, out status) == false)
+ {
+ return Failure("state invaild");
+ }
+ if (bot.GetClient.Friends.FriendList.ContainsKey(avataruuid) == true)
+ {
+ if (status == false)
+ {
+ bot.GetClient.Friends.TerminateFriendship(avataruuid);
+ return BasicReply("Removed");
+ }
+ }
+ if (status == false)
+ {
+ return Failure("Not in friendslist");
+ }
+ bot.GetClient.Friends.OfferFriendship(avataruuid);
+ return BasicReply("Request sent");
+
+ }
+ }
+
+
+}
diff --git a/BetterSecondbot/HttpService/Funds.cs b/BetterSecondbot/HttpService/Funds.cs
new file mode 100644
index 0000000..59f1f6b
--- /dev/null
+++ b/BetterSecondbot/HttpService/Funds.cs
@@ -0,0 +1,112 @@
+using BetterSecondBot.bottypes;
+using BetterSecondBot.Static;
+using EmbedIO;
+using EmbedIO.Routing;
+using EmbedIO.WebApi;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenMetaverse;
+using Newtonsoft.Json;
+using BetterSecondBotShared.Static;
+
+namespace BetterSecondBot.HttpService
+{
+ public class Http_Funds : WebApiControllerWithTokens
+ {
+ public Http_Funds(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { }
+
+ [About("Requests the current balance and requests the balance to update.")]
+ [ReturnHints("Current fund level")]
+ [ReturnHints("Funds commands are disabled")]
+ [Route(HttpVerbs.Get, "/Balance/{token}")]
+ public object Balance(string token)
+ {
+ if (tokens.Allow(token, "funds", "Balance", getClientIP()) == true)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.GetAllowFunds == false)
+ {
+ return Failure("Funds commands are disabled");
+ }
+ bot.GetClient.Self.RequestBalance();
+ return BasicReply(bot.GetClient.Self.Balance.ToString());
+ }
+
+ [About("Makes the bot pay a avatar")]
+ [ReturnHints("Accepted")]
+ [ReturnHints("avatar lookup")]
+ [ReturnHints("Invaild amount")]
+ [ReturnHints("Transfer funds to avatars disabled")]
+ [Route(HttpVerbs.Get, "/PayAvatar/{avatar}/{amount}/{token}")]
+ public object PayAvatar(string avatar, string amount, string token)
+ {
+ if (tokens.Allow(token, "funds", "PayAvatar", getClientIP()) == false)
+ {
+ return BasicReply("Token not accepted");
+ }
+ if (bot.GetAllowFunds == false)
+ {
+ return BasicReply("Transfer funds to avatars disabled");
+ }
+ ProcessAvatar(avatar);
+ if (avataruuid == UUID.Zero)
+ {
+ return BasicReply("avatar lookup");
+ }
+ if (int.TryParse(amount, out int amountvalue) == false)
+ {
+ return BasicReply("Invaild amount");
+ }
+ if (amountvalue < 1)
+ {
+ return BasicReply("Invaild amount");
+ }
+ bot.GetClient.Self.GiveAvatarMoney(avataruuid, amountvalue);
+ return BasicReply("Accepted");
+ }
+
+ [About("Makes the bot pay a object")]
+ [ReturnHints("ok")]
+ [ReturnHints("Primname is empty")]
+ [ReturnHints("Current fund level")]
+ [ReturnHints("Invaild object UUID")]
+ [ReturnHints("Invaild amount")]
+ [ReturnHints("Amount out of range")]
+ [ReturnHints("Funds commands are disabled")]
+ [ArgHints("object", "URLARG", "UUID of the object to pay")]
+ [ArgHints("primname", "URLARG", "The name of the prim on the object to pay")]
+ [ArgHints("amount", "URLARG", "the amount to pay (from 1 to current balance)")]
+ [Route(HttpVerbs.Get, "/PayObject/{object}/{primname}/{amount}/{token}")]
+ public object PayObject(string objectuuid,string primname,string amount,string token)
+ {
+ if (tokens.Allow(token, "funds", "PayObject", getClientIP()) == true)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.GetAllowFunds == false)
+ {
+ return Failure("Funds commands are disabled");
+ }
+ if (UUID.TryParse(objectuuid, out UUID objectUUID) == false)
+ {
+ return Failure("Invaild object UUID");
+ }
+ if (int.TryParse(amount, out int amountvalue) == false)
+ {
+ return Failure("Invaild amount");
+ }
+ if((amountvalue < 0) || (amountvalue > bot.GetClient.Self.Balance))
+ {
+ return Failure("Amount out of range");
+ }
+ if(helpers.notempty(primname) == false)
+ {
+ return Failure("Primname is empty");
+ }
+ bot.GetClient.Self.GiveObjectMoney(objectUUID, amountvalue, primname);
+ return BasicReply("ok");
+ }
+ }
+}
diff --git a/BetterSecondbot/HttpService/Group.cs b/BetterSecondbot/HttpService/Group.cs
index e746737..8a6ddf6 100644
--- a/BetterSecondbot/HttpService/Group.cs
+++ b/BetterSecondbot/HttpService/Group.cs
@@ -22,58 +22,370 @@ namespace BetterSecondBot.HttpService
[ReturnHints("Updating")]
[ReturnHints("Unknown group")]
[ReturnHints("Invaild group UUID")]
- [ReturnHints("Unable to find avatar UUID")]
+ [ReturnHints("avatar lookup")]
[ArgHints("group", "URLARG", "the UUID of the group")]
[ArgHints("avatar", "URLARG", "the UUID of the avatar you wish to check with")]
- [Route(HttpVerbs.Get, "/ismember/{group}/{avatar}/{token}")]
- public object ismember(string group,string avatar,string token)
+ [Route(HttpVerbs.Get, "/IsGroupMember/{group}/{avatar}/{token}")]
+ public object IsGroupMember(string group, string avatar, string token)
{
- if (tokens.Allow(token, "groups", "ismember", getClientIP()) == true)
+ if (tokens.Allow(token, "groups", "IsGroupMember", getClientIP()) == true)
{
- if (UUID.TryParse(group, out UUID groupuuid) == true)
- {
- if (bot.MyGroups.ContainsKey(groupuuid) == true)
- {
- if (bot.NeedReloadGroupData(groupuuid) == false)
- {
- UUID avataruuid = UUID.Zero;
- if(UUID.TryParse(avatar,out avataruuid) == false)
- {
- string lookup = bot.FindAvatarName2Key(avatar);
- if (UUID.TryParse(lookup, out avataruuid) == false)
- {
- return BasicReply("Unable to find avatar UUID");
- }
- }
- bool status = bot.FastCheckInGroup(groupuuid, avataruuid);
- return BasicReply(status.ToString());
- }
- bot.GetClient.Groups.RequestGroupMembers(groupuuid);
- return BasicReply("Updating");
- }
- return BasicReply("Unknown group");
- }
- return BasicReply("Invaild group UUID");
+ return Failure("Token not accepted");
}
- return BasicReply("Token not accepted");
+ if (UUID.TryParse(group, out UUID groupuuid) == false)
+ {
+ return Failure("Invaild group UUID");
+ }
+ if (bot.MyGroups.ContainsKey(groupuuid) == false)
+ {
+ return Failure("Unknown group");
+ }
+ if (bot.NeedReloadGroupData(groupuuid) == true)
+ {
+ bot.GetClient.Groups.RequestGroupMembers(groupuuid);
+ return Failure("Updating");
+ }
+ ProcessAvatar(avatar);
+ if (avataruuid == UUID.Zero)
+ {
+ return Failure("avatar lookup");
+ }
+ bool status = bot.FastCheckInGroup(groupuuid, avataruuid);
+ return BasicReply(status.ToString());
+ }
+
+ [About("Gets membership of a group")]
+ [ReturnHints("list of UUIDS of group members")]
+ [ReturnHints("Updating")]
+ [ReturnHints("Unknown group")]
+ [ReturnHints("Invaild group UUID")]
+ [ReturnHints("avatar lookup")]
+ [ArgHints("group", "URLARG", "the UUID of the group")]
+ [Route(HttpVerbs.Get, "/GetGroupMembers/{group}/{token}")]
+ public object GetGroupMembers(string group, string token)
+ {
+ if (tokens.Allow(token, "groups", "GetGroupMembers", getClientIP()) == true)
+ {
+ return Failure("Token not accepted");
+ }
+ if (UUID.TryParse(group, out UUID groupuuid) == false)
+ {
+ return Failure("Invaild group UUID");
+ }
+ if (bot.MyGroups.ContainsKey(groupuuid) == false)
+ {
+ return Failure("Unknown group");
+ }
+ if (bot.NeedReloadGroupData(groupuuid) == true)
+ {
+ bot.GetClient.Groups.RequestGroupMembers(groupuuid);
+ return Failure("Updating");
+ }
+ return bot.GetGroupMembers(groupuuid);
+ }
+
+ [About("Eject selected avatar from group")]
+ [ReturnHints("Requested")]
+ [ReturnHints("Updating")]
+ [ReturnHints("Unknown group")]
+ [ReturnHints("Invaild group UUID")]
+ [ReturnHints("Not in group")]
+ [ReturnHints("avatar lookup")]
+ [ArgHints("group", "URLARG", "the UUID of the group")]
+ [ArgHints("avatar", "URLARG", "the UUID of the avatar you wish to check with")]
+ [Route(HttpVerbs.Get, "/GroupEject/{group}/{avatar}/{token}")]
+ public object GroupEject(string group, string avatar, string token)
+ {
+ if (tokens.Allow(token, "groups", "GroupEject", getClientIP()) == true)
+ {
+ return Failure("Token not accepted");
+ }
+ if (UUID.TryParse(group, out UUID groupuuid) == false)
+ {
+ return Failure("Invaild group UUID");
+ }
+ if (bot.MyGroups.ContainsKey(groupuuid) == false)
+ {
+ return Failure("Unknown group");
+ }
+ if (bot.NeedReloadGroupData(groupuuid) == true)
+ {
+ bot.GetClient.Groups.RequestGroupMembers(groupuuid);
+ return Failure("Updating");
+ }
+ ProcessAvatar(avatar);
+ if (avataruuid == UUID.Zero)
+ {
+ return Failure("avatar lookup");
+ }
+ bool status = bot.FastCheckInGroup(groupuuid, avataruuid);
+ if(status == false)
+ {
+ return BasicReply("Not in group");
+ }
+ bot.GetClient.Groups.EjectUser(groupuuid, avataruuid);
+ return BasicReply("Requested");
+ }
+
+ [About("Adds the avatar to the Group with the role \n if they are not in the group then it invites them aswell")]
+ [ReturnHints("Roles updated")]
+ [ReturnHints("Invite sent")]
+ [ReturnHints("Updating")]
+ [ReturnHints("Unknown group")]
+ [ReturnHints("Invaild group UUID")]
+ [ReturnHints("Invaild role UUID")]
+ [ReturnHints("Not in group")]
+ [ReturnHints("avatar lookup")]
+ [ArgHints("group", "URLARG", "the UUID of the group")]
+ [ArgHints("avatar", "URLARG", "the UUID of the avatar you wish to check with")]
+ [Route(HttpVerbs.Get, "/GroupAddRole/{group}/{avatar}/{role}/{token}")]
+ public object GroupAddRole(string group, string avatar, string role, string token)
+ {
+ if (tokens.Allow(token, "groups", "GroupAddRole", getClientIP()) == true)
+ {
+ return Failure("Token not accepted");
+ }
+ if (UUID.TryParse(group, out UUID groupuuid) == false)
+ {
+ return Failure("Invaild group UUID");
+ }
+ if (UUID.TryParse(role, out UUID roleuuid) == false)
+ {
+ return Failure("Invaild role UUID");
+ }
+ if (bot.MyGroups.ContainsKey(groupuuid) == false)
+ {
+ return Failure("Unknown group");
+ }
+ if (bot.NeedReloadGroupData(groupuuid) == true)
+ {
+ bot.GetClient.Groups.RequestGroupMembers(groupuuid);
+ return Failure("Updating");
+ }
+ ProcessAvatar(avatar);
+ if (avataruuid == UUID.Zero)
+ {
+ return Failure("avatar lookup");
+ }
+ bool status = bot.FastCheckInGroup(groupuuid, avataruuid);
+ if (status == false)
+ {
+ bot.GetClient.Groups.Invite(groupuuid, new List() { roleuuid }, avataruuid);
+ return BasicReply("Invite sent");
+ }
+ bot.GetClient.Groups.AddToRole(groupuuid, roleuuid, avataruuid);
+ return BasicReply("Roles updated");
+ }
+
+ [About("Eject selected avatar from group")]
+ [ReturnHints("Invite sent")]
+ [ReturnHints("Updating")]
+ [ReturnHints("Unknown group")]
+ [ReturnHints("Invaild group UUID")]
+ [ReturnHints("Already in group")]
+ [ReturnHints("avatar lookup")]
+ [ArgHints("group", "URLARG", "the UUID of the group")]
+ [ArgHints("avatar", "URLARG", "the UUID of the avatar you wish to check with")]
+ [ArgHints("role", "URLARG", "the UUID of the role to invite them at the word \"everyone\"")]
+ [Route(HttpVerbs.Get, "/GroupInvite/{group}/{avatar}/{role}/{token}")]
+ public object GroupInvite(string group, string avatar, string role, string token)
+ {
+ if (tokens.Allow(token, "groups", "GroupInvite", getClientIP()) == true)
+ {
+ return Failure("Token not accepted");
+ }
+ if (UUID.TryParse(group, out UUID groupuuid) == false)
+ {
+ return Failure("Invaild group UUID");
+ }
+ if (bot.MyGroups.ContainsKey(groupuuid) == false)
+ {
+ return Failure("Unknown group");
+ }
+ if (bot.NeedReloadGroupData(groupuuid) == true)
+ {
+ bot.GetClient.Groups.RequestGroupMembers(groupuuid);
+ return Failure("Updating");
+ }
+ ProcessAvatar(avatar);
+ if (avataruuid == UUID.Zero)
+ {
+ return Failure("avatar lookup");
+ }
+ bool status = bot.FastCheckInGroup(groupuuid, avataruuid);
+ if (status == true)
+ {
+ return Failure("Already in group");
+ }
+ if(role == "everyone")
+ {
+ role = UUID.Zero.ToString();
+ }
+ if(UUID.TryParse(role,out UUID roleuuid) == false)
+ {
+ return Failure("Unable to process role UUID");
+ }
+ bot.GetClient.Groups.Invite(groupuuid, new List() { roleuuid }, avataruuid);
+ return BasicReply("Invite sent");
+ }
+
+ [About("Sends a group notice (No attachments please use GroupnoticeWithAttachment to attach items!)")]
+ [ReturnHints("Sending notice")]
+ [ReturnHints("Unknown group")]
+ [ReturnHints("Invaild group UUID")]
+ [ReturnHints("Title empty")]
+ [ReturnHints("Message empty")]
+ [ArgHints("group", "URLARG", "the UUID of the group")]
+ [ArgHints("title", "Text", "The title of the group notice")]
+ [ArgHints("message", "Text", "The body of the group notice")]
+ [Route(HttpVerbs.Post, "/Groupnotice/{group}/{token}")]
+ public object Groupnotice(string group, [FormField] string title, [FormField] string message, string token)
+ {
+ if (tokens.Allow(token, "groups", "Groupnotice", getClientIP()) == true)
+ {
+ return Failure("Token not accepted");
+ }
+ if (UUID.TryParse(group, out UUID groupuuid) == false)
+ {
+ return Failure("Invaild group UUID");
+ }
+ if (bot.MyGroups.ContainsKey(groupuuid) == false)
+ {
+ return Failure("Unknown group");
+ }
+ if (helpers.notempty(title) == false)
+ {
+ return Failure("Title empty");
+ }
+ if (helpers.notempty(message) == false)
+ {
+ return Failure("Message empty");
+ }
+ GroupNotice NewNotice = new GroupNotice();
+ NewNotice.Subject = title;
+ NewNotice.Message = message;
+ NewNotice.OwnerID = bot.GetClient.Self.AgentID;
+ bot.GetClient.Groups.SendGroupNotice(groupuuid, NewNotice);
+ return BasicReply("Sending notice");
+ }
+
+ [About("Activates the selected title")]
+ [ReturnHints("Switching title")]
+ [ReturnHints("Unknown group")]
+ [ReturnHints("Invaild group UUID")]
+ [ReturnHints("Invaild role UUID")]
+ [ArgHints("group", "URLARG", "the UUID of the group")]
+ [ArgHints("role", "URLARG", "tje UUID of the role")]
+ [Route(HttpVerbs.Get, "/GroupActiveTitle/{group}/{token}")]
+ public object GroupActiveTitle(string group, string role, string token)
+ {
+ if (tokens.Allow(token, "groups", "GroupActiveTitle", getClientIP()) == true)
+ {
+ return Failure("Token not accepted");
+ }
+ if (UUID.TryParse(group, out UUID groupuuid) == false)
+ {
+ return Failure("Invaild group UUID");
+ }
+ if (UUID.TryParse(role, out UUID roleuuid) == false)
+ {
+ return Failure("Invaild role UUID");
+ }
+ if (bot.MyGroups.ContainsKey(groupuuid) == false)
+ {
+ return Failure("Unknown group");
+ }
+ bot.GetClient.Groups.ActivateTitle(groupuuid, roleuuid);
+ return BasicReply("Switching title");
+ }
+
+ [About("Sets the selected group to the active group")]
+ [ReturnHints("Switching active group")]
+ [ReturnHints("Unknown group")]
+ [ReturnHints("Invaild group UUID")]
+ [ArgHints("group", "URLARG", "the UUID of the group")]
+ [Route(HttpVerbs.Get, "/GroupActiveGroup/{group}/{token}")]
+ public object GroupActiveGroup(string group, string role, string token)
+ {
+ if (tokens.Allow(token, "groups", "GroupActiveTitle", getClientIP()) == true)
+ {
+ return Failure("Token not accepted");
+ }
+ if (UUID.TryParse(group, out UUID groupuuid) == false)
+ {
+ return Failure("Invaild group UUID");
+ }
+ if (bot.MyGroups.ContainsKey(groupuuid) == false)
+ {
+ return Failure("Unknown group");
+ }
+ bot.GetClient.Groups.ActivateGroup(groupuuid);
+ return BasicReply("Switching active group");
+ }
+
+ [About("Sends a group notice with an attachment")]
+ [ReturnHints("Sending notice with attachment")]
+ [ReturnHints("Unknown group")]
+ [ReturnHints("Invaild group UUID")]
+ [ReturnHints("Invaild inventory UUID")]
+ [ReturnHints("Title empty")]
+ [ReturnHints("Message empty")]
+ [ArgHints("group", "URLARG", "the UUID of the group")]
+ [ArgHints("attachment", "URLARG", "the UUID of inventory you wish to attach")]
+ [ArgHints("title", "Text", "The title of the group notice")]
+ [ArgHints("message", "Text", "The body of the group notice")]
+ [Route(HttpVerbs.Post, "/Groupnotice/{group}/{attachment}/{token}")]
+ public object GroupnoticeWithAttachment(string group, [FormField] string title, [FormField] string message, string attachment, string token)
+ {
+ if (tokens.Allow(token, "groups", "GroupnoticeWithAttachment", getClientIP()) == true)
+ {
+ return Failure("Token not accepted");
+ }
+ if (UUID.TryParse(group, out UUID groupuuid) == false)
+ {
+ return Failure("Invaild group UUID");
+ }
+ if (UUID.TryParse(attachment, out UUID inventoryuuid) == false)
+ {
+ return Failure("Invaild inventory UUID");
+ }
+ if (bot.MyGroups.ContainsKey(groupuuid) == false)
+ {
+ return Failure("Unknown group");
+ }
+ if (helpers.notempty(title) == false)
+ {
+ return Failure("Title empty");
+ }
+ if (helpers.notempty(message) == false)
+ {
+ return Failure("Message empty");
+ }
+ GroupNotice NewNotice = new GroupNotice();
+ NewNotice.Subject = title;
+ NewNotice.Message = message;
+ NewNotice.OwnerID = bot.GetClient.Self.AgentID;
+ NewNotice.AttachmentID = inventoryuuid;
+ bot.GetClient.Groups.SendGroupNotice(groupuuid, NewNotice);
+ return BasicReply("Sending notice with attachment");
}
[About("fetchs a list of all groups known to the bot")]
[ReturnHints("array UUID=name")]
- [Route(HttpVerbs.Get, "/listgroups/{token}")]
- public object listgroups(string token)
+ [Route(HttpVerbs.Get, "/GetGroupList/{token}")]
+ public object GetGroupList(string token)
{
- if (tokens.Allow(token, "groups", "listgroups", getClientIP()) == true)
+ if (tokens.Allow(token, "groups", "GetGroupList", getClientIP()) == true)
{
- Dictionary grouppackage = new Dictionary();
- foreach(KeyValuePair entry in bot.MyGroups)
- {
- grouppackage.Add(entry.Value.ID.ToString(), entry.Value.Name);
- }
- return BasicReply(JsonConvert.SerializeObject(grouppackage));
+ return Failure("Token not accepted");
}
- return BasicReply("Token not accepted");
+ Dictionary grouppackage = new Dictionary();
+ foreach (KeyValuePair entry in bot.MyGroups)
+ {
+ grouppackage.Add(entry.Value.ID.ToString(), entry.Value.Name);
+ }
+ return BasicReply(JsonConvert.SerializeObject(grouppackage));
}
[About("Requests the roles for the selected group
Replys with GroupRoleDetails object formated as follows - UpdateUnderway (Bool)
- RoleDataAge (Int) [default -1]
- Roles (KeyPair array of UUID=Name)
")]
@@ -82,93 +394,132 @@ namespace BetterSecondBot.HttpService
[ReturnHints("Invaild group UUID")]
[ReturnHints("Updating")]
[ArgHints("group", "URLARG", "the UUID of the group")]
- [Route(HttpVerbs.Get, "/listgrouproles/{group}/{token}")]
- public object listgrouproles(string group, string token)
+ [Route(HttpVerbs.Get, "/GetGroupRoles/{group}/{token}")]
+ public object GetGroupRoles(string group, string token)
{
- if (tokens.Allow(token, "groups", "listgrouproles", getClientIP()) == true)
+ if (tokens.Allow(token, "groups", "GetGroupRoles", getClientIP()) == true)
{
- if (UUID.TryParse(group, out UUID groupuuid) == true)
- {
- if (bot.MyGroups.ContainsKey(groupuuid) == true)
- {
- GroupRoleDetails reply = new GroupRoleDetails();
- reply.UpdateUnderway = false;
- reply.RoleDataAge = -1;
- reply.Roles = new Dictionary();
- if (bot.MyGroupRolesStorage.ContainsKey(groupuuid) == false)
- {
- reply.UpdateUnderway = true;
- }
- else
- {
- long dif = helpers.UnixTimeNow() - bot.MyGroupRolesStorage[groupuuid].Key;
- reply.RoleDataAge = dif;
- if (dif >= 120)
- {
- reply.UpdateUnderway = true;
- }
- foreach(GroupRole gr in bot.MyGroupRolesStorage[groupuuid].Value)
- {
- reply.Roles.Add(gr.ID.ToString(), gr.Name);
- }
- }
- if(reply.UpdateUnderway == true)
- {
- bot.GetClient.Groups.RequestGroupRoles(groupuuid);
- if (reply.Roles.Count == 0)
- {
- return BasicReply("Updating");
- }
- }
- return BasicReply(JsonConvert.SerializeObject(reply));
- }
- return BasicReply("Group is not currently known");
- }
- return BasicReply("Invaild group UUID");
+ return Failure("Token not accepted");
}
- return BasicReply("Token not accepted");
+ if (UUID.TryParse(group, out UUID groupuuid) == false)
+ {
+ return Failure("Invaild group UUID");
+ }
+ if (bot.MyGroups.ContainsKey(groupuuid) == false)
+ {
+ return Failure("Unknown group");
+ }
+ GroupRoleDetails reply = new GroupRoleDetails();
+ reply.UpdateUnderway = false;
+ reply.RoleDataAge = -1;
+ reply.Roles = new Dictionary();
+ if (bot.MyGroupRolesStorage.ContainsKey(groupuuid) == false)
+ {
+ reply.UpdateUnderway = true;
+ }
+ else
+ {
+ long dif = helpers.UnixTimeNow() - bot.MyGroupRolesStorage[groupuuid].Key;
+ reply.RoleDataAge = dif;
+ if (dif >= 120)
+ {
+ reply.UpdateUnderway = true;
+ }
+ foreach (GroupRole gr in bot.MyGroupRolesStorage[groupuuid].Value)
+ {
+ reply.Roles.Add(gr.ID.ToString(), gr.Name);
+ }
+ }
+ if (reply.UpdateUnderway == true)
+ {
+ bot.GetClient.Groups.RequestGroupRoles(groupuuid);
+ if (reply.Roles.Count == 0)
+ {
+ return Failure("Updating");
+ }
+ }
+ return BasicReply(JsonConvert.SerializeObject(reply));
}
[About("fetchs a list of all groups with unread messages")]
[ReturnHints("array UUID")]
- [Route(HttpVerbs.Get, "/listgroupswithunread/{token}")]
- public object listgroupswithunread(string token)
+ [Route(HttpVerbs.Get, "/GroupchatListAllUnreadGroups/{token}")]
+ public object GroupchatListAllUnreadGroups(string token)
{
- if (tokens.Allow(token, "groups", "listgroupswithunread", getClientIP()) == true)
+ if (tokens.Allow(token, "groups", "GroupchatListAllUnreadGroups", getClientIP()) == true)
{
- return BasicReply(JsonConvert.SerializeObject(bot.UnreadGroupchatGroups()));
+ return Failure("Token not accepted");
}
- return BasicReply("Token not accepted");
+ return BasicReply(JsonConvert.SerializeObject(bot.UnreadGroupchatGroups()));
}
+ [About("fetchs a list of all groups with unread messages")]
+ [ReturnHints("true")]
+ [ReturnHints("false")]
+ [ReturnHints("Unknown group")]
+ [ReturnHints("group value is invaild")]
+ [ArgHints("group", "URLARG", "the UUID of the group")]
+ [Route(HttpVerbs.Get, "/GroupchatGroupHasUnread/{group}/{token}")]
+ public object GroupchatGroupHasUnread(string group,string token)
+ {
+ if (tokens.Allow(token, "groups", "GroupchatListAllUnreadGroups", getClientIP()) == true)
+ {
+ return Failure("Token not accepted");
+ }
+ UUID groupUUID = UUID.Zero;
+ if(UUID.TryParse(group,out groupUUID) == false)
+ {
+ return Failure("group value is invaild");
+ }
+ if(bot.MyGroups.ContainsKey(groupUUID) == false)
+ {
+ return Failure("Unknown group");
+ }
+ return BasicReply(bot.GroupHasUnread(groupUUID).ToString());
+ }
+
+
[About("checks if there are any groups with unread messages")]
[ReturnHints("True|False")]
- [Route(HttpVerbs.Get, "/haveunreadgroupchat/{token}")]
+ [Route(HttpVerbs.Get, "/GroupchatAnyUnread/{token}")]
public object haveunreadgroupchat(string token)
{
- if (tokens.Allow(token, "groups", "haveunreadgroupchat", getClientIP()) == true)
+ if (tokens.Allow(token, "groups", "GroupchatAnyUnread", getClientIP()) == true)
{
return BasicReply(bot.HasUnreadGroupchats().ToString());
}
- return BasicReply("Token not accepted");
+ return Failure("Token not accepted");
+ }
+
+ [About("Clears all group chat buffers at once")]
+ [ReturnHints("ok")]
+ [Route(HttpVerbs.Get, "/GroupchatClearAll/{token}")]
+ public object GroupchatClearAll(string token)
+ {
+ if (tokens.Allow(token, "groups", "GroupchatClearAll", getClientIP()) == true)
+ {
+ bot.ClearAllGroupchat();
+ return BasicReply("ok");
+ }
+ return Failure("Token not accepted");
}
[About("fetchs the groupchat history")]
[ReturnHints("Group UUID invaild")]
[ReturnHints("Group Chat")]
[ArgHints("group", "URLARG", "the UUID of the group")]
- [Route(HttpVerbs.Get, "/getgroupchat/{group}/{token}")]
- public object getgroupchat(string group, string token)
+ [Route(HttpVerbs.Get, "/GroupchatHistory/{group}/{token}")]
+ public object GroupchatHistory(string group, string token)
{
- if (tokens.Allow(token, "groups", "getgroupchat", getClientIP()) == true)
+ if (tokens.Allow(token, "groups", "GroupchatHistory", getClientIP()) == true)
{
if (UUID.TryParse(group, out UUID groupUUID) == true)
{
return BasicReply(JsonConvert.SerializeObject(bot.GetGroupchat(groupUUID)));
}
- return BasicReply("Group UUID invaild");
+ return Failure("Group UUID invaild");
}
- return BasicReply("Token not accepted");
+ return Failure("Token not accepted");
}
[About("sends a message to the groupchat")]
@@ -176,19 +527,31 @@ namespace BetterSecondBot.HttpService
[ArgHints("message", "Text", "the message to send")]
[ReturnHints("Group UUID invaild")]
[ReturnHints("Processing")]
- [Route(HttpVerbs.Post, "/sendgroupchat/{group}/{token}")]
- public object sendgroupchat(string group, string token, [FormField] string message)
+ [ReturnHints("Opening groupchat")]
+ [ReturnHints("Sending")]
+ [Route(HttpVerbs.Post, "/Groupchat/{group}/{token}")]
+ public object Groupchat(string group, [FormField] string message, string token)
{
- if (tokens.Allow(token, "groups", "sendgroupchat", getClientIP()) == true)
+ if (tokens.Allow(token, "groups", "Groupchat", getClientIP()) == true)
{
- if (UUID.TryParse(group, out UUID groupUUID) == true)
- {
- bool status = bot.GetCommandsInterface.Call("Groupchat", group + "~#~" + message, UUID.Zero, "~#~");
- return BasicReply("Processing");
- }
- return BasicReply("Group UUID invaild");
+ return Failure("Token not accepted");
}
- return BasicReply("Token not accepted");
+ UUID groupUUID = UUID.Zero;
+ if (UUID.TryParse(group, out groupUUID) == false)
+ {
+ return Failure("group value is invaild");
+ }
+ if (bot.MyGroups.ContainsKey(groupUUID) == false)
+ {
+ return Failure("Unknown group");
+ }
+ if (bot.GetActiveGroupchatSessions.Contains(groupUUID) == false)
+ {
+ bot.GetClient.Self.RequestJoinGroupChat(groupUUID);
+ return Failure("Opening groupchat");
+ }
+ bot.GetClient.Self.InstantMessageGroup(groupUUID, message);
+ return BasicReply("Sending");
}
}
diff --git a/BetterSecondbot/HttpService/Home.cs b/BetterSecondbot/HttpService/Home.cs
new file mode 100644
index 0000000..c0ee1ec
--- /dev/null
+++ b/BetterSecondbot/HttpService/Home.cs
@@ -0,0 +1,33 @@
+using BetterSecondBot.bottypes;
+using BetterSecondBot.Static;
+using EmbedIO;
+using EmbedIO.Routing;
+using EmbedIO.WebApi;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenMetaverse;
+using Newtonsoft.Json;
+using BetterSecondBotShared.Static;
+
+namespace BetterSecondBot.HttpService
+{
+ public class Http_Home : WebApiControllerWithTokens
+ {
+ public Http_Home(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { }
+
+ [About("Makes the bot teleport to its home region")]
+ [ReturnHints("ok")]
+ [Route(HttpVerbs.Get, "/GoHome/{token}")]
+ public object GoHome(string group, string token)
+ {
+ if (tokens.Allow(token, "groups", "GetGroupMembers", getClientIP()) == true)
+ {
+ return Failure("Token not accepted");
+ }
+ bot.GotoNextHomeRegion();
+ return BasicReply("ok");
+ }
+
+ }
+}
diff --git a/BetterSecondbot/HttpService/HttpAsService.cs b/BetterSecondbot/HttpService/HttpAsService.cs
index de0762d..07c0948 100644
--- a/BetterSecondbot/HttpService/HttpAsService.cs
+++ b/BetterSecondbot/HttpService/HttpAsService.cs
@@ -436,8 +436,15 @@ namespace BetterSecondBot.HttpService
protected Object BasicReply(string input)
{
- return new { reply = input };
+ return new { reply = input, status=true };
}
+
+ protected Object Failure(string input)
+ {
+ return new { reply = input, status = false };
+ }
+
+
public WebApiControllerWithTokens(SecondBot mainbot, TokenStorage setuptokens)
{
bot = mainbot;
diff --git a/BetterSecondbot/HttpService/Info.cs b/BetterSecondbot/HttpService/Info.cs
new file mode 100644
index 0000000..9f00532
--- /dev/null
+++ b/BetterSecondbot/HttpService/Info.cs
@@ -0,0 +1,116 @@
+using BetterSecondBot.bottypes;
+using BetterSecondBot.Static;
+using EmbedIO;
+using EmbedIO.Routing;
+using EmbedIO.WebApi;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenMetaverse;
+using Newtonsoft.Json;
+using BetterSecondBotShared.Static;
+
+namespace BetterSecondBot.HttpService
+{
+ public class Http_Info : WebApiControllerWithTokens
+ {
+ public Http_Info(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { }
+
+ [About("Fetchs the current bot")]
+ [ReturnHints("The build ID of the bot")]
+ [Route(HttpVerbs.Get, "/Version/{token}")]
+ public object Version(string token)
+ {
+ if (tokens.Allow(token, "info", "Version", getClientIP()) == true)
+ {
+ return BasicReply(bot.MyVersion);
+ }
+ return Failure("Token not accepted");
+ }
+
+ [About("Fetchs the name of the bot")]
+ [ReturnHints("Firstname Lastname")]
+ [Route(HttpVerbs.Get, "/Name/{token}")]
+ public object Name(string token)
+ {
+ if (tokens.Allow(token, "info", "Name", getClientIP()) == true)
+ {
+ return BasicReply(bot.GetClient.Self.FirstName + " " + bot.GetClient.Self.LastName);
+ }
+ return Failure("Token not accepted");
+ }
+
+ [About("Fetchs the current parcels name")]
+ [ReturnHints("Parcelname")]
+ [ReturnHints("Error parcel not found")]
+ [ReturnHints("Error not in a sim")]
+ [Route(HttpVerbs.Get, "/ParcelName/{token}")]
+ public object ParcelName(string token)
+ {
+ if (tokens.Allow(token, "info", "ParcelName", getClientIP()) == true)
+ {
+ if (bot.GetClient.Network.CurrentSim != null)
+ {
+ int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition);
+ if (bot.GetClient.Network.CurrentSim.Parcels.ContainsKey(localid) == true)
+ {
+ return BasicReply(bot.GetClient.Network.CurrentSim.Parcels[localid].Name);
+ }
+ return Failure("Error parcel not found");
+ }
+ return Failure("Error not in a sim");
+ }
+ return Failure("Token not accepted");
+ }
+
+ [About("Requests the current unixtime at the bot")]
+ [ReturnHints("Unixtime")]
+ [Route(HttpVerbs.Get, "/UnixTimeNow/{token}")]
+ public object UnixTimeNow(string token)
+ {
+ if (tokens.Allow(token, "info", "UnixTimeNow", getClientIP()) == true)
+ {
+ return BasicReply(helpers.UnixTimeNow().ToString());
+ }
+ return Failure("Token not accepted");
+ }
+
+ [About("Fetchs the current region name")]
+ [ReturnHints("Regionname")]
+ [ReturnHints("Error not in a sim")]
+ [Route(HttpVerbs.Get, "/SimName/{token}")]
+ public object SimName(string token)
+ {
+ if (tokens.Allow(token, "info", "SimName", getClientIP()) == true)
+ {
+ if (bot.GetClient.Network.CurrentSim != null)
+ {
+ return BasicReply(bot.GetClient.Network.CurrentSim.Name);
+ }
+ return Failure("Error not in a sim");
+ }
+ return Failure("Token not accepted");
+ }
+
+ [About("Fetchs the current location of the bot")]
+ [ReturnHints("array of X,Y,Z values")]
+ [ReturnHints("Error not in a sim")]
+ [Route(HttpVerbs.Get, "/GetPosition/{token}")]
+ public object GetPosition(string token)
+ {
+ if (tokens.Allow(token, "info", "GetPosition", getClientIP()) == true)
+ {
+ if (bot.GetClient.Network.CurrentSim != null)
+ {
+ Dictionary pos = new Dictionary();
+ pos.Add("x", (int)Math.Round(bot.GetClient.Self.SimPosition.X));
+ pos.Add("y", (int)Math.Round(bot.GetClient.Self.SimPosition.Y));
+ pos.Add("z", (int)Math.Round(bot.GetClient.Self.SimPosition.Z));
+ return BasicReply(JsonConvert.SerializeObject(pos));
+ }
+ return Failure("Error not in a sim");
+ }
+ return Failure("Token not accepted");
+ }
+ }
+}
diff --git a/BetterSecondbot/HttpService/Self.cs b/BetterSecondbot/HttpService/Self.cs
new file mode 100644
index 0000000..f08016f
--- /dev/null
+++ b/BetterSecondbot/HttpService/Self.cs
@@ -0,0 +1,131 @@
+using BetterSecondBot.bottypes;
+using BetterSecondBot.Static;
+using EmbedIO;
+using EmbedIO.Routing;
+using EmbedIO.WebApi;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenMetaverse;
+using Newtonsoft.Json;
+using BetterSecondBotShared.Static;
+
+namespace BetterSecondBot.HttpService
+{
+ public class Http_Self : WebApiControllerWithTokens
+ {
+ public Http_Self(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { }
+
+ [About("Makes the bot turn to face avatar and point at them (if found)")]
+ [ReturnHints("ok")]
+ [ReturnHints("Cant find UUID in sim")]
+ [Route(HttpVerbs.Get, "/PointAt/{avatar}/{token}")]
+ public object PointAt(string avatar, string token)
+ {
+ if (tokens.Allow(token, "self", "PointAt", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ ProcessAvatar(avatar);
+ if (bot.GetClient.Network.CurrentSim.AvatarPositions.ContainsKey(avataruuid) == false)
+ {
+ return Failure("Cant find UUID in sim");
+ }
+ bot.ResetAnimations();
+ bot.GetClient.Self.Stand();
+ bot.GetClient.Self.Movement.TurnToward(bot.GetClient.Network.CurrentSim.AvatarPositions[avataruuid]);
+ bot.GetClient.Self.Movement.SendUpdate();
+ bot.GetClient.Self.AnimationStart(Animations.POINT_YOU, true);
+ bot.GetClient.Self.PointAtEffect(bot.GetClient.Self.AgentID, avataruuid, new Vector3d(0, 0, 0), PointAtType.Select, UUID.Random());
+ bot.GetClient.Self.BeamEffect(bot.GetClient.Self.AgentID, avataruuid, new Vector3d(0, 0, 2), new Color4(255, 255, 255, 1), (float)3.0, UUID.Random());
+ return BasicReply("ok");
+ }
+
+ [About("Makes the bot sit on the ground or on a object if it can see it")]
+ [ReturnHints("ok")]
+ [ReturnHints("Invaild object UUID")]
+ [ArgHints("target", "URLARG", "ground or a object UUID")]
+ [Route(HttpVerbs.Get, "/Sit/{target}/{token}")]
+ public object Sit(string target, string token)
+ {
+ if (tokens.Allow(token, "self", "Sit", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if(target == "ground")
+ {
+ bot.GetClient.Self.SitOnGround();
+ return BasicReply("ok");
+ }
+ if(UUID.TryParse(target,out UUID objectuuid) == false)
+ {
+ return Failure("Invaild object UUID");
+ }
+ bot.GetClient.Self.RequestSit(objectuuid, Vector3.Zero);
+ return BasicReply("ok");
+ }
+
+ [About("Makes the bot stand up if sitting (also resets animations)")]
+ [ReturnHints("ok")]
+ [Route(HttpVerbs.Get, "/Stand/{token}")]
+ public object Stand(string target, string token)
+ {
+ if (tokens.Allow(token, "self", "Stand", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ bot.GetClient.Self.Stand();
+ bot.ResetAnimations();
+ return BasicReply("ok");
+ }
+
+ [About("Makes the bot sit on the ground or on a object if it can see it")]
+ [ReturnHints("true|false")]
+ [ReturnHints("Invaild object UUID")]
+ [ReturnHints("Unable to see object")]
+ [ArgHints("target", "URLARG", "object UUID")]
+ [Route(HttpVerbs.Get, "/ClickObject/{object}/{token}")]
+ public object ClickObject(string target, string token)
+ {
+ if (tokens.Allow(token, "self", "ClickObject", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (UUID.TryParse(target, out UUID objectuuid) == false)
+ {
+ return Failure("Invaild object UUID");
+ }
+ Dictionary objectsentrys = bot.GetClient.Network.CurrentSim.ObjectsPrimitives.Copy();
+ bool found_object = false;
+ foreach (KeyValuePair entry in objectsentrys)
+ {
+ if (entry.Value.ID == objectuuid)
+ {
+ bot.GetClient.Objects.ClickObject(bot.GetClient.Network.CurrentSim, entry.Key);
+ found_object = true;
+ break;
+ }
+ }
+ return BasicReply(found_object.ToString());
+ }
+
+ [About("Makes the bot sit on the ground or on a object if it can see it")]
+ [ReturnHints("ok")]
+ [Route(HttpVerbs.Get, "/Logoff/{token}")]
+ public object Logoff(string token)
+ {
+ if (tokens.Allow(token, "self", "Logoff", getClientIP()) == false)
+ {
+ return Failure("Token not accepted");
+ }
+ if (bot.KillMe == false)
+ {
+ bot.GetClient.Self.Chat("Laters im out", 0, ChatType.Normal);
+ bot.KillMePlease();
+ }
+ return BasicReply("ok");
+ }
+
+
+ }
+}
diff --git a/Core/Commands/DiscordAPI/BulkClear_Messages.cs b/Core/Commands/DiscordAPI/BulkClear_Messages.cs
deleted file mode 100644
index 49bea46..0000000
--- a/Core/Commands/DiscordAPI/BulkClear_Messages.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Linq;
-using OpenMetaverse;
-using Newtonsoft.Json;
-using Discord.WebSocket;
-using Discord;
-using Discord.Rest;
-using System.Threading.Tasks;
-
-namespace BetterSecondBot.Commands.DiscordAPI
-{
- class Discord_BulkClear_Messages : CoreCommand_3arg
- {
- public override string[] ArgTypes { get { return new[] { "Smart", "Number", "Number" }; } }
- public override string[] ArgHints { get { return new[] { "Mixed [Channel|Avatar uuid|Avatar name|http url]", "Discord server id", "Member id" }; } }
- public override string Helpfile { get { return "Clears messages on the server sent by the member in the last 13 days, 22hours 59mins"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (bot.discordReady() == false)
- {
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], bot.getDiscordWhyFailed(), CommandName);
- }
- KeyValuePair reply = ClearMessages(args).Result;
- Dictionary collection = new Dictionary();
- collection.Add("Deleted", reply.Value.ToString());
- return bot.GetCommandsInterface.SmartCommandReply(reply.Key, args[0], "See status for state, see collection for total deleted", CommandName, collection);
- }
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], "incorrect args", CommandName);
- }
-
- protected async Task> ClearMessages(string[] args)
- {
- int messagesDeleted = 0;
- DiscordSocketClient Discord = bot.getDiscordClient();
- if (ulong.TryParse(args[1], out ulong serverid) == true)
- {
- if (ulong.TryParse(args[2], out ulong memberid) == true)
- {
- SocketGuild server = Discord.GetGuild(serverid);
- SocketGuildUser user = server.GetUser(memberid);
- TimeSpan somedays = new TimeSpan(13, 22, 59, 59, 0);
- DateTimeOffset justundertwosweeks = DateTimeOffset.Now;
- justundertwosweeks = justundertwosweeks.Subtract(somedays);
- long unixtimelimit = justundertwosweeks.ToUnixTimeSeconds();
- foreach (SocketTextChannel channel in server.TextChannels)
- {
- List DeleteMessages = new List();
- IEnumerable messages = await channel.GetMessagesAsync(100).FlattenAsync();
- foreach (IMessage message in messages)
- {
- if (message.CreatedAt.ToUnixTimeSeconds() > unixtimelimit)
- {
- if (message.Author.Id == user.Id)
- {
- DeleteMessages.Add(message);
- }
- }
- }
- if(DeleteMessages.Count() > 0)
- {
- messagesDeleted += DeleteMessages.Count();
- await channel.DeleteMessagesAsync(DeleteMessages);
- }
- }
- return new KeyValuePair(true, messagesDeleted);
- }
- }
- return new KeyValuePair(false,0);
- }
- }
-}
diff --git a/Core/Commands/DiscordAPI/Dm_Member.cs b/Core/Commands/DiscordAPI/Dm_Member.cs
deleted file mode 100644
index 7a2e311..0000000
--- a/Core/Commands/DiscordAPI/Dm_Member.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Linq;
-using OpenMetaverse;
-using Newtonsoft.Json;
-using Discord.WebSocket;
-using Discord;
-using Discord.Rest;
-using System.Threading.Tasks;
-
-namespace BetterSecondBot.Commands.DiscordAPI
-{
- class Discord_Dm_Member : CoreCommand_4arg
- {
- public override string[] ArgTypes { get { return new[] { "Smart", "Number", "Number", "Text" }; } }
- public override string[] ArgHints { get { return new[] { "Mixed [Channel|Avatar uuid|Avatar name|http url]", "Server id", "Member id", "Message" }; } }
- public override string Helpfile { get { return "Sends a message directly to the user [They must be in the server]\n This command requires the SERVER MEMBERS INTENT found in discord app dev"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (bot.discordReady() == false)
- {
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], bot.getDiscordWhyFailed(), CommandName);
- }
- bool reply = MessageMember(args).Result;
- return bot.GetCommandsInterface.SmartCommandReply(reply, args[0], "see status for state", CommandName);
- }
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], "incorrect args", CommandName);
- }
-
- protected async Task MessageMember(string[] args)
- {
- DiscordSocketClient Discord = bot.getDiscordClient();
- if (ulong.TryParse(args[1], out ulong serverid) == true)
- {
- if (ulong.TryParse(args[2], out ulong memberid) == true)
- {
- try
- {
- SocketGuild server = Discord.GetGuild(serverid);
- IEnumerable users = await server.GetUsersAsync().FlattenAsync().ConfigureAwait(true);
- bool sent = false;
- foreach(IGuildUser user in users)
- {
- if(user.Id == memberid)
- {
- sent = true;
- await user.SendMessageAsync(args[3]);
- break;
- }
- }
- return sent;
- }
- catch
- {
- return false;
- }
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/DiscordAPI/MembersList.cs b/Core/Commands/DiscordAPI/MembersList.cs
deleted file mode 100644
index a771545..0000000
--- a/Core/Commands/DiscordAPI/MembersList.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Linq;
-using OpenMetaverse;
-using Newtonsoft.Json;
-using Discord.WebSocket;
-using Discord;
-using Discord.Rest;
-using System.Threading.Tasks;
-
-namespace BetterSecondBot.Commands.DiscordAPI
-{
- class Discord_MembersList : CoreCommand_SmartReply_2arg
- {
- public override string[] ArgTypes { get { return new[] { "Smart", "Number" }; } }
- public override string[] ArgHints { get { return new[] { "Mixed [Channel|Avatar uuid|Avatar name|http url]", "Discord server id" }; } }
- public override string Helpfile { get { return "Returns a list of members in a server \n collection is userid: username \n if the user has set a nickname: userid: nickname|username \n This command requires Discord full client mode enabled and connected\n !!!! This command also requires: Privileged Gateway Intents / SERVER MEMBERS INTENT set to true on the discord bot api area !!!"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (bot.discordReady() == false)
- {
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], bot.getDiscordWhyFailed(), CommandName);
- }
- KeyValuePair> reply = ListMembers(args).Result;
- return bot.GetCommandsInterface.SmartCommandReply(reply.Key, args[0], "see status for state", CommandName, reply.Value);
- }
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], "incorrect args", CommandName);
- }
-
- protected async Task>> ListMembers(string[] args)
- {
- DiscordSocketClient Discord = bot.getDiscordClient();
- if (ulong.TryParse(args[1], out ulong serverid) == true)
- {
- SocketGuild server = Discord.GetGuild(serverid);
- IEnumerable users = await server.GetUsersAsync().FlattenAsync().ConfigureAwait(true);
- Dictionary membersList = new Dictionary();
-
- foreach (IGuildUser user in users)
- {
- if (user.Nickname != null)
- {
- membersList.Add(user.Id.ToString(), user.Nickname+"|"+user.Username);
- }
- else
- {
- membersList.Add(user.Id.ToString(), user.Username);
- }
- }
- return new KeyValuePair>(true, membersList);
- }
- return new KeyValuePair>(false, new Dictionary());
- }
- }
-}
diff --git a/Core/Commands/DiscordAPI/MessageChannel.cs b/Core/Commands/DiscordAPI/MessageChannel.cs
deleted file mode 100644
index dd8c1ae..0000000
--- a/Core/Commands/DiscordAPI/MessageChannel.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Linq;
-using OpenMetaverse;
-using Newtonsoft.Json;
-using Discord.WebSocket;
-using Discord;
-using Discord.Rest;
-using System.Threading.Tasks;
-
-namespace BetterSecondBot.Commands.DiscordAPI
-{
- class Discord_MessageChannel : CoreCommand_4arg
- {
- public override string[] ArgTypes { get { return new[] { "Smart", "Number", "Number", "Message", "True|False" }; } }
- public override string[] ArgHints { get { return new[] { "Mixed [Channel|Avatar uuid|Avatar name|http url]", "Discord server id", "channel id", "Message to send", "Use TTS defaults to False" }; } }
- public override string Helpfile { get { return "Sends a message to the selected channel - Optional TTS usage"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (bot.discordReady() == false)
- {
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], bot.getDiscordWhyFailed(), CommandName);
- }
- bool reply = MessageChannel(args).Result;
- return bot.GetCommandsInterface.SmartCommandReply(reply, args[0], "see status for state", CommandName);
- }
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], "incorrect args", CommandName);
- }
-
- protected async Task MessageChannel(string[] args)
- {
- bool useTTS = false;
- if (args.Length == 5)
- {
- bool.TryParse(args[4], out useTTS);
- }
- return await bot.SendMessageToDiscord(args[1], args[2], args[3], useTTS);
- }
- }
-}
diff --git a/Core/Commands/DiscordAPI/MuteMember.cs b/Core/Commands/DiscordAPI/MuteMember.cs
deleted file mode 100644
index 623e576..0000000
--- a/Core/Commands/DiscordAPI/MuteMember.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Linq;
-using OpenMetaverse;
-using Newtonsoft.Json;
-using Discord.WebSocket;
-using Discord;
-using Discord.Rest;
-using System.Threading.Tasks;
-
-namespace BetterSecondBot.Commands.DiscordAPI
-{
- class Discord_MuteMember : CoreCommand_3arg
- {
- public override string[] ArgTypes { get { return new[] { "Smart", "Number", "Number", "True|False" }; } }
- public override string[] ArgHints { get { return new[] { "Mixed [Channel|Avatar uuid|Avatar name|http url]", "Discord server id", "Member id", "{Optional} Mute status (defaults to true) set this to False to unmute" }; } }
- public override string Helpfile { get { return "Updates the Mute status of the member"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (bot.discordReady() == false)
- {
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], bot.getDiscordWhyFailed(), CommandName);
- }
- bool reply = MuteMember(args).Result;
- return bot.GetCommandsInterface.SmartCommandReply(reply, args[0], "see status for state", CommandName);
- }
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], "incorrect args", CommandName);
- }
-
- protected async Task MuteMember(string[] args)
- {
- DiscordSocketClient Discord = bot.getDiscordClient();
- if (ulong.TryParse(args[1], out ulong serverid) == true)
- {
- if (ulong.TryParse(args[2], out ulong memberid) == true)
- {
- SocketGuild server = Discord.GetGuild(serverid);
- SocketGuildUser user = server.GetUser(memberid);
- bool status = true;
- if (args.Length == 4)
- {
- bool.TryParse(args[3], out status);
- }
- await user.ModifyAsync(pr =>
- {
- pr.Mute = status;
- });
- return true;
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/DiscordAPI/RoleCreate.cs b/Core/Commands/DiscordAPI/RoleCreate.cs
deleted file mode 100644
index 7f265cb..0000000
--- a/Core/Commands/DiscordAPI/RoleCreate.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Linq;
-using OpenMetaverse;
-using Newtonsoft.Json;
-using Discord.WebSocket;
-using Discord;
-using Discord.Rest;
-using System.Threading.Tasks;
-
-namespace BetterSecondBot.Commands.DiscordAPI
-{
- class Discord_RoleCreate : CoreCommand_SmartReply_3arg
- {
- public override string[] ArgTypes { get { return new[] { "Smart","Number","Text" }; } }
- public override string[] ArgHints { get { return new[] { "Mixed [Channel|Avatar uuid|Avatar name|http url]","Discord server id","Role name" }; } }
- public override string Helpfile { get { return "Creates a new role and returns its role ID via smart target\n This command requires Discord full client mode enabled and connected"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if(bot.discordReady() == false)
- {
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], bot.getDiscordWhyFailed(), CommandName);
- }
- KeyValuePair reply = CreateRole(args).Result;
- Dictionary collection = new Dictionary();
- collection.Add("roleid", reply.Value.ToString());
- return bot.GetCommandsInterface.SmartCommandReply(true, args[0], "ok", CommandName, collection);
- }
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], "incorrect args", CommandName);
- }
-
- protected async Task> CreateRole(string[] args)
- {
- DiscordSocketClient Discord = bot.getDiscordClient();
- if (ulong.TryParse(args[1], out ulong serverid) == true)
- {
- SocketGuild server = Discord.GetGuild(serverid);
- RestRole role = await server.CreateRoleAsync(args[2], new GuildPermissions(), Color.DarkRed, false, null).ConfigureAwait(true);
- return new KeyValuePair("ok", role.Id);
- }
- return new KeyValuePair("Unable to process server id", 0);
- }
- }
-}
diff --git a/Core/Commands/DiscordAPI/RoleList.cs b/Core/Commands/DiscordAPI/RoleList.cs
deleted file mode 100644
index 3490ce2..0000000
--- a/Core/Commands/DiscordAPI/RoleList.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Linq;
-using OpenMetaverse;
-using Newtonsoft.Json;
-using Discord.WebSocket;
-using Discord;
-using Discord.Rest;
-using System.Threading.Tasks;
-
-namespace BetterSecondBot.Commands.DiscordAPI
-{
- class Discord_RoleList: CoreCommand_SmartReply_2arg
- {
- public override string[] ArgTypes { get { return new[] { "Smart", "Number" }; } }
- public override string[] ArgHints { get { return new[] { "Mixed [Channel|Avatar uuid|Avatar name|http url]", "Discord server id" }; } }
- public override string Helpfile { get { return "Returns a list of roles and their ids in collection \n This command requires Discord full client mode enabled and connected"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (bot.discordReady() == false)
- {
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], bot.getDiscordWhyFailed(), CommandName);
- }
- KeyValuePair> reply = ListRoles(args);
- return bot.GetCommandsInterface.SmartCommandReply(reply.Key, args[0], "see status for state", CommandName, reply.Value);
- }
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], "incorrect args", CommandName);
- }
-
- protected KeyValuePair> ListRoles(string[] args)
- {
- DiscordSocketClient Discord = bot.getDiscordClient();
- if (ulong.TryParse(args[1], out ulong serverid) == true)
- {
- SocketGuild server = Discord.GetGuild(serverid);
- Dictionary rolesList = new Dictionary();
- foreach (SocketRole role in server.Roles)
- {
- rolesList.Add(role.Id.ToString(), role.Name);
- }
- return new KeyValuePair>(true, rolesList);
- }
- return new KeyValuePair>(false,new Dictionary());
- }
- }
-}
diff --git a/Core/Commands/DiscordAPI/RoleRemove.cs b/Core/Commands/DiscordAPI/RoleRemove.cs
deleted file mode 100644
index ad4a3c1..0000000
--- a/Core/Commands/DiscordAPI/RoleRemove.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Linq;
-using OpenMetaverse;
-using Newtonsoft.Json;
-using Discord.WebSocket;
-using Discord;
-using Discord.Rest;
-using System.Threading.Tasks;
-
-namespace BetterSecondBot.Commands.DiscordAPI
-{
- class Discord_RoleRemove: CoreCommand_SmartReply_3arg
- {
- public override string[] ArgTypes { get { return new[] { "Smart", "Number", "Number" }; } }
- public override string[] ArgHints { get { return new[] { "Mixed [Channel|Avatar uuid|Avatar name|http url]", "Discord server id", "Role id" }; } }
- public override string Helpfile { get { return "Remove a new role from a server \n This command requires Discord full client mode enabled and connected"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (bot.discordReady() == false)
- {
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], bot.getDiscordWhyFailed(), CommandName);
- }
- bool status = RemoveRole(args).Result;
- return bot.GetCommandsInterface.SmartCommandReply(status, args[0], "see status for removal state", CommandName);
- }
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], "incorrect args", CommandName);
- }
-
- protected async Task RemoveRole(string[] args)
- {
- DiscordSocketClient Discord = bot.getDiscordClient();
- if (ulong.TryParse(args[1], out ulong serverid) == true)
- {
- if (ulong.TryParse(args[2], out ulong roleid) == true)
- {
- SocketGuild server = Discord.GetGuild(serverid);
- SocketRole role = server.GetRole(roleid);
- await role.DeleteAsync().ConfigureAwait(true);
- return true;
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/DiscordAPI/Role_GetSettings.cs b/Core/Commands/DiscordAPI/Role_GetSettings.cs
deleted file mode 100644
index 4f21e65..0000000
--- a/Core/Commands/DiscordAPI/Role_GetSettings.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Linq;
-using OpenMetaverse;
-using Newtonsoft.Json;
-using Discord.WebSocket;
-using Discord;
-using Discord.Rest;
-using System.Threading.Tasks;
-
-namespace BetterSecondBot.Commands.DiscordAPI
-{
- class Discord_Role_GetSettings : CoreCommand_SmartReply_3arg
- {
- public override string[] ArgTypes { get { return new[] { "Smart", "Number", "Number" }; } }
- public override string[] ArgHints { get { return new[] { "Mixed [Channel|Avatar uuid|Avatar name|http url]", "Discord server id", "Role id" }; } }
- public override string Helpfile { get { return "returns a collection of settings for the given role \n This command requires Discord full client mode enabled and connected"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (bot.discordReady() == false)
- {
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], bot.getDiscordWhyFailed(), CommandName);
- }
- KeyValuePair> reply = RoleSettings(args);
- return bot.GetCommandsInterface.SmartCommandReply(reply.Key, args[0], "see status for state", CommandName,reply.Value);
- }
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], "incorrect args", CommandName);
- }
-
- protected KeyValuePair> RoleSettings(string[] args)
- {
- DiscordSocketClient Discord = bot.getDiscordClient();
- if (ulong.TryParse(args[1], out ulong serverid) == true)
- {
- if (ulong.TryParse(args[2], out ulong roleid) == true)
- {
- SocketGuild server = Discord.GetGuild(serverid);
- SocketRole role = server.GetRole(roleid);
- Dictionary settings = new Dictionary
- {
- { "Config|Color", String.Join(",", new byte[3] { role.Color.R, role.Color.G, role.Color.B }) },
- { "Config|Name", role.Name },
- { "Info|AssignedCount", role.Members.Count().ToString() },
- { "Perm|AttachFiles", role.Permissions.AttachFiles.ToString() },
- { "Perm|ReadMessageHistory", role.Permissions.ReadMessageHistory.ToString() },
- { "Perm|MentionEveryone", role.Permissions.MentionEveryone.ToString() },
- { "Perm|UseExternalEmojis", role.Permissions.UseExternalEmojis.ToString() },
- { "Perm|Connect", role.Permissions.Connect.ToString() },
- { "Perm|Speak", role.Permissions.Speak.ToString() },
- { "Perm|MuteMembers", role.Permissions.MuteMembers.ToString() },
- { "Perm|UseVAD", role.Permissions.UseVAD.ToString() },
- { "Perm|MoveMembers", role.Permissions.MoveMembers.ToString() },
- { "Perm|EmbedLinks", role.Permissions.EmbedLinks.ToString() },
- { "Perm|PrioritySpeaker", role.Permissions.PrioritySpeaker.ToString() },
- { "Perm|Stream", role.Permissions.Stream.ToString() },
- { "Perm|ChangeNickname", role.Permissions.ChangeNickname.ToString() },
- { "Perm|ManageNicknames", role.Permissions.ManageNicknames.ToString() },
- { "Perm|ManageRoles", role.Permissions.ManageRoles.ToString() },
- { "Perm|DeafenMembers", role.Permissions.DeafenMembers.ToString() },
- { "Perm|ManageMessages", role.Permissions.ManageMessages.ToString() },
- { "Perm|ViewChannel", role.Permissions.ViewChannel.ToString() },
- { "Perm|SendMessages", role.Permissions.SendMessages.ToString() },
- { "Perm|CreateInstantInvite", role.Permissions.CreateInstantInvite.ToString() },
- { "Perm|BanMembers", role.Permissions.BanMembers.ToString() },
- { "Perm|SendTTSMessages", role.Permissions.SendTTSMessages.ToString() },
- { "Perm|Administrator", role.Permissions.Administrator.ToString() },
- { "Perm|ManageChannels", role.Permissions.ManageChannels.ToString() },
- { "Perm|KickMembers", role.Permissions.KickMembers.ToString() },
- { "Perm|AddReactions", role.Permissions.AddReactions.ToString() },
- { "Perm|ViewAuditLog", role.Permissions.ViewAuditLog.ToString() },
- { "Perm|ManageWebhooks", role.Permissions.ManageWebhooks.ToString() },
- { "Perm|ManageGuild", role.Permissions.ManageGuild.ToString() },
- { "Perm|ManageEmojis", role.Permissions.ManageEmojis.ToString() }
- };
- return new KeyValuePair>(true, settings);
- }
- }
- return new KeyValuePair>(false, new Dictionary());
- }
- }
-}
diff --git a/Core/Commands/DiscordAPI/Role_UpdatePerms.cs b/Core/Commands/DiscordAPI/Role_UpdatePerms.cs
deleted file mode 100644
index 5e53575..0000000
--- a/Core/Commands/DiscordAPI/Role_UpdatePerms.cs
+++ /dev/null
@@ -1,165 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Linq;
-using OpenMetaverse;
-using Newtonsoft.Json;
-using Discord.WebSocket;
-using Discord;
-using Discord.Rest;
-using System.Threading.Tasks;
-
-namespace BetterSecondBot.Commands.DiscordAPI
-{
- class Discord_Role_UpdatePerms : CoreCommand_4arg
- {
- public override string[] ArgTypes { get { return new[] { "Smart", "Number", "Number","Text" }; } }
- public override string[] ArgHints { get { return new[] { "Mixed [Channel|Avatar uuid|Avatar name|http url]", "Discord server id", "Role id","CSV list of PermFlag=Bool" }; } }
- public override string Helpfile { get { return "Updates perm flags for the selected role \n example CSV format: Speak=True,SendMessages=False \n for a full list of perms see output of DiscordRoleGetSettings \n This command requires Discord full client mode enabled and connected"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (bot.discordReady() == false)
- {
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], bot.getDiscordWhyFailed(), CommandName);
- }
- bool status = UpdateRolePerms(args).Result;
- return bot.GetCommandsInterface.SmartCommandReply(status, args[0], "see status for update state", CommandName);
- }
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], "incorrect args", CommandName);
- }
-
- protected GuildPermissions UpdateFlag(GuildPermissions NewPerms,string flag, bool flagValue)
- {
- switch (flag)
- {
- case "CreateInstantInvite":
- NewPerms = NewPerms.Modify(flagValue);
- break;
- case "KickMembers":
- NewPerms = NewPerms.Modify(null, flagValue);
- break;
- case "BanMembers":
- NewPerms = NewPerms.Modify(null, null, flagValue);
- break;
- case "Administrator":
- NewPerms = NewPerms.Modify(null, null, null, flagValue);
- break;
- case "ManageChannels":
- NewPerms = NewPerms.Modify(null, null, null, null, flagValue);
- break;
- case "ManageGuild":
- NewPerms = NewPerms.Modify(null, null, null, null, null, flagValue);
- break;
- case "AddReactions":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, flagValue);
- break;
- case "ViewAuditLog":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, flagValue);
- break;
- case "SendTTSMessages":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "AttachFiles":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "ReadMessageHistory":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "MentionEveryone":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "UseExternalEmojis":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "Connect":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "Speak":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "MuteMembers":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "UseVAD":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "MoveMembers":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "EmbedLinks":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "PrioritySpeaker":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "Stream":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "ChangeNickname":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "ManageNicknames":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "ManageRoles":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "DeafenMembers":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "ManageMessages":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "ViewChannel":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "SendMessages":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "ManageWebhooks":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- case "ManageEmojis":
- NewPerms = NewPerms.Modify(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, flagValue);
- break;
- default:
- break;
- }
- return NewPerms;
- }
-
- protected async Task UpdateRolePerms(string[] args)
- {
- DiscordSocketClient Discord = bot.getDiscordClient();
- if (ulong.TryParse(args[1], out ulong serverid) == true)
- {
- if (ulong.TryParse(args[2], out ulong roleid) == true)
- {
- SocketGuild server = Discord.GetGuild(serverid);
- SocketRole role = server.GetRole(roleid);
- string[] bits = args[3].Split(',');
- GuildPermissions NewPerms = role.Permissions;
- foreach (String bit in bits)
- {
- string[] subbits = bit.Split('=');
- if(subbits.Length == 2)
- {
- if(bool.TryParse(subbits[1],out bool flagValue) == true)
- {
- NewPerms = UpdateFlag(NewPerms, subbits[0], flagValue);
- }
- }
- }
- await role.ModifyAsync(Rp =>
- {
- Rp.Permissions = NewPerms;
- }).ConfigureAwait(true);
- return true;
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/DiscordAPI/TextChannels_List.cs b/Core/Commands/DiscordAPI/TextChannels_List.cs
deleted file mode 100644
index a18d72c..0000000
--- a/Core/Commands/DiscordAPI/TextChannels_List.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Linq;
-using OpenMetaverse;
-using Newtonsoft.Json;
-using Discord.WebSocket;
-using Discord;
-using Discord.Rest;
-using System.Threading.Tasks;
-
-namespace BetterSecondBot.Commands.DiscordAPI
-{
- class Discord_TextChannels_List : CoreCommand_SmartReply_2arg
- {
- public override string[] ArgTypes { get { return new[] { "Smart", "Number" }; } }
- public override string[] ArgHints { get { return new[] { "Mixed [Channel|Avatar uuid|Avatar name|http url]", "Discord server id" }; } }
- public override string Helpfile { get { return "Returns a list of text channels in a server \n collection is channelid: name"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (bot.discordReady() == false)
- {
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], bot.getDiscordWhyFailed(), CommandName);
- }
- KeyValuePair> reply = ListTextChannels(args);
- return bot.GetCommandsInterface.SmartCommandReply(reply.Key, args[0], "see status for state", CommandName, reply.Value);
- }
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], "incorrect args", CommandName);
- }
-
- protected KeyValuePair> ListTextChannels(string[] args)
- {
- DiscordSocketClient Discord = bot.getDiscordClient();
- if (ulong.TryParse(args[1], out ulong serverid) == true)
- {
- SocketGuild server = Discord.GetGuild(serverid);
- Dictionary textChannels = new Dictionary();
- foreach(SocketTextChannel channel in server.TextChannels)
- {
- textChannels.Add(channel.Id.ToString(), channel.Name);
- }
- return new KeyValuePair>(true, textChannels);
- }
- return new KeyValuePair>(false, new Dictionary());
- }
- }
-}
diff --git a/Core/Commands/Estate/EstateParcelReclaim.cs b/Core/Commands/Estate/EstateParcelReclaim.cs
deleted file mode 100644
index 47a8e4e..0000000
--- a/Core/Commands/Estate/EstateParcelReclaim.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-namespace BetterSecondBot.Commands.Estate
-{
- public class EstateParcelReclaim : CoreCommand
- {
- public override string Helpfile { get { return "Reclaims ownership of the current parcel"; } }
-
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (bot.GetClient.Network.CurrentSim.IsEstateManager == true)
- {
- int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition);
- bot.GetClient.Parcels.Reclaim(bot.GetClient.Network.CurrentSim, localid);
- return true;
- }
- else
- {
- return Failed("Not an estate manager here");
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Estate/GetSimGlobalPos.cs b/Core/Commands/Estate/GetSimGlobalPos.cs
deleted file mode 100644
index 60f007d..0000000
--- a/Core/Commands/Estate/GetSimGlobalPos.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using OpenMetaverse;
-
-namespace BetterSecondBot.Commands.Estate
-{
- public class GetSimGlobalPos : CoreCommand_SmartReply_2arg
- {
- public override string Helpfile { get { return "Fetchs a region and returns its global X,Y"; } }
-
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (bot.GetClient.Grid.GetGridRegion(args[1], GridLayerType.Objects, out GridRegion region))
- {
- collection.Add("X", region.X.ToString());
- collection.Add("Y", region.Y.ToString());
- return bot.GetCommandsInterface.SmartCommandReply(true, args[0], "ok", CommandName,collection);
- }
- else
- {
- return Failed("Unable to find region");
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Estate/GetSimTexture.cs b/Core/Commands/Estate/GetSimTexture.cs
deleted file mode 100644
index de732b1..0000000
--- a/Core/Commands/Estate/GetSimTexture.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using OpenMetaverse;
-
-namespace BetterSecondBot.Commands.Estate
-{
- public class GetSimTexture : CoreCommand_SmartReply_2arg
- {
- public override string Helpfile { get { return "Fetchs a region and returns its tile texture UUID - Expect this to die at some point!"; } }
-
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (bot.GetClient.Grid.GetGridRegion(args[1], GridLayerType.Objects, out GridRegion region))
- {
- return bot.GetCommandsInterface.SmartCommandReply(true, args[0], region.MapImageID.ToString(),CommandName);
- }
- else
- {
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], "Unable to find region", CommandName);
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Estate/SimMessage.cs b/Core/Commands/Estate/SimMessage.cs
deleted file mode 100644
index 2083466..0000000
--- a/Core/Commands/Estate/SimMessage.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-namespace BetterSecondBot.Commands.Estate
-{
- public class SimMessage : CoreCommand_1arg
- {
- public override string[] ArgTypes { get { return new[] { "Text" }; } }
- public override string[] ArgHints { get { return new[] { "Message to send" }; } }
- public override string Helpfile { get { return "Sends the message [ARG 1] to the current sim"; } }
-
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (bot.GetClient.Network.CurrentSim.IsEstateManager == true)
- {
- bot.GetClient.Estate.SimulatorMessage(args[0]);
- return true;
- }
- else
- {
- return Failed("Not an estate manager here");
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Estate/SimRestart.cs b/Core/Commands/Estate/SimRestart.cs
deleted file mode 100644
index 86471ad..0000000
--- a/Core/Commands/Estate/SimRestart.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-namespace BetterSecondBot.Commands.Estate
-{
- public class SimRestart : CoreCommand_1arg
- {
- public override string[] ArgTypes { get { return new[] { "True|False","Number" }; } }
- public override string[] ArgHints { get { return new[] { "Restart mode: True=Restart sim,False=Cancel restart","delay in secs to restart (Min 30 - max 240) defaults to 60 if not given" }; } }
- public override string Helpfile { get { return "Sends the message [ARG 1] to the current sim"; } }
-
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (bot.GetClient.Network.CurrentSim.IsEstateManager == true)
- {
-
- if(bool.TryParse(args[0],out bool mode) == true)
- {
- if(mode == false)
- {
- bot.GetClient.Estate.CancelRestart();
- }
- else
- {
- int delay_restart = 60;
- if(args.Length == 2)
- {
- int.TryParse(args[1], out delay_restart);
- }
- bot.GetClient.Estate.RestartRegion(delay_restart);
- }
- }
- else
- {
- return Failed("True or False request for arg 1");
- }
- }
- else
- {
- return Failed("Not an estate manager here");
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Friends/FriendFullPerms.cs b/Core/Commands/Friends/FriendFullPerms.cs
deleted file mode 100644
index 9c4c5a6..0000000
--- a/Core/Commands/Friends/FriendFullPerms.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System;
-using OpenMetaverse;
-namespace BetterSecondBot.Commands.Friends
-{
- public class FriendFullPerms : CoreCommand_2arg
- {
- public override string[] ArgTypes { get { return new[] { "Avatar","True|False" }; } }
- public override string[] ArgHints { get { return new[] { "Avatar UUID or Firstname Lastname","What status should it be" }; } }
- public override string Helpfile { get { return "Updates the friend perms for avatar [Arg 1] to [Arg 2] (Online/Map/Modify)"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if(UUID.TryParse(args[0],out UUID avatar) == true)
- {
- if(bool.TryParse(args[1],out bool status) == true)
- {
- if (bot.GetClient.Friends.FriendList.ContainsKey(avatar) == true)
- {
- if (status == true)
- {
- bot.GetClient.Friends.GrantRights(avatar, FriendRights.CanSeeOnline | FriendRights.CanSeeOnMap | FriendRights.CanModifyObjects);
- InfoBlob = "Friendship rights granted";
- }
- else
- {
- bot.GetClient.Friends.GrantRights(avatar, FriendRights.None);
- InfoBlob = "Friendship rights removed";
- }
- return true;
- }
- return Failed("Avatar not on friends list or friends list has not updated yet");
- }
- return Failed("Unable to process arg 2");
- }
- return Failed("Unable to process avatar on arg 1");
- }
- return false;
- }
- }
-
-}
diff --git a/Core/Commands/Friends/FriendRequest.cs b/Core/Commands/Friends/FriendRequest.cs
deleted file mode 100644
index f26d34f..0000000
--- a/Core/Commands/Friends/FriendRequest.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System;
-using OpenMetaverse;
-namespace BetterSecondBot.Commands.Friends
-{
- public class FriendRequest : CoreCommand_1arg
- {
- public override string[] ArgTypes { get { return new[] { "Avatar" }; } }
- public override string[] ArgHints { get { return new[] { "Avatar UUID or Firstname Lastname" }; } }
- public override string Helpfile { get { return "sends a friend request to the target avatar"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (UUID.TryParse(args[0], out UUID avatar) == true)
- {
- if (bot.GetClient.Friends.FriendList.ContainsKey(avatar) == false)
- {
- bot.GetClient.Friends.OfferFriendship(avatar);
- }
- return true;
- }
- return Failed("Unable to process avatar on arg 1");
- }
- return false;
- }
- }
-
-}
diff --git a/Core/Commands/Friends/Friendslist.cs b/Core/Commands/Friends/Friendslist.cs
deleted file mode 100644
index cc05419..0000000
--- a/Core/Commands/Friends/Friendslist.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using OpenMetaverse;
-namespace BetterSecondBot.Commands.Friends
-{
- public class Friendslist : CoreCommand_SmartReply_1arg
- {
- public override string Helpfile { get { return "Returns a copy of the friends list"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- return bot.GetCommandsInterface.SmartCommandReply(true, args[0], bot.getJsonFriendlist(), CommandName);
- }
- return false;
- }
- }
-
-}
diff --git a/Core/Commands/Group/GroupActiveGroup.cs b/Core/Commands/Group/GroupActiveGroup.cs
deleted file mode 100644
index 5e9dd2d..0000000
--- a/Core/Commands/Group/GroupActiveGroup.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using OpenMetaverse;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace BetterSecondBot.Commands.Group
-{
- class GroupActiveGroup : CoreCommand_1arg
- {
- public override string[] ArgTypes { get { return new[] { "Group"}; } }
- public override string[] ArgHints { get { return new[] { "Group UUID or Name" }; } }
- public override string Helpfile { get { return "Sets the selected group to the active group"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (UUID.TryParse(args[0], out UUID group_uuid) != true)
- {
- foreach (KeyValuePair G in bot.MyGroups)
- {
- if (G.Value.Name == args[0])
- {
- group_uuid = G.Key;
- break;
- }
- }
- }
- if (group_uuid != UUID.Zero)
- {
- bot.GetClient.Groups.ActivateGroup(group_uuid);
- return true;
- }
- return Failed("Unable to find group");
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Group/GroupActiveTitle.cs b/Core/Commands/Group/GroupActiveTitle.cs
deleted file mode 100644
index 0b5fd6f..0000000
--- a/Core/Commands/Group/GroupActiveTitle.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using OpenMetaverse;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace BetterSecondBot.Commands.Group
-{
- class GroupActiveTitle : CoreCommand_2arg
- {
- public override string[] ArgTypes { get { return new[] { "UUID", "UUID"}; } }
- public override string[] ArgHints { get { return new[] { "UUID of the group","UUID of the role" }; } }
- public override string Helpfile { get { return "Activates the selected title"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if(UUID.TryParse(args[0],out UUID group_uuid) == true)
- {
- if (UUID.TryParse(args[1], out UUID group_role) == true)
- {
- bot.GetClient.Groups.ActivateTitle(group_uuid, group_role);
- return true;
- }
- return Failed("Unable to process group Role on arg 1");
- }
- return Failed("Unable to process group UUID on arg 1");
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Group/GroupAddRole.cs b/Core/Commands/Group/GroupAddRole.cs
deleted file mode 100644
index 092320c..0000000
--- a/Core/Commands/Group/GroupAddRole.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-using System;
-using OpenMetaverse;
-using BetterSecondBotShared.logs;
-
-namespace BetterSecondBot.Commands.Group
-{
- class GroupAddRole : CoreCommand_3arg
- {
- public override string[] ArgTypes { get { return new[] { "UUID", "Avatar", "UUID" }; } }
- public override string[] ArgHints { get { return new[] { "GROUP", "Avatar [UUID or Firstname Lastname]", "Role" }; } }
- public override string Helpfile { get { return "Adds the avatar [ARG 2] to the Group [ARG 1] with the role [ARG 3] if they are not in the group then it invites them"; } }
-
- public override void Callback(string[] args, EventArgs e)
- {
- GroupMembersReplyEventArgs reply = (GroupMembersReplyEventArgs)e;
- if (UUID.TryParse(args[0], out UUID target_group) == true)
- {
- if (reply.GroupID == target_group)
- {
- if (UUID.TryParse(args[1], out UUID target_avatar) == true)
- {
- if (UUID.TryParse(args[2], out UUID target_role) == true)
- {
- if(reply.Members.ContainsKey(target_avatar) == true)
- {
- bot.GetClient.Groups.AddToRole(target_group, target_role, target_avatar);
- InfoBlob = "Role added to avatar: " + target_avatar.ToString() + "";
- base.Callback(args, e, true);
- }
- else
- {
- InfoBlob = "{GroupAddRole} Member not in group to get role, passing to invite";
- bot.GetCommandsInterface.Call("GroupInvite", String.Join("~#~", args), caller, "~#~");
- base.Callback(args, e, true);
- }
-
- }
- else
- {
- InfoBlob = "{ GroupAddRole} Unable to unpack role as part of the callback";
- base.Callback(args, e, false);
- }
- }
- else
- {
- InfoBlob = "{GroupAddRole} Unable to unpack avatar as part of the callback";
- base.Callback(args, e, false);
- }
- }
- else
- {
- InfoBlob = "Callback sent for the wrong group as part of GroupAddRole!";
- base.Callback(args, e, false);
- }
- }
- else
- {
- InfoBlob = "{GroupAddRole} Unable to unpack group as part of the callback";
- base.Callback(args, e, false);
- }
- }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (UUID.TryParse(args[0], out UUID target_group) == true)
- {
- if (UUID.TryParse(args[1], out UUID _) == true)
- {
- if (UUID.TryParse(args[2], out UUID _) == true)
- {
- if (bot.MyGroups.ContainsKey(target_group) == true)
- {
- if (bot.CreateAwaitEventReply("groupmembersreply", this, args) == true)
- {
- bot.GetClient.Groups.RequestGroupMembers(target_group);
- InfoBlob = "Requesting group membership";
- return true;
- }
- else
- {
- return Failed("Unable to await reply");
- }
- }
- else
- {
- return Failed("I am not a member of that group");
- }
- }
- else
- {
- return Failed("Invaild role UUID");
- }
- }
- else
- {
- return Failed("Invaild avatar UUID");
- }
- }
- else
- {
- return Failed("Invaild group UUID");
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Group/GroupEject.cs b/Core/Commands/Group/GroupEject.cs
deleted file mode 100644
index cf521ab..0000000
--- a/Core/Commands/Group/GroupEject.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-using System.Collections.Generic;
-using OpenMetaverse;
-using BetterSecondBotShared.logs;
-
-namespace BetterSecondBot.Commands.Group
-{
- public class GroupEject : CoreCommand_2arg
- {
- public override string[] ArgTypes { get { return new[] { "UUID", "Avatar" }; } }
- public override string[] ArgHints { get { return new[] { "GROUP", "Avatar [UUID or Firstname Lastname]"}; } }
- public override string Helpfile { get { return "Eject selected avatar from group"; } }
-
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (UUID.TryParse(args[0], out UUID target_group) == true)
- {
- if (UUID.TryParse(args[1], out UUID target_avatar) == true)
- {
- if (bot.MyGroups.ContainsKey(target_group) == true)
- {
- bot.GetClient.Groups.EjectUser(target_group, target_avatar);
- return true;
- }
- else
- {
- return Failed("I am not a member of that group");
- }
- }
- else
- {
- return Failed("Invaild avatar UUID");
- }
- }
- else
- {
- return Failed("Invaild group UUID");
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Group/GroupInvite.cs b/Core/Commands/Group/GroupInvite.cs
deleted file mode 100644
index 020480a..0000000
--- a/Core/Commands/Group/GroupInvite.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using System;
-using System.Collections.Generic;
-using OpenMetaverse;
-using BetterSecondBotShared.logs;
-
-namespace BetterSecondBot.Commands.Group
-{
- public class GroupInvite : CoreCommand_2arg
- {
- public override string[] ArgTypes { get { return new[] { "UUID", "Avatar", "UUID" }; } }
- public override string[] ArgHints { get { return new[] { "GROUP", "Avatar [UUID or Firstname Lastname]", "Role" }; } }
- public override string Helpfile { get { return "Invites the avatar [ARG 2] to the Group [ARG 1] {optional with the Role [ARG 3]} otherwise to role Everyone"; } }
-
- protected void ForRealGroupInvite(string[] args,UUID group,UUID avatar)
- {
- UUID target_role = UUID.Zero;
- if (args.Length == 3)
- {
- if(UUID.TryParse(args[2], out target_role) == false)
- {
- LogFormater.Warn("GroupInvite: Role uuid not vaild using everyone");
- }
- }
- bot.GetClient.Groups.Invite(group, new List() { target_role }, avatar);
- }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (UUID.TryParse(args[0], out UUID target_group) == true)
- {
- if (UUID.TryParse(args[1], out UUID target_avatar) == true)
- {
- if (bot.MyGroups.ContainsKey(target_group) == true)
- {
- if (bot.GetAllowGroupInvite(target_avatar, target_group) == true)
- {
- bot.GroupInviteLockoutArm(target_avatar,target_group); // enable 120 sec cooldown
- ForRealGroupInvite(args, target_group, target_avatar);
- return true;
- }
- else
- {
- return Failed("Group invite to this avatar is on 120sec cooldown");
- }
- }
- else
- {
- return Failed("I am not a member of that group");
- }
- }
- else
- {
- return Failed("Invaild avatar UUID");
- }
- }
- else
- {
- return Failed("Invaild group UUID");
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Group/GroupInviteNoLimiter.cs b/Core/Commands/Group/GroupInviteNoLimiter.cs
deleted file mode 100644
index ec4eb55..0000000
--- a/Core/Commands/Group/GroupInviteNoLimiter.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using BetterSecondBotShared.logs;
-using OpenMetaverse;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace BetterSecondBot.Commands.Group
-{
- class GroupInviteNoLimiter: CoreCommand_2arg
- {
- public override string[] ArgTypes { get { return new[] { "UUID", "Avatar", "UUID" }; } }
- public override string[] ArgHints { get { return new[] { "GROUP", "Avatar [UUID or Firstname Lastname]", "Role" }; } }
- public override string Helpfile { get { return "see GroupInvite, note: This command bypasses the limiter use at your own risk!"; } }
-
- protected void ForRealGroupInvite(string[] args, UUID group, UUID avatar)
- {
- UUID target_role = UUID.Zero;
- if (args.Length == 3)
- {
- if (UUID.TryParse(args[2], out target_role) == false)
- {
- LogFormater.Warn("GroupInviteNoLimiter: Role uuid not vaild using everyone");
- }
- }
- bot.GetClient.Groups.Invite(group, new List() { target_role }, avatar);
- }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (UUID.TryParse(args[0], out UUID target_group) == true)
- {
- if (UUID.TryParse(args[1], out UUID target_avatar) == true)
- {
- if (bot.MyGroups.ContainsKey(target_group) == true)
- {
- ForRealGroupInvite(args, target_group, target_avatar);
- return true;
- }
- else
- {
- return Failed("I am not a member of that group");
- }
- }
- else
- {
- return Failed("Invaild avatar UUID");
- }
- }
- else
- {
- return Failed("Invaild group UUID");
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Group/GroupNotice.cs b/Core/Commands/Group/GroupNotice.cs
deleted file mode 100644
index 1341c7d..0000000
--- a/Core/Commands/Group/GroupNotice.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using BetterSecondBotShared.Static;
-using OpenMetaverse;
-
-namespace BetterSecondBot.Commands.Group
-{
- class Groupnotice : CoreCommand_2arg
- {
- public override string[] ArgTypes { get { return new[] { "UUID", "TEXT","TEXT","TEXT" }; } }
- public override string[] ArgHints { get { return new[] { "Group", "Message/Title", "Message","Inventory UUID" }; } }
- public override string Helpfile { get { return "Sends a group notice to [ARG 1] with the message [ARG 2]
if given 3 Args: Sends a group notice to [ARG 1] with the title [ARG 2] and the message [ARG 3]
if [ARG 4] is given then it also sends the notice with an attachment"; } }
- 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)
- {
- string Noticetitle = "GroupNotice@"+ helpers.UnixTimeNow().ToString()+"";
- string Noticemessage = args[1];
- if (args.Length >= 3)
- {
- Noticetitle = args[1];
- Noticemessage = args[2];
- }
- GroupNotice NewNotice = new GroupNotice();
- NewNotice.Subject = Noticetitle;
- NewNotice.Message = Noticemessage;
- NewNotice.OwnerID = bot.GetClient.Self.AgentID;
- if (args.Length == 4)
- {
- if (UUID.TryParse(args[3], out UUID result) == true)
- {
- NewNotice.AttachmentID = result;
- }
- }
- bot.GetClient.Groups.SendGroupNotice(targetgroup, NewNotice);
- return true;
- }
- else
- {
- return Failed("Unkown group");
- }
- }
- else
- {
- return Failed("Invaild UUID");
- }
- }
- return false;
- }
- }
-}
\ No newline at end of file
diff --git a/Core/Commands/Group/IsGroupMember.cs b/Core/Commands/Group/IsGroupMember.cs
deleted file mode 100644
index b98fd93..0000000
--- a/Core/Commands/Group/IsGroupMember.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Newtonsoft.Json;
-using OpenMetaverse;
-
-namespace BetterSecondBot.Commands.Group
-{
- public class IsGroupMember : CoreCommand_3arg
- {
- public override string[] ArgTypes { get { return new[] { "UUID", "Mixed", "Avatar" }; } }
- public override string[] ArgHints { get { return new[] { "Group", "Smart reply [Channel|IM uuid|http url]", "Avatar [UUID or Firstname Lastname]" }; } }
- public override string Helpfile { get { return "Returns if the selected user is in the group or not"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (UUID.TryParse(args[0], out UUID targetgroup) == true)
- {
- if (UUID.TryParse(args[2], out UUID testavatar) == true)
- {
- if (bot.FastCheckInGroup(targetgroup, testavatar) == true)
- {
- Dictionary reply = new Dictionary
- {
- { "group", args[0] },
- { "avatar", args[2] },
- { "ingroup", "1" }
- };
- return bot.GetCommandsInterface.SmartCommandReply(true, args[1], JsonConvert.SerializeObject(reply), CommandName);
- }
- else
- {
- 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("Unable to find avatar");
- }
- }
- else
- {
- return Failed("Invaild UUID");
- }
- }
- return false;
- }
-
- public override void Callback(string[] args, EventArgs e)
- {
- if (UUID.TryParse(args[2], out UUID testavatar) == true)
- {
- GroupMembersReplyEventArgs members_reply = (GroupMembersReplyEventArgs)e;
- string return_status = "0";
- foreach (KeyValuePair data in members_reply.Members)
- {
- if (data.Value.ID == testavatar)
- {
- return_status = "1";
- break;
- }
- }
- Dictionary reply = new Dictionary
- {
- { "group", args[0] },
- { "avatar", args[2] },
- { "ingroup", return_status }
- };
- bot.GetCommandsInterface.SmartCommandReply(true, args[1], JsonConvert.SerializeObject(reply), CommandName);
- }
- base.Callback(args, e);
- }
- }
-}
diff --git a/Core/Commands/Group/getGroupList.cs b/Core/Commands/Group/getGroupList.cs
deleted file mode 100644
index c285e2a..0000000
--- a/Core/Commands/Group/getGroupList.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using OpenMetaverse;
-
-namespace BetterSecondBot.Commands.Group
-{
- public class GetGroupList : CoreGroupCommand_SmartReply_auto
- {
- public override string Helpfile { get { return "Gets a list of groups Json encoded"; } }
- protected override string RunFunction()
- {
- foreach (KeyValuePair groupdata in bot.MyGroups)
- {
- collection.Add(groupdata.Value.Name, groupdata.Key.ToString());
- }
- return "grouplist=loaded";
- }
- }
-}
diff --git a/Core/Commands/Group/getGroupMembers.cs b/Core/Commands/Group/getGroupMembers.cs
deleted file mode 100644
index dce0041..0000000
--- a/Core/Commands/Group/getGroupMembers.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using OpenMetaverse;
-
-namespace BetterSecondBot.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 collection = new Dictionary();
- foreach (KeyValuePair 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);
- }
- }
-}
diff --git a/Core/Commands/Group/getGroupRoles.cs b/Core/Commands/Group/getGroupRoles.cs
deleted file mode 100644
index 379dab0..0000000
--- a/Core/Commands/Group/getGroupRoles.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using OpenMetaverse;
-
-namespace BetterSecondBot.Commands.Group
-{
- public class GetGroupRoles : CoreGroupCommand_SmartReply_Group
- {
- public override string Helpfile { get { return "Gets a list of group roles Json encoded "; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (UUID.TryParse(args[1], out UUID group) == true)
- {
- if (bot.CreateAwaitEventReply("grouproles", this, args) == true)
- {
- InfoBlob = "Requesting now";
- bot.GetClient.Groups.RequestGroupRoles(group);
- return true;
- }
- else
- {
- return Failed("Unable to await reply");
- }
- }
- else
- {
- return Failed("Invaild group UUID");
- }
- }
- return false;
- }
-
- public override void Callback(string[] args, EventArgs e)
- {
- GroupRolesDataReplyEventArgs rolesData = (GroupRolesDataReplyEventArgs)e;
- foreach(KeyValuePair data in rolesData.Roles)
- {
- if (data.Key != UUID.Zero)
- {
- collection.Add(data.Value.Name, data.Value.ID.ToString());
- }
- }
- bot.GetCommandsInterface.SmartCommandReply(true,args[0], "group=" + args[1], CommandName,collection);
- base.Callback(args, e);
- }
- }
-}
diff --git a/Core/Commands/Group/group.cs b/Core/Commands/Group/group.cs
deleted file mode 100644
index 3ab64e6..0000000
--- a/Core/Commands/Group/group.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using OpenMetaverse;
-using System.Collections.Generic;
-
-namespace BetterSecondBot.Commands.Group
-{
- public abstract class CoreGroupCommand_SmartReply_auto : CoreCommand_SmartReply_1arg
- {
- protected virtual string RunFunction()
- {
- return "";
- }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- return bot.GetCommandsInterface.SmartCommandReply(true, args[0], RunFunction(), CommandName, collection);
- }
- return bot.GetCommandsInterface.SmartCommandReply(false, args[0], "", CommandName);
- }
- }
-
- public abstract class CoreGroupCommand_SmartReply_Group : CoreCommand_2arg
- {
- protected Dictionary collection = new Dictionary();
- public override string[] ArgTypes { get { return new[] { "Mixed", "UUID" }; } }
- public override string[] ArgHints { get { return new[] { "Smart reply [Channel|IM uuid|http url]", "Group" }; } }
- }
-
- public abstract class CoreGroupCommand_SmartReply_Group_auto : CoreGroupCommand_SmartReply_Group
- {
- protected virtual string RunFunction(UUID group)
- {
- return "";
- }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (UUID.TryParse(args[1], out UUID targetgroup) == true)
- {
- if (bot.MyGroups.ContainsKey(targetgroup) == true)
- {
- return bot.GetCommandsInterface.SmartCommandReply(true,args[0], RunFunction(targetgroup), CommandName);
- }
- else
- {
- return Failed("Unknown group");
- }
- }
- else
- {
- return Failed("Invaild UUID");
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Group/groupchat.cs b/Core/Commands/Group/groupchat.cs
deleted file mode 100644
index ce3c7bb..0000000
--- a/Core/Commands/Group/groupchat.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using OpenMetaverse;
-using System;
-
-namespace BetterSecondBot.Commands.Group
-{
- class Groupchat : CoreCommand_2arg
- {
- public override string[] ArgTypes { get { return new[] { "UUID","TEXT" }; } }
- public override string[] ArgHints { get { return new[] { "Group","Message" }; } }
- public override string Helpfile { get { return "Sends a message [ARG 2] to the group [ARG 1]"; } }
- 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.GetActiveGroupchatSessions.Contains(targetgroup) == true)
- {
- Callback(args, null);
- return true;
- }
- else
- {
- if (bot.CreateAwaitEventReply("groupchatjoin", this, args) == true)
- {
- bot.GetClient.Self.RequestJoinGroupChat(targetgroup);
- return true;
- }
- else
- {
- return Failed("Unable to await reply");
- }
- }
- }
- else
- {
- return Failed("Unkown group");
- }
- }
- else
- {
- return Failed("Invaild UUID");
- }
- }
- return false;
- }
- public override void Callback(string[] args, EventArgs e)
- {
- if (UUID.TryParse(args[0], out UUID targetgroup) == true)
- {
- bot.GetClient.Self.InstantMessageGroup(targetgroup, args[1]);
- base.Callback(args, e);
- }
- else
- {
- base.Callback(args, e,false);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Core/Commands/Group/groupchatAnyUnread.cs b/Core/Commands/Group/groupchatAnyUnread.cs
deleted file mode 100644
index 2e8451a..0000000
--- a/Core/Commands/Group/groupchatAnyUnread.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace BetterSecondBot.Commands.Group
-{
- class GroupchatAnyUnread : CoreGroupCommand_SmartReply_auto
- {
- public override string Helpfile { get { return "Returns True|False via the smart reply target if there are any unread group ims"; } }
- protected override string RunFunction()
- {
- return "groupchatunread="+bot.HasUnreadGroupchats().ToString();
- }
- }
-}
\ No newline at end of file
diff --git a/Core/Commands/Group/groupchatClearAll.cs b/Core/Commands/Group/groupchatClearAll.cs
deleted file mode 100644
index d9c669d..0000000
--- a/Core/Commands/Group/groupchatClearAll.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-namespace BetterSecondBot.Commands.Group
-{
- class GroupchatClearAll : CoreCommand
- {
- public override string Helpfile { get { return "Clears all group chat buffers at once"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- bot.ClearAllGroupchat();
- return true;
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Group/groupchatGroupHasUnread.cs b/Core/Commands/Group/groupchatGroupHasUnread.cs
deleted file mode 100644
index b83c31b..0000000
--- a/Core/Commands/Group/groupchatGroupHasUnread.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using OpenMetaverse;
-
-namespace BetterSecondBot.Commands.Group
-{
- class GroupchatGroupHasUnread : CoreGroupCommand_SmartReply_Group_auto
- {
- public override string Helpfile { get { return "Returns True|False via the smart reply target if there are any unread group ims for the group [ARG 2]"; } }
-
- protected override string RunFunction(UUID targetgroup)
- {
- return ""+targetgroup.ToString()+"=" + bot.GroupHasUnread(targetgroup).ToString();
- }
-
- }
-}
diff --git a/Core/Commands/Group/groupchatHistory.cs b/Core/Commands/Group/groupchatHistory.cs
deleted file mode 100644
index 22475f4..0000000
--- a/Core/Commands/Group/groupchatHistory.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Linq;
-using Microsoft.VisualBasic.CompilerServices;
-using OpenMetaverse;
-
-namespace BetterSecondBot.Commands.Group
-{
- class GroupchatHistory : CoreGroupCommand_SmartReply_Group_auto
- {
- public override string Helpfile { get { return "Returns the chat history for the selected group [ARG 2] via smart reply [ARG 1]"; } }
- protected override string RunFunction(UUID targetgroup)
- {
- int entry = 1;
- foreach(string A in bot.GetGroupchat(targetgroup))
- {
- collection.Add(entry.ToString(),A);
- entry++;
- }
- return "group="+targetgroup.ToString()+"";
- }
- }
-}
diff --git a/Core/Commands/Group/groupchatListAllUnreadGroups.cs b/Core/Commands/Group/groupchatListAllUnreadGroups.cs
deleted file mode 100644
index 15a8989..0000000
--- a/Core/Commands/Group/groupchatListAllUnreadGroups.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using OpenMetaverse;
-using System.Text;
-
-namespace BetterSecondBot.Commands.Group
-{
- public class GroupchatListAllUnreadGroups : CoreGroupCommand_SmartReply_auto
- {
- public override string Helpfile { get { return "Returns what groups have unread messages "; } }
-
- protected override string RunFunction()
- {
- int entry = 1;
- foreach (UUID group in bot.UnreadGroupchatGroups())
- {
- collection.Add(entry.ToString(),group.ToString());
- entry++;
- }
- return "count="+collection.Count.ToString();
- }
- }
-}
diff --git a/Core/Commands/Home/GoHome.cs b/Core/Commands/Home/GoHome.cs
deleted file mode 100644
index 30fa54a..0000000
--- a/Core/Commands/Home/GoHome.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-namespace BetterSecondBot.Commands.Home
-{
- public class GoHome : CoreCommand
- {
- public override string Helpfile { get { return "Makes the bot teleport to its home region"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- bot.GotoNextHomeRegion();
- return true;
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Home/resetAtHome.cs b/Core/Commands/Home/resetAtHome.cs
deleted file mode 100644
index 947db62..0000000
--- a/Core/Commands/Home/resetAtHome.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-namespace BetterSecondBot.Commands.Home
-{
- public class ResetAtHome : CoreCommand
- {
- public override string Helpfile { get { return "Resets the at home lockouts"; } }
- public override bool CallFunction(string[] args)
- {
- if(base.CallFunction(args) == true)
- {
- bot.ResetAtHome();
- return true;
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Info/Balance.cs b/Core/Commands/Info/Balance.cs
deleted file mode 100644
index 1b08433..0000000
--- a/Core/Commands/Info/Balance.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-namespace BetterSecondBot.Commands.Info
-{
- public class Balance : CoreCommand_SmartReply_1arg
- {
- public override string Helpfile { get { return "Requests the current balance and sends that via the smart reply target and then requests the balance to update."; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (bot.GetAllowFunds == true)
- {
- bool status = bot.GetCommandsInterface.SmartCommandReply(true,args[0], bot.GetClient.Self.Balance.ToString(), CommandName);
- bot.GetClient.Self.RequestBalance();
- return status;
- }
- return bot.GetCommandsInterface.SmartCommandReply(false,args[0], "0", CommandName);
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Info/GetPosition.cs b/Core/Commands/Info/GetPosition.cs
deleted file mode 100644
index e617a63..0000000
--- a/Core/Commands/Info/GetPosition.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace BetterSecondBot.Commands.Info
-{
- public class GetPosition : CoreCommand_SmartReply_1arg
- {
- public override string Helpfile { get { return "Requests the Position and sends that via the smart reply target"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- return bot.GetCommandsInterface.SmartCommandReply(true,args[0], bot.GetClient.Self.RelativePosition.ToString(), CommandName);
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Info/ParcelName.cs b/Core/Commands/Info/ParcelName.cs
deleted file mode 100644
index a4eb654..0000000
--- a/Core/Commands/Info/ParcelName.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-namespace BetterSecondBot.Commands.Info
-{
- public class ParcelName : ParcelCommand_CheckParcel_1arg_smart
- {
- public override string Helpfile { get { return "Fetchs the current parcels name and sends it to the smart reply target on [ARG 1]"; } }
-
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- return bot.GetCommandsInterface.SmartCommandReply(true,args[0], targetparcel.Name, CommandName);
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Info/SimName.cs b/Core/Commands/Info/SimName.cs
deleted file mode 100644
index 3823bc0..0000000
--- a/Core/Commands/Info/SimName.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace BetterSecondBot.Commands.Info
-{
- public class SimName : CoreCommand_SmartReply_1arg
- {
- public override string Helpfile { get { return "Requests the current Sim Position and sends that via the smart reply target"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- return bot.GetCommandsInterface.SmartCommandReply(true,args[0], bot.GetClient.Network.CurrentSim.Name, CommandName);
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Info/UnixTimeNow.cs b/Core/Commands/Info/UnixTimeNow.cs
deleted file mode 100644
index 934eb6b..0000000
--- a/Core/Commands/Info/UnixTimeNow.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using BetterSecondBotShared.Static;
-
-namespace BetterSecondBot.Commands.Info
-{
- public class UnixTimeNow : CoreCommand_SmartReply_1arg
- {
- public override string Helpfile { get { return "Requests the current unixtime at the bot and sends that via the smart reply target"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- return bot.GetCommandsInterface.SmartCommandReply(true,args[0], helpers.UnixTimeNow().ToString(), CommandName);
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Self/CickObject.cs b/Core/Commands/Self/CickObject.cs
deleted file mode 100644
index 286f6a4..0000000
--- a/Core/Commands/Self/CickObject.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Linq;
-using OpenMetaverse;
-
-
-namespace BetterSecondBot.Commands.Self
-{
- public class ClickObject : CoreCommand_1arg
- {
- public override string[] ArgTypes { get { return new[] { "UUID" }; } }
- public override string[] ArgHints { get { return new[] { "Object UUID" }; } }
- public override string Helpfile { get { return "Makes the bot attempt to click a object"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if(UUID.TryParse(args[0],out UUID ObjectUUID) == true)
- {
- Dictionary objectsentrys = bot.GetClient.Network.CurrentSim.ObjectsPrimitives.Copy();
- bool found_object = false;
- foreach (KeyValuePair entry in objectsentrys)
- {
- if(entry.Value.ID == ObjectUUID)
- {
- bot.GetClient.Objects.ClickObject(bot.GetClient.Network.CurrentSim, entry.Key);
- found_object = true;
- break;
- }
- }
- if(found_object == true)
- {
- return true;
- }
- else
- {
- return Failed("Unable to see object");
- }
- }
- else
- {
- return Failed("UUID not vaild");
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Self/Help.cs b/Core/Commands/Self/Help.cs
deleted file mode 100644
index 476bbb1..0000000
--- a/Core/Commands/Self/Help.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-using System.Text;
-using OpenMetaverse;
-
-namespace BetterSecondBot.Commands.Self
-{
- public class Help : CoreCommand
- {
-
- public override string Helpfile { get { return "Basic list of commands"; } }
- public override bool CallFunction(string[] args)
- {
- if (bot.getMaster_uuid != UUID.Zero)
- {
-
- StringBuilder sb = new StringBuilder();
- sb.Append("Second Bot - Basic Command List\n\n");
- sb.Append(bot.GetCommandsInterface.GetCommandHelp("im"));
- sb.Append("\n\n");
- sb.Append(bot.GetCommandsInterface.GetCommandHelp("say"));
- sb.Append("\n\n");
- sb.Append(bot.GetCommandsInterface.GetCommandHelp("botsit"));
- sb.Append("\n\n");
- sb.Append("\nType: 'morehelp' for a full list of commands\n");
- sb.Replace("
", "\n");
- bot.SendIM(bot.getMaster_uuid, sb.ToString());
-
- return true;
- }
- else
- {
- return Failed("UUID is not vaild");
- }
- }
- }
- public class MoreHelp : CoreCommand
- {
-
- public override string Helpfile { get { return "Generates a notecard of all supported commands"; } }
- public override bool CallFunction(string[] args)
- {
- if (bot.getMaster_uuid != UUID.Zero)
- {
-
-
- StringBuilder reply = new StringBuilder();
- reply.Append("Second Bot - Full Command List\n\n");
- foreach (string a in bot.GetCommandsInterface.GetCommandsList())
- {
- reply.Append(a);
- reply.Append("\n");
- reply.Append(bot.GetCommandsInterface.GetCommandHelp(a));
- reply.Append("\n\n");
- }
- reply.Replace("
", "\n");
- reply.Replace("", "");
- reply.Replace("", "\n");
- reply.Replace(" | ", "\n");
- reply.Replace("", "");
- reply.Replace("| ", "");
- reply.Replace(" |
", "");
- reply.Replace("", "");
- reply.Replace("
", " ");
-
- bot.SendNotecard("SecondBot - All Commands", reply.ToString(), bot.getMaster_uuid);
-
- return true;
- }
- else
- {
- return Failed("UUID is not vaild");
- }
- }
- }
-}
diff --git a/Core/Commands/Self/PayObject.cs b/Core/Commands/Self/PayObject.cs
deleted file mode 100644
index 8b49e4b..0000000
--- a/Core/Commands/Self/PayObject.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Linq;
-using OpenMetaverse;
-
-
-namespace BetterSecondBot.Commands.Self
-{
- public class PayObject : CoreCommand_3arg
- {
- public override string[] ArgTypes { get { return new[] { "UUID","Number","Text" }; } }
- public override string[] ArgHints { get { return new[] { "Object UUID","Amount to pay","Object Name" }; } }
- public override string Helpfile { get { return "Makes the bot pay a object"; } }
- public override bool CallFunction(string[] args)
- {
-
- if (base.CallFunction(args) == true)
- {
- if (bot.GetAllowFunds == true)
- {
- if (UUID.TryParse(args[0], out UUID objectuuid) == true)
- {
- if (int.TryParse(args[1], out int amount) == true)
- {
- if (amount > 0)
- {
- if (args[2].Length > 0)
- {
- bot.GetClient.Self.GiveObjectMoney(objectuuid, amount, args[2]);
- return true;
- }
- return Failed("Invaild object name");
- }
- }
- return Failed("Invaild amount");
- }
- return Failed("Invaild object UUID");
- }
- return Failed("Transfer funds to objects disabled");
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Self/botVersion.cs b/Core/Commands/Self/botVersion.cs
deleted file mode 100644
index d7993b0..0000000
--- a/Core/Commands/Self/botVersion.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace BetterSecondBot.Commands.Self
-{
- class BotVersion : CoreCommand_SmartReply_1arg
- {
- public override string Helpfile { get { return "Returns the bots build version"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- return bot.GetCommandsInterface.SmartCommandReply(true,args[0], bot.MyVersion, CommandName);
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Self/logout.cs b/Core/Commands/Self/logout.cs
index 79973af..d80ec02 100644
--- a/Core/Commands/Self/logout.cs
+++ b/Core/Commands/Self/logout.cs
@@ -27,8 +27,7 @@ namespace BetterSecondBot.Commands.Self
public override string Helpfile { get { return "Makes the bot kill itself you monster"; } }
public override bool CallFunction(string[] args)
{
- bot.GetClient.Self.Chat("Laters im out", 0, ChatType.Normal);
- bot.KillMePlease();
+
return true;
}
}
diff --git a/Core/Commands/Self/pointAt.cs b/Core/Commands/Self/pointAt.cs
deleted file mode 100644
index 13b3444..0000000
--- a/Core/Commands/Self/pointAt.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using OpenMetaverse;
-
-namespace BetterSecondBot.Commands.Self
-{
- public class PointAt : CoreCommand_1arg
- {
- public override string[] ArgTypes { get { return new[] { "Avatar" }; } }
- public override string[] ArgHints { get { return new[] { "Avatar [UUID or Firstname Lastname]" }; } }
- public override string Helpfile { get { return "Makes the bot turn to face [ARG 1] and point at them (if found)"; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- if (UUID.TryParse(args[0], out UUID testavatar) == true)
- {
- if (bot.GetClient.Network.CurrentSim.AvatarPositions.ContainsKey(testavatar) == true)
- {
- bot.ResetAnimations();
- bot.GetClient.Self.Stand();
- bot.GetClient.Self.Movement.TurnToward(bot.GetClient.Network.CurrentSim.AvatarPositions[testavatar]);
- bot.GetClient.Self.Movement.SendUpdate();
- bot.GetClient.Self.AnimationStart(Animations.POINT_YOU, true);
- bot.GetClient.Self.PointAtEffect(bot.GetClient.Self.AgentID, testavatar, new Vector3d(0, 0, 0), PointAtType.Select, UUID.Random());
- bot.GetClient.Self.BeamEffect(bot.GetClient.Self.AgentID, testavatar, new Vector3d(0, 0, 2), new Color4(255, 255, 255, 1), (float)3.0, UUID.Random());
- return true;
- }
- else
- {
- return Failed("Cant find UUID in sim");
- }
- }
- else
- {
- return Failed("UUID is not vaild");
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Self/sit.cs b/Core/Commands/Self/sit.cs
deleted file mode 100644
index 6239294..0000000
--- a/Core/Commands/Self/sit.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using OpenMetaverse;
-
-namespace BetterSecondBot.Commands.Self
-{
- public class BotSit : CoreCommand_1arg
- {
- public override string[] ArgTypes { get { return new[] { "Mixed" }; } }
- public override string[] ArgHints { get { return new[] { "Text \"ground\" or a object UUID" }; } }
- public override string Helpfile { get { return "Makes the bot sit on the ground or on a object if it can see it
Example: BOTSIT|||" + UUID.Zero; } }
- public override bool CallFunction(string[] args)
- {
- if (base.CallFunction(args) == true)
- {
- bot.ResetAnimations();
- bot.GetClient.Self.Stand();
- if (args[0] == "ground")
- {
- bot.GetClient.Self.SitOnGround();
- return true;
- }
- else
- {
- if (UUID.TryParse(args[0], out UUID arg_is_uuid) == true)
- {
- bot.GetClient.Self.RequestSit(arg_is_uuid, Vector3.Zero);
- return true;
- }
- else
- {
- return Failed("UUID is not vaild");
- }
- }
- }
- return false;
- }
- }
-}
diff --git a/Core/Commands/Self/stand.cs b/Core/Commands/Self/stand.cs
deleted file mode 100644
index 8fe8a0d..0000000
--- a/Core/Commands/Self/stand.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace BetterSecondBot.Commands.Self
-{
- public class Stand : CoreCommand
- {
- public override string Helpfile { get { return "Makes the bot stand up if sitting (also resets animations)"; } }
- public override bool CallFunction(string[] args)
- {
- bot.GetClient.Self.Stand();
- bot.ResetAnimations();
- return true;
- }
- }
-}
\ No newline at end of file
diff --git a/Core/bottypes/EventsBot.cs b/Core/bottypes/EventsBot.cs
index 62668a4..1977b16 100644
--- a/Core/bottypes/EventsBot.cs
+++ b/Core/bottypes/EventsBot.cs
@@ -250,6 +250,15 @@ namespace BetterSecondBot.bottypes
}
+ public List GetGroupMembers(UUID group)
+ {
+ if (group_members_storage.ContainsKey(group) == false)
+ {
+ return null;
+ }
+ return group_members_storage[group].Value;
+ }
+
public bool FastCheckInGroup(UUID group,UUID avatar)
{
if(NeedReloadGroupData(group) == false)