diff --git a/README.md b/README.md index f4ed0e1..695ee6e 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,51 @@ -A Dragalia Lost bot that gives information on Adventurers and Wyrmprints (Dragons coming soon) +A Dragalia Lost bot that gives information on Adventurers, Dragons, and Wyrmprints ## Requirements - [Python 3.6 or higher](https://www.python.org/) +- [discord.py 0.16.12](https://github.com/Rapptz/discord.py). You can install this by opening a command prompt or terminal window and typing the following: +``` +python -m pip install discord.py==0.16.12 +``` ## Installation -1. Go to the [DiscordApp developers application site](https://discordapp.com/developers/applications) and create a New Application, naming it whatever you wish, noting down the client ID -2. Select Bot on the left hand side, and create a new bot -3. Copy the token of this bot and paste it into the config_example.py for the TOKEN string -4. Visit the URL https://discordapp.com/oauth2/authorize?client_id=CLIENT_IDscope=bot, replacing the CLIENT_ID in the URL to what you noted down in step 1 -5. Choose the server you want to add the bot to and select authorize -6. Set the TOKEN in the config_example.py file that you copied from step 3 in the file -7. Optional: Set the other items in the configuration file (such as the current event, a stream, the help text, picture server, etc) -8. Change the name of the config_example.py -> config.py -9. Run the bot in Python3 through the main.py -``` -python3 main.py +1. Go to the [DiscordApp developers application site](https://discordapp.com/developers/applications) and create a New Application +![Creating the application](https://i.imgur.com/fqe68Zn.gif) +2. Name the application anything you'd like +![Naming the application](https://i.imgur.com/lV71FFb.gif) +3. Note down the Client ID, you can copy this and save it for now +![Saving the client id](https://i.imgur.com/vyebJAi.gif) +4. Select Bot on the left hand side, and create a new bot +![Creating a new bot for the application](https://i.imgur.com/lSAMUAo.gif) +5. Visit the following URL, replacing the CLIENT_ID in it with the client id you copied down in step 3: https://discordapp.com/oauth2/authorize?client_id=CLIENT_IDscope=bot +6. Select the server you want the bot to appear in +![Selecting the server for the bot to appear in](https://i.imgur.com/9zE2CtP.gif) +7. Copy the token from the bot page +![Copying the bot token](https://i.imgur.com/KxaJykR.gif) +8. Set the TOKEN parameter in the config_example.py file that you copied from step 7 in the file +![Setting the bot token](https://imgur.com/M3hS1k5.gif) +9. Change the name of the config_example.py -> config.py +10. Install d +10. Run the bot using the following command in the command prompt or terminal +``` +python main.py +``` + +## Features +Searching for adventurers, dragons, and wyrmprints with the following command: +``` +^(adv|wyr|dra) [name] [level] +``` +Names are not case sensitive. Additionally, if multiple results would be found, they are sorted by release date in descending order. Level is an optional attribute that will list the abilities/skills of the search result. If level=1, then this gives a 0 unbind wyrmprint or dragon. If level=2, then this gives a max unbound wyrmprint or dragon. This only works with wyrmprints and dragons currently. By default the level is set to 2. + +There exists additionally a query function to find adventurers, dragons, or wyrmprints with specific skills, abilities, rarities, element, weapon, etc. +``` +^query type=(adv|wyr|dra) key=value +``` +Key is defined as an attribute (such as element or weapon) where value is the value of the key. Multiple key value pairs can be given. If the value has spaces, surround it with quotes. Below is an example searching for water axe adventurers with the Freeze Res ability. +``` +^query type=adv element=Water ability="Freeze Res" weapon=Axe ``` +Be warned this will return ALL results, and may spam the chat log. Use at your own discretion. ## LICENSE This project is licensed under the [MIT License](https://github.com/eesandoval/NefBot/blob/master/LICENSE). \ No newline at end of file diff --git a/master.db b/master.db index 5222a6c..8f39aa4 100644 Binary files a/master.db and b/master.db differ diff --git a/models/adventurer.py b/models/adventurer.py index 4522ba8..6ee8737 100644 --- a/models/adventurer.py +++ b/models/adventurer.py @@ -67,7 +67,7 @@ def __init__(self, name): def _getAdventurer(self, db): result = db.query(Adventurer.adventurerQueryText, (self.name,)) - if result == None: + if result == None or result == []: return False result = result[0] self.adventurerid = result[0] @@ -113,7 +113,9 @@ def _getAbilities(self, db): INNER JOIN ElementTypes ET ON ET.ElementTypeID = A.ElementTypeID INNER JOIN WeaponTypes WT ON WT.WeaponTypeID = A.WeaponTypeID INNER JOIN UnitTypes UT ON UT.UnitTypeID = A.UnitTypeID - WHERE A.Name = ? COLLATE NOCASE + WHERE A.Name LIKE '%' || ? || '%' COLLATE NOCASE + ORDER BY A.ReleaseDate DESC + LIMIT 1 ''' skillsQueryText = ''' SELECT S.Name diff --git a/models/dragon.py b/models/dragon.py index a002e14..5f520de 100644 --- a/models/dragon.py +++ b/models/dragon.py @@ -44,8 +44,7 @@ def findDragons(element=None, skill=None, ability=None, rarity=None, level=2): fullQuery += "AND D.rarity >= ? " params += (rarity,) if level != None: - fullQuery += "AND DS.level = ? AND DA.level = ? " - params += (level,) + fullQuery += "AND DA.level = ? " params += (level,) if len(params) == 0: return dragons @@ -65,10 +64,11 @@ def __init__(self, name, level): else: self._getSkills(db, level) self._getAbilities(db, level) + self.level = level def _getDragon(self, db): result = db.query(Dragon.dragonQueryText, (self.name,)) - if result == None: + if result == None or result == []: return False result = result[0] self.dragonid = result[0] @@ -82,13 +82,13 @@ def _getDragon(self, db): def _getSkills(self, db, level): self.skills = [] - result = db.query(Dragon.skillsQueryText, (self.dragonid,level)) + result = db.query(Dragon.skillsQueryText, (self.dragonid,)) for skill in map(Skill._make, result): self.skills.append(skill) def _getAbilities(self, db, level): self.abilities = [] - result = db.query(Dragon.abilitiesQueryText, (self.dragonid,level)) + result = db.query(Dragon.abilitiesQueryText, (self.dragonid,level,)) for ability in map(Ability._make, result): self.abilities.append(ability) @@ -96,13 +96,15 @@ def _getAbilities(self, db, level): SELECT D.DragonID , ET.Name AS "ElementTypeName" , D.Rarity - , D.MaxHP - , D.MaxSTR + , D.HP + , D.STR , D.ReleaseDate , D.Name FROM Dragons D INNER JOIN ElementTypes ET ON ET.ElementTypeID = D.ElementTypeID - WHERE D.Name = ? COLLATE NOCASE + WHERE D.Name LIKE '%' || ? || '%' COLLATE NOCASE + ORDER BY D.ReleaseDate DESC + LIMIT 1 ''' abilitiesQueryText = ''' @@ -118,12 +120,14 @@ def _getAbilities(self, db, level): skillsQueryText = ''' SELECT S.Name - , S.Description + , S.SPCost + , S.FrameTime + , S.DescriptionLevel1 + , S.DescriptionLevel2 + , S.DescriptionLevel3 FROM DragonSkills DS INNER JOIN Skills S ON S.SkillID = DS.SkillID WHERE DS.DragonID = ? - AND DS.Level = ? - ORDER BY DS.Slot ASC, DS.Level ASC ''' dragonSearchQueryText = ''' diff --git a/models/wyrmprint.py b/models/wyrmprint.py index 6b5c39b..54eb42f 100644 --- a/models/wyrmprint.py +++ b/models/wyrmprint.py @@ -59,7 +59,7 @@ def __init__(self, name, level=2): def _getWyrmprint(self, db): result = db.query(Wyrmprint.wyrmprintQueryText, (self.name,)) - if result == None: + if result == None or result == []: return False result = result[0] self.wyrmprintid = result[0] @@ -84,7 +84,9 @@ def _getAbilities(self, db, level): , W.ReleaseDate , W.Name FROM Wyrmprints W - WHERE W.Name = ? COLLATE NOCASE + WHERE W.Name LIKE '%' || ? || '%' COLLATE NOCASE + ORDER BY W.ReleaseDate DESC + LIMIT 1 ''' abilitiesQueryText = ''' SELECT A.Name diff --git a/view.py b/view.py index d2f5f0e..340ebf0 100644 --- a/view.py +++ b/view.py @@ -117,12 +117,15 @@ async def showDragon(dragon): e = discord.Embed(title=dragon.name, desc=dragon.name) portraitURL = PICTURE_SERVER + "dragons/portraits/{0}.png".format("%20".join(dragon.name)) e.set_thumbnail(url=portraitURL) - e.add_field(name="Element", value=getEmojiElement(dragon.element), inline=True) + e.add_field(name="Element", value=getEmojiElement(dragon.elementtype), inline=True) e.add_field(name="Rarity", value=getEmojiRarity(dragon.rarity), inline=True) e.add_field(name="Max HP/Max STR", value="{0}/{1}".format(dragon.maxhp, dragon.maxstr), inline=True) e.add_field(name="Release Date", value=getHumanStringDate(dragon.releasedate), inline=True) for skill in dragon.skills: - e.add_field(name="Skill: " + skill.name, value=skill.description, inline=False) + if dragon.level == 1: + e.add_field(name="Skill: " + skill.name, value=skill.descriptionlevel1, inline=False) + else: + e.add_field(name="Skill: " + skill.name, value=skill.descriptionlevel2, inline=False) for ability in dragon.abilities: e.add_field(name="Ability: " + ability.name, value=ability.description, inline=False) await client.send_message(channel, embed=e)