Commit 04a19b44 authored by Jens Langhammer's avatar Jens Langhammer

initial commit, add ark cog

parents
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
#Ipython Notebook
.ipynb_checkpoints
\ No newline at end of file
{
"python.pythonPath": "${workspaceFolder}/env/bin/python"
}
\ No newline at end of file
"""discord red-bot ark search"""
import requests
from discord import Embed
from discord.ext import commands
class ARKCog:
"""ARK lookup Cog"""
def __init__(self, bot):
self.bot = bot
@staticmethod
def do_lookup(query: str) -> dict:
"""Run the actual ARK lookup"""
base_url = ("https://odata.intel.com/API/v1_0/Products/Processors()?&$filter="
"substringof(%%27%s%%27,ProductName)&$format=json")
response = requests.get(base_url % query).json()
if not response.get('d'):
return None
return response.get('d')[0]
@commands.command()
async def ark(self, query: str, field_to_return: str = None):
"""This does stuff!"""
cpu_data = ARKCog.do_lookup(query)
if not cpu_data:
await self.bot.say("I couldn't find anything matching `%s`" % query)
return
fields = ['ProductName', 'ClockSpeed', 'ClockSpeedMax', 'CoreCount', 'ThreadCount', 'VTD']
if field_to_return and field_to_return in cpu_data:
fields = [field_to_return]
# Create embedded message
embed = Embed(title="ARK Search Result",
description="Query was `%s`" % query,
color=0x0071c5)
for field in fields:
embed.add_field(name=field, value=cpu_data[field])
await self.bot.say(embed=embed)
def setup(bot):
"""setup"""
bot.add_cog(ARKCog(bot))
{
"AUTHOR": "BeryJu",
"SHORT": "Lookup Info on Intel's ARK Database",
"DESCRIPTION": "Lookup Info on Intel's ARK Database",
"DISABLED": false,
"NAME": "ark",
"TAGS": [
"ark",
"intel",
"search",
"lookup"
],
"INSTALL_MSG": "Usage: `[p]ark <query> <field_to_display>`"
}
\ No newline at end of file
{"NAME": "BeryJu's Cogs",
"AUTHOR" : "BeryJu",
"SHORT": "General purpose cogs",
"DESCRIPTION" : ""
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment