public bool ExecuteCommand(string characterCalling, string command, IEnumerable <string> args, string channel) { command = command.ToLower(); if (DoesCommandExist(command)) { try { var thisType = this.GetType(); var searchedType = typeof(BaseCommand <>); var types = AppDomain.CurrentDomain.GetAssemblies().SelectMany(s => s.GetTypes()).Where(p => IsAssignableToGenericType(p, typeof(BaseCommand <>))); var typeToCreate = types.FirstOrDefault(x => x.Name.Split("`").FirstOrDefault().ToLower() == command.ToLower()); if (typeToCreate != null) { if (this.GetType().BaseType != null && this.GetType().BaseType.IsGenericType&& typeToCreate.IsGenericType) { var genericArgs = this.GetType().BaseType.GenericTypeArguments; typeToCreate = typeToCreate.MakeGenericType(genericArgs); } var instance = Activator.CreateInstance(typeToCreate); instance.GetType().InvokeMember(nameof(BaseCommand <DummyPlugin> .Plugin), BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty, Type.DefaultBinder, instance, new object[] { this }); if (!string.IsNullOrWhiteSpace(channel)) { instance.GetType().InvokeMember(nameof(BaseCommand <DummyPlugin> .ExecuteCommand), BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, Type.DefaultBinder, instance, new object[] { characterCalling, args, channel }); } else { instance.GetType().InvokeMember(nameof(BaseCommand <DummyPlugin> .ExecutePrivateCommand), BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, Type.DefaultBinder, instance, new object[] { characterCalling, args }); } } } catch (Exception ex) { if (FChatClient != null && FChatClient.State != null && FChatClient.State.IsBotReady) { if (ex.InnerException != null) { FChatClient.SendMessageInChannel($"Error: {ex.InnerException.Message}", channel); } else { FChatClient.SendMessageInChannel($"Error: {ex.Message}", channel); } } return(false); } return(true); } return(false); }
private void AutoKickNonShemales(object state) { if (!FChatClient.IsUserAdmin(FChatClient.State.BotCharacterName, Channel)) { return; } var characters = FChatClient.State.GetAllCharactersInChannel(Channel); foreach (var character in characters) { if (character.Gender != FChatSharpLib.Entities.Events.Helpers.GenderEnum.Shemale && !FChatClient.IsSelf(character.Character) && !FChatClient.IsUserAdmin(character.Character, Channel)) { FChatClient.KickUser(character.Character, Channel); } } }
private void JoinRequiredChannels(bool excludeAlreadyJoinedOnes = true) { if (!IsInDebug) { var missingJoinedChannels = Channels.Select(x => x.ToLower()); if (excludeAlreadyJoinedOnes) { missingJoinedChannels = missingJoinedChannels.Except(FChatClient.State.Channels.Select(x => x.ToLower())); } foreach (var missingChannel in missingJoinedChannels) { Console.WriteLine($"Joining channel {missingChannel}"); FChatClient.JoinChannel(missingChannel); } } }
private void PeriodicallyCheckThings(object state) { if (!FChatClient.IsUserAdmin(FChatClient.State.BotCharacterName, Channel)) { return; } var characters = FChatClient.State.GetAllCharactersInChannel(Channel); var newListSubscribedCharacters = SDSWQueryAPI.GetAllCharacters(); var newCharacters = new List <string>(); if (subscribedCharacters.Count != 0) { newCharacters = newListSubscribedCharacters.Except(subscribedCharacters).ToList(); } subscribedCharacters = newListSubscribedCharacters; foreach (var character in characters) { if ((character.Gender != FChatSharpLib.Entities.Events.Helpers.GenderEnum.Shemale || (subscribedCharacters.Count > 0 && !subscribedCharacters.Contains(character.Character))) && !FChatClient.IsSelf(character.Character) && !FChatClient.IsUserAdmin(character.Character, Channel)) { FChatClient.KickUser(character.Character, Channel); FChatClient.SendPrivateMessage("Hello! You've been kicked out from the Shemale DS World ([session=Shemale DS World]adh-ae6c36cf75c40ec6a52a[/session]) channel because you're not an active player of that game.\nIf you'd like to register, please join the OOC room ([session=Shemale DS Game]adh-3c6c8a69c06c14bbf523[/session]) and read the description.\nThank you!", character.Character); } } if (newCharacters.Count == 0 && !isUsingDefaultStatus) { FChatClient.SetStatus(FChatSharpLib.Entities.Events.Helpers.StatusEnum.Looking, $"[color=pink]Come join other bitch-breakers @ [session=Shemale DS Game]adh-3c6c8a69c06c14bbf523[/session]. Read the room's description for instructions on how to join the game.[/color]"); isUsingDefaultStatus = true; } foreach (var character in newCharacters) { FChatClient.SetStatus(FChatSharpLib.Entities.Events.Helpers.StatusEnum.Looking, $"[icon]{character}[/icon] [user]{character}[/user] [color=pink]just joined the game![/color]"); isUsingDefaultStatus = false; } }
private void FChatClient_BotCreatedChannel(object sender, FChatSharpLib.Entities.Events.Server.InitialChannelData e) { FChatClient.ChangeChannelPrivacy(false, e.channel); }
private void FChatClient_UserJoinedChannel(object sender, FChatSharpLib.Entities.Events.Server.JoinChannel e) { FChatClient.SendMessageInChannel($"Hey, {e.character.identity} just joined us!", e.channel); }