From 587914e45107bbb076d6975c56ad3d96d3515089 Mon Sep 17 00:00:00 2001 From: Matthew Cech Date: Sun, 23 Jun 2019 01:39:17 -0700 Subject: [PATCH] = Iterative step - config reading but improper writing --- assets/config.config | 436 +++++++++++++++++++++++++++++++++ assets/locCommands.config | 371 ++++++++++++++++++++++++++++ src/core/BaseKeyValueFile.java | 86 +++---- src/core/BaseLocFile.java | 5 +- src/core/CommandEnabler.java | 56 ++--- src/core/Config.java | 113 +++++++-- src/core/Constants.java | 1 + src/core/IConfigSection.java | 5 +- src/core/LocCommands.java | 20 +- src/core/LocStrings.java | 22 +- src/main/Main.java | 2 +- 11 files changed, 981 insertions(+), 136 deletions(-) create mode 100644 assets/config.config diff --git a/assets/config.config b/assets/config.config new file mode 100644 index 0000000..892e290 --- /dev/null +++ b/assets/config.config @@ -0,0 +1,436 @@ +[[Command Management]] +[CommandEnabler] +beans=1 +benchmark, bench=1 +bet=1 +bethistory=1 +blur=1 +boop=1 +buildhelp=1 +c++, g++, cplus, cpp=1 +catch=1 +charactercreate=1 +charactereditbio=1 +charactereditname=1 +characterediturl=1 +choose=1 +color, colour=1 +crouton=1 +dbflush=1 +dbstats=1 +eightball, 8ball=1 +fetch=1 +givebeans=1 +guildroleadd=1 +guildroleallowed=1 +guildrolelist=1 +guildrolenotallowed=1 +guildroleremove=1 +help=1 +indicator=1 +info, about=1 +invite=1 +java, jdoodle=1 +leaderboard=1 +map=1 +perish, thenperish=1 +ping=1 +poll=1 +raffleend=1 +rafflejoin=1 +rafflespin=1 +rafflestart=1 +rating=1 +results=1 +role=1 +roll=1 +rpend=1 +rpg=1 +rpstart=1 +searchcharacter=1 +showpoll=1 +shutdown=1 +stats=1 +teey=1 +tony, stark, dontfeelgood, dontfeelsogood=1 +tweet=1 +vote=1 +wolfram=1 +work=1 +yeet=1 + + + +[[Localized Commands]] +[ObjectBuilderFactory] +indicator= +yeet= +guildroleremove= +bethistory= +benchmark, bench= +rating= +poll= +rafflespin= +charactereditURL= +bet= +guildrolelist= +stats= +catch= +color, colour= +guildroleadd= +results= +wolfram= +givebeans= +c++, g++, cplus, cpp= +work= +rpend= +java, jdoodle= +rafflejoin= +guildroleallowed= +leaderboard= +buildHelp= +dbflush= +shutdown= +boop= +tony, stark, dontfeelgood, dontfeelsogood= +role= +raffleend= +ping= +charactereditbio= +roll= +blur= +choose= +rpstart= +guildrolenotallowed= +perish, thenperish= +teey= +searchcharacter= +dbstats= +rafflestart= +beans= +eightball, 8ball= +vote= +map= +info, about= +showpoll= +rpg= +tweet= +charactercreate= +help= +charactereditname= +fetch= +crouton= +invite= + + + +[[Localized Strings]] +[CommandBenchmark] +BenchmarkInfo=Allows you to lookup PC component benchmarks from UserBenchmark! You can use `bench find ` to see what's in the database, `bench info ` to look at a specific component, or the experimental `bench compare` commands! +BenchmarkInvalid=The benchmark operation you were trying to perform was invalid! + +[CommandPollManage] +PollManageInfo='start' will start a new poll with the query of the line you put after, 'choice' will add a choice to the poll, 'stop' will end the poll + +[CommandGuildRoleNotAllowed] +GuildRoleNotAllowedFailure= +GuildRoleNotAllowedSuccess= +GuildRoleNotAllowedInfo= + +[CommandBetHistory] +BetHistoryOutput=Kitty has %s beans! +BetHistoryInfo=Sees the amount of beans Kitty has earned through your bets! + +[CommandCatch] +CatchInfo=Play catch with yourself or with a friend with @! + +[CommandLeaderboard] +LeaderboardInfo=Shows you the 10 users with the most beans on the server +LeaderboardTitle=Server Leaderboard + +[CommandGuildRoleList] +GuildRoleListOutput=The allowed roles are %s! +GuildRoleListEmpty=There are no roles allowed! +GuildRoleListInfo=Outputs a list of the roles you are allowed to add to yourself! + +[CommandRoll] +RollError=Didn't work ;3; +RollInfo=Based on input of xdy where x is number of dice and y is faces kitty will roll that amount of dice, display the individual rolls and total + +[CommandGuildRoleAllowed] +GuildRoleAllowedInfo= +GuildRoleAllowedSuccess=Added %s to the allowed roles! +GuildRoleAllowedDuplicate=Can't add the same role twice! + +[CommandStats] +StatsInfo=Displays the actively running KittyBot application information + +[CommandRole] +RoleInfo=Will show the current role you have, Admins can change others roles with input of 'role x @y' with x being blacklist, general, mod, or admin. Blacklist will not allow the user to interact with kitty anymore, general mod and admin will give the user access to those commands. +RoleStandardResponse=Your role is %s +RoleError=You aren't allowed to do that! You must have the KittyRole '%s' or higher! +RoleChanged=Changed %s to role `%s`! +RoleNeededRole=Please enter `general`, `mod`, or `admin`! + +[CommandJDoodle] +JDoodleInfo=Will compile any java code you put in! Supports Java 1.8 +JDoodleError=Please provide some java code to get it compiled! + +[CommandChangeIndicator] +ChangeIndicatorInfo=Changes the command indicator to any single character. By default, it's '!'. If more than one character is provided, the first one is used! +ChangeIndicatorError=Please specify a letter or symbol to use! +ChangeIndicatorChanged=Indicator changed to `%s` + +[CommandPerish] +PerishInfo=Adds a red, 'a n g e r y' overlay to your icon or the icon of a friend you mentioned + +[CommandTradeBeans] +TradeBeanseStealingBeans=Stealing is wrong! *Steals 10 beans from %s* +TradeBeansNoTargetError=You have to give *someone* your beans! +TradeBeansSuccess=%s gave %s %s of their beans! +TradeBeansStealingBeans= +TradeBeansInfo=Gives another person some of your beans! Use is `tradebeans amount @person`! +TradeBeansIntParseError=That's not a real number! +TradeBeansNotEnoughError=You don't have enough beans! + +[CommandPollVote] +PollVoteNotValidNumber=That's not a vaild number! +PollVoteInfo=Vote in a poll with the choice number, won't work if no poll is running, you can't change your vote once you have cast it! Be careful! +PollVoteNoPoll=There is no poll running! +PollVoteAlreadyVoted=You already voted +PollVoteNotValidVote=%s That's not a vaild vote! +PollVoteSuccess=You successfully voted for + +[CommandShutdown] +ShutdownSafe=Shutting down, but first syncing database and finishing current threads. +ShutdownUnsafe=Shutting down and immediately and abandoning all threads without sync. +ShutdownInfo=Stops kitty. `-s` or `safe` as an argument attempts to sync off the database before shutdown. + +[CommandRaffleSpin] +RaffleSpinInfo= +RaffleSpinSuccess=The winner issssssss %s! +RaffleSpinFailure=I can't choose a winner D: + +[CommandRaffleEnd] +RaffleEndSuccess= +RaffleEndInfo= +RaffleEndFailure=I don't think there's one going! + +[CommandCharacterSearch] +CharacterSearchNoCharacterFound=Couldn't find a character with that name or ID! +CharacterSearchMultipleCharacterHeader=I found a couple characters with that name, use `charactersearch UniqueID` with their Unique ID to find them! +CharacterSearchMultipleCharacter=%s is owned by %s. Unique ID is `%s` +CharacterSearchOneCharacter=I found one character with that name! \n Owner: %s | Name: %s | Bio: %s | Ref: <%s> | Unique ID: `%s` +CharacterSearchInfo=Find a character with their name or Unique ID! `charactersearch name` or `charactersearch UniqueID` + +[CommandColor] +ColorNotSearchable=Your color couldn't be parsed! Make sure it's in hex format. Try this! `!color 3F5D54` +ColorInfo=Looks up the provided hex color and outputs it as hex, rgb, hsl, hsv, xyz, and cmyk. Also attempts to name the color, and provies a sample of it! Usage example: `!color #365345` (the # can be omitted) + +[CommandDoWork] +DoWorkFinished=I finished with my work! :D +DoWorkInfo=Occupies a core for a few seconds + +[CommandRPStart] +RPStartInfo=Starts an rp, add people to it by mentioning them! + +[CommandBlurry] +BlurryInfo=Blurs your icon or the icon of a friend you mentioned + +[CommandRating] +RatingInfo='0' is fully sfw (Derpi and e621 searches are disabled), '1' is filtered (kitty auto appends a sfw tag on any searches), '2' is nsfw (any search will go through). Some other words are supported for setting filter as well. +RatingWarning=Warning: NSFW may slip through, images are only based on tags on their respective sites! +RatingChanged=Kittybot content set to +RatingInvalid=Invalid content rating + +[CommandDBStats] +DBStatsInfo= + +[CommandGiveBeans] +GiveBeansNoneMentioned=You didn't mention anyone! +GiveBeansSuccess=Gave %s %s beans! +GiveBeansInvalid=That's not a valid number! +GiveBeansInfo=Gives beans to the mentioned users! + +[CommandPollShow] +PollShowNoPoll=There is no poll running! +PollShowInfo=Will show the current poll running +PollShowPoll=The current poll is `%s`\n +PollShowChoices=And the choices are:\n + +[CommandHelpBuilder] +HelpBuilderInfo=Emit help for all commands as formatted HTML + +[CommandCharacterEditURL] +CharacterEditURLInfo= +CharacterEditURLNotValid= +CharacterEditURLSuccess= +CharacterEditURLNotAuth= +CharacterEditURLIDNotValid= + +[CommandRPG] +RPGInfo=Admin+ command only right now - experimental text RPG! Format is !rpg +RPGInvalid=Invalid RPG Command! + +[CommandFetch] +FetchError=That no picture! +FetchEat=Me eat now *monch %s* +FetchInfo=Throw a custom emote and me bring it back! +FetchCatchRun=*Catches and runs away with %s* +FetchRunAway=*Runs away and doesn't return for a long time* +FetchBringBack=Me gots it! %s +FetchBringBackWrong=Me gots it! %s +FetchStare=*Stares at %s* + +[CommandInfo] +InfoResponse=I'm made by `Rin#8904` and `Reverie Wisp#3703`!\nYou can find more info about me along with a Patreon link to support us and GitHub link for filing bugs https://www.rinsnowmew.com/bot/ +InfoInfo=Provides author info and a link to Kitty's website + +[CommandGuildRoleRemove] +GuildRoleRemoveNotAllowed=You're not allowed to add %s +GuildRoleRemoveFailure=Couldn't remove %s from %s +GuildRoleRemoveSuccess=Removed %s from %s! +GuildRoleRemoveInfo=Removes the role specified! + +[CommandWolfram] +WolframError=Something went wrong! +WolframInfo=Will query wolframalpha with your question and give a full image output of the answer +WolframNoArgs=You need to provide some arguments! + +[CommandMap] +MapInfo=Generates a map! You can pass additional information if you want with the flags `-s -w -h`. If one of the fields isn't provided, its default will be used. Note that adjusting the width and height impacts the map outcomes.\n\n**Defaults**\nDefault Seed: Random,\nDefault Width: 35(max %s),\nDefault Height: 25(max %s)\n\n**Key**\nLand: ˶\nMountain: ▲\nBeach: =\nMarsh: ¥\nLava: # +MapSeed=Seed +MapInvalid=Invalid arguments provided! +MapVersion=Using mapgen v0.1 +MapWidth=Width +MapHeight=Height + +[CommandBeansShow] +BeansShowDisplay=You have %s beans! +BeansShowMentioned=I looked it up and %sbeans! +BeansShowInfo=Displays how many beans you have + +[CommandRaffleStart] +RaffleStartSuccess=Started a raffle with an entrance fee of %s beans! +RaffleStartFailure=There's already a raffle going! +RaffleStart= +RaffleStartInfo= + +[CommandHelp] +HelpInfo=Lets you look up specific commands, or get a link to a list of all commands. +HelpDisplay=You can get help with a specific command by typing `!help command`!\nGeneral Commands: `boop, roll, choose, help, info, vote, results, showpoll, wolfram, cplus, java, beans, role, bet, yeet` + +[CommandCharacterEditBio] +CharacterEditBioSuccess= +CharacterEditBioIDNotValid= +CharacterEditBioNotAuth= +CharacterEditBioInfo= +CharacterEditBioNotValid= + +[CommandTweet] +TweetInfo=Kitty will tweet to her personal twitter account +TweetError=Tweet command failed! + +[CommandGuildRoleAdd] +GuildRoleAddSuccess=Added %s to %s +GuildRoleAddFailure=Failed to add %s to %s +GuildRoleAddNotAllowed=You are not allowed to add %s! +GuildRoleAddInfo=Add a role to yourself! + +[CommandCharacterEditName] +CharacterEditNameInfo= +CharacterEditNameNotValid= +CharacterEditNameIDNotValid= +CharacterEditNameSuccess= +CharacterEditNameNotAuth= + +[CommandColiru] +ColiruError=Please provide some c++ code to attempt to compile! +ColiruInfo=Will try to compile any c++ code you put in! Supports up to C++14 standard, uses g++. + +[CommandStark] +StarkInfo=Snaps your icon or the icon of a friend you mentioned + +[CommandYeet] +YeetInfo=Yeet yourself or yeet a friend with @! + +[CommandCrouton] +CroutonInfo=Crouton + +[CommandCharacterCreate] +CharacterCreateDuplicate=You can't create a character with the same name! +CharacterCreateInfo=Create a character for kitty to hold onto for you! `createcharacter name, shortbio, refURL` +CharacterCreateSuccess=You successfully created a character! +CharacterCreateNullInfo=There's not enough info! + +[CommandTeey] +TeeyInfo=Teey yourself back into existance, or teey a friend with @! + +[CommandBetBeans] +BetBeansLowBet=Please bet with at least 50 beans! +BetBeansInfo=Allows you to bet your beans, set your amount after the command! Warning! House always wins!\nSets of 3 will get 2x, 4 will get 10x, and 5 will get 1000x +BetBeansNotValid=That's not a valid bet! +BetBeansLose=Sorry, you didn't win, try again! +BetBeansNotEnough=You don't have enough beans! +BetBeansWin=You won %s beans! + +[CommandPollResults] +PollResultsResponse=%s people voted for %s `%s` with `%s%` !\n +PollResultsInfo=Will show current results of a poll and percentages of votes per choice + +[CommandRPEnd] +RPEndError=You can't end this RP! +RPEndInfo=Ends RP in channel and gives you a .txt file! +RPEndFileOut=Here's your file! + +[CommandBoop] +BoopPerson=%s booped %s! +BoopInfo=Kitty will react with a counter +BoopStandard=Woah! %s booped me! That's %s total! +BoopMultiple=%s booped several others - %s! + +[CommandPing] +PingResponse=Pong! +PingInfo=Will respond with Pong! + +[CommandChoose] +ChooseChoice=I chooooooose %s! +ChooseOne=I can't choose from *one* thing! +ChooseInfo=With an input of x,y,z where x y and z are all choices, kitty will choose one + +[CommandEightBall] +EightBallYes4=Yes - definitely. +EightBallYes3=Without a doubt. +EightBallYes2=It is decidedly so. +EightBallYes1=It is certain. +EightBallYes8=Outlook good. +EightBallYes7=Most likely. +EightBallYes6=As I see it, yes. +EightBallYes5=You may rely on it. +EightBallMaybe1=Reply hazy, try again. +EightBallMaybe2=Ask again later. +EightBallError=Hmm? You'll need to ask a question! +EightBallMaybe3=Better not tell you now. +EightBallMaybe4=Cannot predict now. +EightBallMaybe5=Concentrate and ask again. +EightBallInfo=Answers a yes or no question! Warning: Kitty can not actually tell the future, she claims no responsibility for any lion mauling, lack of lottery wins, or felony charges. +EightBallNo5=Very doubtful. +EightBallNo3=My sources say no. +EightBallNo4=Outlook not so good. +EightBallNo1=Don't count on it. +EightBallNo2=My reply is no. +EightBallYes9=Yes. +EightBallYes10=Signs point to yes. + +[CommandInvite] +InviteInfo=Provides a direct invite link for KittyBot + +[CommandRaffleJoin] +RaffleJoinFailure=You can't join the raffle ;3; +RaffleJoinInfo= +RaffleJoinSuccess=You joined the raffle! + +[CommandDBFlush] +DBFlushInfo=Takes all objects queued for the database and writes them to the database, then says how many were written. + + diff --git a/assets/locCommands.config b/assets/locCommands.config index 75cb78a..e7de63a 100644 --- a/assets/locCommands.config +++ b/assets/locCommands.config @@ -1,3 +1,65 @@ +[[Command Management]] +[CommandEnabler] +beans=1 +benchmark, bench=1 +bet=1 +bethistory=1 +blur=1 +boop=1 +buildhelp=1 +c++, g++, cplus, cpp=1 +catch=1 +charactercreate=1 +charactereditbio=1 +charactereditname=1 +characterediturl=1 +choose=1 +color, colour=1 +crouton=1 +dbflush=1 +dbstats=1 +eightball, 8ball=1 +fetch=1 +givebeans=1 +guildroleadd=1 +guildroleallowed=1 +guildrolelist=1 +guildrolenotallowed=1 +guildroleremove=1 +help=1 +indicator=1 +info, about=1 +invite=1 +java, jdoodle=1 +leaderboard=1 +map=1 +perish, thenperish=1 +ping=1 +poll=1 +raffleend=1 +rafflejoin=1 +rafflespin=1 +rafflestart=1 +rating=1 +results=1 +role=1 +roll=1 +rpend=1 +rpg=1 +rpstart=1 +searchcharacter=1 +showpoll=1 +shutdown=1 +stats=1 +teey=1 +tony, stark, dontfeelgood, dontfeelsogood=1 +tweet=1 +vote=1 +wolfram=1 +work=1 +yeet=1 + +[[Command Localization]] [ObjectBuilderFactory] indicator= yeet= @@ -58,4 +120,313 @@ fetch= crouton= invite= +[[String Localization]] +[CommandBenchmark] +BenchmarkInfo=Allows you to lookup PC component benchmarks from UserBenchmark! You can use `bench find ` to see what's in the database, `bench info ` to look at a specific component, or the experimental `bench compare` commands! +BenchmarkInvalid=The benchmark operation you were trying to perform was invalid! + +[CommandPollManage] +PollManageInfo='start' will start a new poll with the query of the line you put after, 'choice' will add a choice to the poll, 'stop' will end the poll + +[CommandGuildRoleNotAllowed] +GuildRoleNotAllowedFailure= +GuildRoleNotAllowedSuccess= +GuildRoleNotAllowedInfo= + +[CommandBetHistory] +BetHistoryOutput=Kitty has %s beans! +BetHistoryInfo=Sees the amount of beans Kitty has earned through your bets! + +[CommandCatch] +CatchInfo=Play catch with yourself or with a friend with @! + +[CommandLeaderboard] +LeaderboardInfo=Shows you the 10 users with the most beans on the server +LeaderboardTitle=Server Leaderboard + +[CommandGuildRoleList] +GuildRoleListOutput=The allowed roles are %s! +GuildRoleListEmpty=There are no roles allowed! +GuildRoleListInfo=Outputs a list of the roles you are allowed to add to yourself! + +[CommandRoll] +RollError=Didn't work ;3; +RollInfo=Based on input of xdy where x is number of dice and y is faces kitty will roll that amount of dice, display the individual rolls and total + +[CommandGuildRoleAllowed] +GuildRoleAllowedInfo= +GuildRoleAllowedSuccess=Added %s to the allowed roles! +GuildRoleAllowedDuplicate=Can't add the same role twice! + +[CommandStats] +StatsInfo=Displays the actively running KittyBot application information + +[CommandRole] +RoleInfo=Will show the current role you have, Admins can change others roles with input of 'role x @y' with x being blacklist, general, mod, or admin. Blacklist will not allow the user to interact with kitty anymore, general mod and admin will give the user access to those commands. +RoleStandardResponse=Your role is %s +RoleError=You aren't allowed to do that! You must have the KittyRole '%s' or higher! +RoleChanged=Changed %s to role `%s`! +RoleNeededRole=Please enter `general`, `mod`, or `admin`! + +[CommandJDoodle] +JDoodleInfo=Will compile any java code you put in! Supports Java 1.8 +JDoodleError=Please provide some java code to get it compiled! + +[CommandChangeIndicator] +ChangeIndicatorInfo=Changes the command indicator to any single character. By default, it's '!'. If more than one character is provided, the first one is used! +ChangeIndicatorError=Please specify a letter or symbol to use! +ChangeIndicatorChanged=Indicator changed to `%s` + +[CommandPerish] +PerishInfo=Adds a red, 'a n g e r y' overlay to your icon or the icon of a friend you mentioned + +[CommandTradeBeans] +TradeBeanseStealingBeans=Stealing is wrong! *Steals 10 beans from %s* +TradeBeansNoTargetError=You have to give *someone* your beans! +TradeBeansSuccess=%s gave %s %s of their beans! +TradeBeansStealingBeans= +TradeBeansInfo=Gives another person some of your beans! Use is `tradebeans amount @person`! +TradeBeansIntParseError=That's not a real number! +TradeBeansNotEnoughError=You don't have enough beans! + +[CommandPollVote] +PollVoteNotValidNumber=That's not a vaild number! +PollVoteInfo=Vote in a poll with the choice number, won't work if no poll is running, you can't change your vote once you have cast it! Be careful! +PollVoteNoPoll=There is no poll running! +PollVoteAlreadyVoted=You already voted +PollVoteNotValidVote=%s That's not a vaild vote! +PollVoteSuccess=You successfully voted for + +[CommandShutdown] +ShutdownSafe=Shutting down, but first syncing database and finishing current threads. +ShutdownUnsafe=Shutting down and immediately and abandoning all threads without sync. +ShutdownInfo=Stops kitty. `-s` or `safe` as an argument attempts to sync off the database before shutdown. + +[CommandRaffleSpin] +RaffleSpinInfo= +RaffleSpinSuccess=The winner issssssss %s! +RaffleSpinFailure=I can't choose a winner D: + +[CommandRaffleEnd] +RaffleEndSuccess= +RaffleEndInfo= +RaffleEndFailure=I don't think there's one going! + +[CommandCharacterSearch] +CharacterSearchNoCharacterFound=Couldn't find a character with that name or ID! +CharacterSearchMultipleCharacterHeader=I found a couple characters with that name, use `charactersearch UniqueID` with their Unique ID to find them! +CharacterSearchMultipleCharacter=%s is owned by %s. Unique ID is `%s` +CharacterSearchOneCharacter=I found one character with that name! \n Owner: %s | Name: %s | Bio: %s | Ref: <%s> | Unique ID: `%s` +CharacterSearchInfo=Find a character with their name or Unique ID! `charactersearch name` or `charactersearch UniqueID` + +[CommandColor] +ColorNotSearchable=Your color couldn't be parsed! Make sure it's in hex format. Try this! `!color 3F5D54` +ColorInfo=Looks up the provided hex color and outputs it as hex, rgb, hsl, hsv, xyz, and cmyk. Also attempts to name the color, and provies a sample of it! Usage example: `!color #365345` (the # can be omitted) + +[CommandDoWork] +DoWorkFinished=I finished with my work! :D +DoWorkInfo=Occupies a core for a few seconds + +[CommandRPStart] +RPStartInfo=Starts an rp, add people to it by mentioning them! + +[CommandBlurry] +BlurryInfo=Blurs your icon or the icon of a friend you mentioned + +[CommandRating] +RatingInfo='0' is fully sfw (Derpi and e621 searches are disabled), '1' is filtered (kitty auto appends a sfw tag on any searches), '2' is nsfw (any search will go through). Some other words are supported for setting filter as well. +RatingWarning=Warning: NSFW may slip through, images are only based on tags on their respective sites! +RatingChanged=Kittybot content set to +RatingInvalid=Invalid content rating + +[CommandDBStats] +DBStatsInfo= + +[CommandGiveBeans] +GiveBeansNoneMentioned=You didn't mention anyone! +GiveBeansSuccess=Gave %s %s beans! +GiveBeansInvalid=That's not a valid number! +GiveBeansInfo=Gives beans to the mentioned users! + +[CommandPollShow] +PollShowNoPoll=There is no poll running! +PollShowInfo=Will show the current poll running +PollShowPoll=The current poll is `%s`\n +PollShowChoices=And the choices are:\n + +[CommandHelpBuilder] +HelpBuilderInfo=Emit help for all commands as formatted HTML + +[CommandCharacterEditURL] +CharacterEditURLInfo= +CharacterEditURLNotValid= +CharacterEditURLSuccess= +CharacterEditURLNotAuth= +CharacterEditURLIDNotValid= + +[CommandRPG] +RPGInfo=Admin+ command only right now - experimental text RPG! Format is !rpg +RPGInvalid=Invalid RPG Command! + +[CommandFetch] +FetchError=That no picture! +FetchEat=Me eat now *monch %s* +FetchInfo=Throw a custom emote and me bring it back! +FetchCatchRun=*Catches and runs away with %s* +FetchRunAway=*Runs away and doesn't return for a long time* +FetchBringBack=Me gots it! %s +FetchBringBackWrong=Me gots it! %s +FetchStare=*Stares at %s* + +[CommandInfo] +InfoResponse=I'm made by `Rin#8904` and `Reverie Wisp#3703`!\nYou can find more info about me along with a Patreon link to support us and GitHub link for filing bugs https://www.rinsnowmew.com/bot/ +InfoInfo=Provides author info and a link to Kitty's website + +[CommandGuildRoleRemove] +GuildRoleRemoveNotAllowed=You're not allowed to add %s +GuildRoleRemoveFailure=Couldn't remove %s from %s +GuildRoleRemoveSuccess=Removed %s from %s! +GuildRoleRemoveInfo=Removes the role specified! + +[CommandWolfram] +WolframError=Something went wrong! +WolframInfo=Will query wolframalpha with your question and give a full image output of the answer +WolframNoArgs=You need to provide some arguments! + +[CommandMap] +MapInfo=Generates a map! You can pass additional information if you want with the flags `-s -w -h`. If one of the fields isn't provided, its default will be used. Note that adjusting the width and height impacts the map outcomes.\n\n**Defaults**\nDefault Seed: Random,\nDefault Width: 35(max %s),\nDefault Height: 25(max %s)\n\n**Key**\nLand: ˶\nMountain: ▲\nBeach: =\nMarsh: ¥\nLava: # +MapSeed=Seed +MapInvalid=Invalid arguments provided! +MapVersion=Using mapgen v0.1 +MapWidth=Width +MapHeight=Height + +[CommandBeansShow] +BeansShowDisplay=You have %s beans! +BeansShowMentioned=I looked it up and %sbeans! +BeansShowInfo=Displays how many beans you have + +[CommandRaffleStart] +RaffleStartSuccess=Started a raffle with an entrance fee of %s beans! +RaffleStartFailure=There's already a raffle going! +RaffleStart= +RaffleStartInfo= + +[CommandHelp] +HelpInfo=Lets you look up specific commands, or get a link to a list of all commands. +HelpDisplay=You can get help with a specific command by typing `!help command`!\nGeneral Commands: `boop, roll, choose, help, info, vote, results, showpoll, wolfram, cplus, java, beans, role, bet, yeet` + +[CommandCharacterEditBio] +CharacterEditBioSuccess= +CharacterEditBioIDNotValid= +CharacterEditBioNotAuth= +CharacterEditBioInfo= +CharacterEditBioNotValid= + +[CommandTweet] +TweetInfo=Kitty will tweet to her personal twitter account +TweetError=Tweet command failed! + +[CommandGuildRoleAdd] +GuildRoleAddSuccess=Added %s to %s +GuildRoleAddFailure=Failed to add %s to %s +GuildRoleAddNotAllowed=You are not allowed to add %s! +GuildRoleAddInfo=Add a role to yourself! + +[CommandCharacterEditName] +CharacterEditNameInfo= +CharacterEditNameNotValid= +CharacterEditNameIDNotValid= +CharacterEditNameSuccess= +CharacterEditNameNotAuth= + +[CommandColiru] +ColiruError=Please provide some c++ code to attempt to compile! +ColiruInfo=Will try to compile any c++ code you put in! Supports up to C++14 standard, uses g++. + +[CommandStark] +StarkInfo=Snaps your icon or the icon of a friend you mentioned + +[CommandYeet] +YeetInfo=Yeet yourself or yeet a friend with @! + +[CommandCrouton] +CroutonInfo=Crouton + +[CommandCharacterCreate] +CharacterCreateDuplicate=You can't create a character with the same name! +CharacterCreateInfo=Create a character for kitty to hold onto for you! `createcharacter name, shortbio, refURL` +CharacterCreateSuccess=You successfully created a character! +CharacterCreateNullInfo=There's not enough info! + +[CommandTeey] +TeeyInfo=Teey yourself back into existance, or teey a friend with @! + +[CommandBetBeans] +BetBeansLowBet=Please bet with at least 50 beans! +BetBeansInfo=Allows you to bet your beans, set your amount after the command! Warning! House always wins!\nSets of 3 will get 2x, 4 will get 10x, and 5 will get 1000x +BetBeansNotValid=That's not a valid bet! +BetBeansLose=Sorry, you didn't win, try again! +BetBeansNotEnough=You don't have enough beans! +BetBeansWin=You won %s beans! + +[CommandPollResults] +PollResultsResponse=%s people voted for %s `%s` with `%s%` !\n +PollResultsInfo=Will show current results of a poll and percentages of votes per choice + +[CommandRPEnd] +RPEndError=You can't end this RP! +RPEndInfo=Ends RP in channel and gives you a .txt file! +RPEndFileOut=Here's your file! + +[CommandBoop] +BoopPerson=%s booped %s! +BoopInfo=Kitty will react with a counter +BoopStandard=Woah! %s booped me! That's %s total! +BoopMultiple=%s booped several others - %s! + +[CommandPing] +PingResponse=Pong! +PingInfo=Will respond with Pong! + +[CommandChoose] +ChooseChoice=I chooooooose %s! +ChooseOne=I can't choose from *one* thing! +ChooseInfo=With an input of x,y,z where x y and z are all choices, kitty will choose one + +[CommandEightBall] +EightBallYes4=Yes - definitely. +EightBallYes3=Without a doubt. +EightBallYes2=It is decidedly so. +EightBallYes1=It is certain. +EightBallYes8=Outlook good. +EightBallYes7=Most likely. +EightBallYes6=As I see it, yes. +EightBallYes5=You may rely on it. +EightBallMaybe1=Reply hazy, try again. +EightBallMaybe2=Ask again later. +EightBallError=Hmm? You'll need to ask a question! +EightBallMaybe3=Better not tell you now. +EightBallMaybe4=Cannot predict now. +EightBallMaybe5=Concentrate and ask again. +EightBallInfo=Answers a yes or no question! Warning: Kitty can not actually tell the future, she claims no responsibility for any lion mauling, lack of lottery wins, or felony charges. +EightBallNo5=Very doubtful. +EightBallNo3=My sources say no. +EightBallNo4=Outlook not so good. +EightBallNo1=Don't count on it. +EightBallNo2=My reply is no. +EightBallYes9=Yes. +EightBallYes10=Signs point to yes. + +[CommandInvite] +InviteInfo=Provides a direct invite link for KittyBot + +[CommandRaffleJoin] +RaffleJoinFailure=You can't join the raffle ;3; +RaffleJoinInfo= +RaffleJoinSuccess=You joined the raffle! + +[CommandDBFlush] +DBFlushInfo=Takes all objects queued for the database and writes them to the database, then says how many were written. + diff --git a/src/core/BaseKeyValueFile.java b/src/core/BaseKeyValueFile.java index b2b19bd..b370d99 100644 --- a/src/core/BaseKeyValueFile.java +++ b/src/core/BaseKeyValueFile.java @@ -1,17 +1,10 @@ package core; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; import java.util.List; import java.util.ListIterator; import java.util.function.Consumer; import dataStructures.Pair; -import utils.GlobalLog; -import utils.LogFilter; -import utils.io.FileUtils; public class BaseKeyValueFile { @@ -21,70 +14,55 @@ public class BaseKeyValueFile public static final String pairSplit = "="; public static final char pairSeparator = '\n'; - protected final String filename; protected final String header; // Constructor - public BaseKeyValueFile(String filename) + public BaseKeyValueFile() { - this.filename = filename; this.header = headerStart + this.getClass().getSimpleName() + headerEnd; } // Reads in and calls the specifid function for each keyvalue pair we find - protected void parse(Consumer> keyValueCallback) + protected void parse(String content, Consumer> keyValueCallback) { - File f = new File(filename); - if(f.isFile() && f.canRead()) + content = content.trim(); + String[] lines = content.split("" + pairSeparator); + + for(int i = 0; i < lines.length; ++i) { - String content = FileUtils.readContent(f).trim(); - String[] lines = content.split("" + pairSeparator); + if(lines[i].contains(header)) + continue; - for(int i = 0; i < lines.length; ++i) - { - if(lines[i].contains(header)) - continue; - - String[] pair = lines[i].split(pairSplit); - - if(pair.length < 2) - continue; - - String key = pair[0].trim().toLowerCase(); - String value = pair[1].trim().toLowerCase(); - - keyValueCallback.accept(new Pair(key, value)); - } + String[] pair = lines[i].split(pairSplit); + + if(pair.length < 2) + continue; + + String key = pair[0].trim().toLowerCase(); + String value = pair[1].trim().toLowerCase(); + + keyValueCallback.accept(new Pair(key, value)); } } - - // Writes out a set of keyvalue pairs - protected void write(List> toWrite) + + // Writes the set of keyvalue pairs to a string + protected String write(List> toWrite) { - try + ListIterator> iter = toWrite.listIterator(); + + String outString = ""; + outString += header + pairSeparator; + + while(iter.hasNext()) { - ListIterator> iter = toWrite.listIterator(); + Pair pair = iter.next(); + String key = pair.First.toLowerCase(); + String value = pair.Second.toLowerCase(); - String outString = ""; - outString += header + pairSeparator; - - while(iter.hasNext()) - { - Pair pair = iter.next(); - String key = pair.First.toLowerCase(); - String value = pair.Second.toLowerCase(); - - outString += key + pairSplit + value + pairSeparator; - } - - BufferedWriter writer = new BufferedWriter(new FileWriter(filename)); - writer.write(outString); - writer.close(); - } - catch (IOException e) - { - GlobalLog.error(LogFilter.Core, "Issue writing file " + filename + ": " + e.getMessage()); + outString += key + pairSplit + value + pairSeparator; } + + return outString; } } diff --git a/src/core/BaseLocFile.java b/src/core/BaseLocFile.java index 5750c5c..aeda116 100644 --- a/src/core/BaseLocFile.java +++ b/src/core/BaseLocFile.java @@ -13,9 +13,6 @@ import utils.io.FileUtils; // generates/updates a file externally with all the stub values as keys that are localized. public abstract class BaseLocFile { - // Pre-defined values - public static final String KittySourceDirectory = "./src"; - // Filename public final String functionName; // Example: "Localizer.Stub"; @@ -130,7 +127,7 @@ public abstract class BaseLocFile public void scrapeAll() { ArrayList localizeList = new ArrayList(); - FileUtils.acquireAllFiles(KittySourceDirectory).forEach((path) -> tryStripSpecified(path, localizeList)); + FileUtils.acquireAllFiles(Constants.SourceDirectory).forEach((path) -> tryStripSpecified(path, localizeList)); for(LocInfo toStub : localizeList) stringStore.addKeyValue(toStub.file, toStub.phrase, toStub.phrase); diff --git a/src/core/CommandEnabler.java b/src/core/CommandEnabler.java index 668baae..e8cbe00 100644 --- a/src/core/CommandEnabler.java +++ b/src/core/CommandEnabler.java @@ -19,32 +19,38 @@ public class CommandEnabler extends BaseKeyValueFile implements IConfigSection public static final String enabled = "1"; public static final String disabled = "0"; public static final boolean defaultEnabledState = true; + public static final String HeaderName = "Command Management"; // Local variables private HashMap enabledMap; // Quick lookup private ArrayList keyList; // Tracking ordering for later - private final static String name = Constants.AssetDirectory + "commands.config"; + + public static CommandEnabler instance; // Constructor public CommandEnabler() { - super(name); + super(); - // Create/Init variables - GlobalLog.log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName()); - enabledMap = new HashMap<>(); - keyList = new ArrayList<>(); - - // Startup - readIn(); - getTrackedCommands(); - writeOut(); + if(instance == null) + { + // Create/Init variables + GlobalLog.log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName()); + enabledMap = new HashMap<>(); + keyList = new ArrayList<>(); + + instance = this; + } + else + { + GlobalLog.error(LogFilter.Core, "You can't have two of the following: " + this.getClass().getSimpleName()); + } } // Reads in the config file and parses it, keeping tabs on the order it read things - private void readIn() + private void readIn(String contents) { - parse((pair) ->{ + parse(contents, (pair) ->{ String key = pair.First; String value = pair.Second; @@ -76,7 +82,7 @@ public class CommandEnabler extends BaseKeyValueFile implements IConfigSection } // Write out enabled/disabled file info. - private void writeOut() + private String writeOut() { List> list = new Vector>(); @@ -93,7 +99,7 @@ public class CommandEnabler extends BaseKeyValueFile implements IConfigSection Collections.sort(list, (c1, c2) -> { return c1.First.compareTo(c2.First); }); - write(list); + return write(list); } // Looks up a key to see if it's enabled or not @@ -109,25 +115,17 @@ public class CommandEnabler extends BaseKeyValueFile implements IConfigSection @Override public String getHeader() { - // TODO Auto-generated method stub - return null; + return HeaderName; } @Override - public void preUpdate() { - // TODO Auto-generated method stub - + public void read(String contents) { + getTrackedCommands(); + readIn(contents); } @Override - public void init() { - // TODO Auto-generated method stub - - } - - @Override - public String getContent() { - // TODO Auto-generated method stub - return null; + public String write() { + return writeOut(); } } diff --git a/src/core/Config.java b/src/core/Config.java index a5b2b0d..dbe41d9 100644 --- a/src/core/Config.java +++ b/src/core/Config.java @@ -1,9 +1,10 @@ package core; import java.io.File; +import java.io.FileWriter; import java.io.IOException; +import java.util.HashMap; import java.util.Vector; - import utils.GlobalLog; import utils.LogFilter; import utils.io.FileMonitor; @@ -14,12 +15,7 @@ public class Config private static final String filepath = Constants.AssetDirectory + Constants.ConfigFilename; public static Config instance; - - // Accessable config related things - public LocStrings locStrings; - public LocCommands locCommands; - public CommandEnabler commandEnabler; - + // Private private Vector sections; private FileMonitor monitoredConfigFile; @@ -32,9 +28,9 @@ public class Config sections = new Vector(); // Add all sections - sections.add(new CommandEnabler()); - sections.add(new LocStrings()); sections.add(new LocCommands()); + sections.add(new LocStrings()); + sections.add(new CommandEnabler()); // Read file in and parse everything out performStartup(); @@ -50,13 +46,14 @@ public class Config } } + // Perform startup private void performStartup() { File configFile = new File(filepath); + if(configFile.exists()) { - String configContents = FileUtils.readContent(configFile); - reformConfig(configContents); + reformConfig(configFile); } else { @@ -72,20 +69,104 @@ public class Config } } - private void reformConfig(String fullContents) + public static final String sectionStart = "[["; + public static final String sectionEnd = "]]"; + public static final String headerStart = "["; + public static final String headerEnd = "]"; + public static final String pairSplit = "="; + public static final String pairSeparator = "\n"; + + private void reformConfig(File configFile) { - for(IConfigSection section : sections) + // Read and update + String configContents = FileUtils.readContent(configFile); + readConfigs(configContents); + + // Form updated data as necessary for autogeneration + String output = combineConfigs(); + String path = configFile.getPath(); + + // Write to file. + FileWriter fileWriter; + + try { - // Parse stuff and sections here based on interface + fileWriter = new FileWriter(path); + fileWriter.write(output); + fileWriter.close(); } + catch (IOException e) + { + GlobalLog.error(LogFilter.Core, "Config writing failure."); + GlobalLog.error(LogFilter.Core, e.getMessage()); + } + } + + public void readConfigs(String fullContents) + { + String[] str = fullContents.split(pairSeparator); + HashMap parsedSections = new HashMap(); + + String currentHeader = ""; + for(int i = 0; i < str.length; ++i) + { + String line = str[i].trim(); + if(line.startsWith(sectionStart) && line.endsWith(sectionEnd)) + { + currentHeader = line.substring(sectionStart.length(), line.length() - sectionEnd.length()); + } + else + { + String sectionContents = parsedSections.getOrDefault(currentHeader, ""); + parsedSections.put(currentHeader, sectionContents); + } + } + + for(int i = 0; i < sections.size(); ++i) + { + IConfigSection section = sections.get(i); + String header = section.getHeader(); + String content = parsedSections.getOrDefault(header, null); + + if(content != null) + { + section.read(content); + } + else + { + GlobalLog.warn(LogFilter.Core, "Mismatch during config parsing - expected but did not find " + header); + } + } + } + + public String combineConfigs() + { + String output = ""; + + for(int i = 0; i < sections.size(); ++i) + { + // If not the first section, add spacing! + if(i != 0) + { + for(int spacing = 0; spacing < 3; ++spacing) + { + output += pairSeparator; + } + } + + IConfigSection section = sections.get(i); + output += sectionStart + section.getHeader() + sectionEnd + pairSeparator; + output += section.write() + pairSeparator; + } + + return output; } public void upkeep() { monitoredConfigFile.update((monitoredFile) -> { File configFile = new File(filepath); - String configContents = FileUtils.readContent(configFile); - reformConfig(configContents); + reformConfig(configFile); }); } diff --git a/src/core/Constants.java b/src/core/Constants.java index 9a08828..59d49cf 100644 --- a/src/core/Constants.java +++ b/src/core/Constants.java @@ -8,4 +8,5 @@ public final class Constants public static final Color ColorDefault = new Color(7*16, 8*16, 9*16); // A slate-grey public static final String AssetDirectory = "./assets/"; public static final String ConfigFilename = "config.config"; + public static final String SourceDirectory = "./src"; } diff --git a/src/core/IConfigSection.java b/src/core/IConfigSection.java index a632a67..6df338e 100644 --- a/src/core/IConfigSection.java +++ b/src/core/IConfigSection.java @@ -3,7 +3,6 @@ package core; public abstract interface IConfigSection { public abstract String getHeader(); - public abstract void preUpdate(); - public abstract void init(); - public abstract String getContent(); + public abstract void read(String contents); + public abstract String write(); } diff --git a/src/core/LocCommands.java b/src/core/LocCommands.java index 817b415..b49aca8 100644 --- a/src/core/LocCommands.java +++ b/src/core/LocCommands.java @@ -46,25 +46,17 @@ public class LocCommands extends BaseLocFile implements IConfigSection @Override public String getHeader() { - // TODO Auto-generated method stub - return null; + return HeaderName; } @Override - public void preUpdate() { - // TODO Auto-generated method stub - + public void read(String contents) { + updateLocFromString(contents); + scrapeAll(); } @Override - public void init() { - // TODO Auto-generated method stub - - } - - @Override - public String getContent() { - // TODO Auto-generated method stub - return null; + public String write() { + return super.toString(); } } diff --git a/src/core/LocStrings.java b/src/core/LocStrings.java index 5f9a3f9..fefe1bd 100644 --- a/src/core/LocStrings.java +++ b/src/core/LocStrings.java @@ -8,7 +8,7 @@ import utils.LogFilter; // can then be localized. public class LocStrings extends BaseLocFile implements IConfigSection { - public static final String fileName = Constants.AssetDirectory + "locStrings.config"; + public static final String HeaderName = "Localized Strings"; public static final String function = "LocStrings.stub"; private static LocStrings instance; @@ -42,25 +42,17 @@ public class LocStrings extends BaseLocFile implements IConfigSection @Override public String getHeader() { - // TODO Auto-generated method stub - return null; + return HeaderName; } @Override - public void preUpdate() { - // TODO Auto-generated method stub - + public void read(String contents) { + updateLocFromString(contents); + scrapeAll(); } @Override - public void init() { - // TODO Auto-generated method stub - - } - - @Override - public String getContent() { - // TODO Auto-generated method stub - return null; + public String write() { + return super.toString(); } } \ No newline at end of file diff --git a/src/main/Main.java b/src/main/Main.java index 83be8af..5ec601a 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -49,7 +49,7 @@ public class Main extends ListenerAdapter // Factory startup. The ordering is intentional. GlobalLog.initialize(); databaseManager = ObjectBuilderFactory.constructDatabaseManager(); - commandManager = ObjectBuilderFactory.constructCommandManager(Config.instance.commandEnabler); + commandManager = ObjectBuilderFactory.constructCommandManager(CommandEnabler.instance); // TODO: Untangle this singleton stats = ObjectBuilderFactory.constructStats(commandManager); charManager = new CharacterManager(); rpManager = ObjectBuilderFactory.constructRPManager();