Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom YOURLS and MESSAGES.json handling #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
env
.env
.MESSAGES.json
__pycache__/
*.egg-info/
*.egg
*.spec
*.log
*.db
*.sqlite
*.pypackage
*.egg
*.py[co]
*.mo
*.pot
*.env
.tox/
.nox/
.coverage
.cache
nosetests.xml
coverage.xml
*.xml
*.log
*.db
local_settings.py
db.sqlite3
instance
.mypy_cache
7 changes: 5 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@
try:
with open("MESSAGES.json", "r") as f:
MESSAGES = json.load(f)
except (FileNotFoundError, json.JSONDecodeError):
with open("MESSAGES.json", "w") as f:
json.dump({}, f)
except Exception as err:
logger.exception(err)
pass

NSPASS = CONFIG.get("NSPASS")


Expand Down Expand Up @@ -230,7 +233,7 @@ async def postToYourls(params={}):
try:
async with aiohttp.ClientSession() as session:
async with session.get(
"https://therelay.cc/yourls-api.php", params=params
CONFIG.get("YOURLSAPIURL"), params=params
) as resp:
logger.debug(resp.status)
return await resp.json()
Expand Down
2 changes: 2 additions & 0 deletions sample.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
NSPASS="IRC NickServ password goes here"
# Splitkit relay requires the YOURLS URL shortener. https://github.com/YOURLS
YOURLSAPIURL="https://YourSelfHostedYourlsInstance.com/yourls-api.php"
SHORTURL="YOURLS URL shortener API key here"
URL="websocket URL that thesplitkit.com provides"
ADMINS="comma separated list of IRC nicknames to administer the bot"
Expand Down