mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Minor website improvements
This commit is contained in:
parent
b7ba25798d
commit
13622d7c65
3 changed files with 27 additions and 18 deletions
2
db.py
2
db.py
|
@ -7,7 +7,7 @@ from sqlalchemy.ext.declarative import declarative_base
|
||||||
from sqlalchemy.orm import sessionmaker, relationship
|
from sqlalchemy.orm import sessionmaker, relationship
|
||||||
from sqlalchemy.ext.hybrid import hybrid_property
|
from sqlalchemy.ext.hybrid import hybrid_property
|
||||||
from sqlalchemy import Column, BigInteger, Integer, String, DateTime, ForeignKey, Float, Enum, create_engine, \
|
from sqlalchemy import Column, BigInteger, Integer, String, DateTime, ForeignKey, Float, Enum, create_engine, \
|
||||||
UniqueConstraint, PrimaryKeyConstraint, Boolean, LargeBinary, Text, Date
|
UniqueConstraint, PrimaryKeyConstraint, Boolean, LargeBinary, Text, Date, func
|
||||||
import requests
|
import requests
|
||||||
from errors import NotFoundError, AlreadyExistingError, PrivateError
|
from errors import NotFoundError, AlreadyExistingError, PrivateError
|
||||||
import re
|
import re
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<span class="player-name">{{ record.royal.username }}</span>
|
<span class="player-name">{{ record.royal.username }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="game-title mysterystatus">
|
<div class="game-title mysterystatus">
|
||||||
Lune ottenute
|
Lune ottenute ad Halloween 2018
|
||||||
</div>
|
</div>
|
||||||
<div class="game-score mysterystatus">
|
<div class="game-score mysterystatus">
|
||||||
{% for index in range(7) %}
|
{% for index in range(7) %}
|
||||||
|
|
41
webserver.py
41
webserver.py
|
@ -7,6 +7,7 @@ import bcrypt
|
||||||
import configparser
|
import configparser
|
||||||
import markdown2
|
import markdown2
|
||||||
import datetime
|
import datetime
|
||||||
|
# noinspection PyPackageRequirements
|
||||||
import telegram
|
import telegram
|
||||||
import query_discord_music
|
import query_discord_music
|
||||||
import random
|
import random
|
||||||
|
@ -187,7 +188,8 @@ def page_editprofile():
|
||||||
profile_data.royal.fiorygi += 1
|
profile_data.royal.fiorygi += 1
|
||||||
try:
|
try:
|
||||||
telegram_bot.send_message(config["Telegram"]["main_group"],
|
telegram_bot.send_message(config["Telegram"]["main_group"],
|
||||||
f'⭐️ {profile_data.royal.username} ha configurato la sua bio su Royalnet e ha ottenuto un fioryg!',
|
f'⭐️ {profile_data.royal.username} ha configurato la sua bio su Royalnet'
|
||||||
|
f' e ha ottenuto un fioryg!',
|
||||||
parse_mode="HTML", disable_web_page_preview=True, disable_notification=True)
|
parse_mode="HTML", disable_web_page_preview=True, disable_notification=True)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
@ -236,7 +238,7 @@ def page_game(name: str):
|
||||||
elif name == "discord":
|
elif name == "discord":
|
||||||
game_name = "Discord"
|
game_name = "Discord"
|
||||||
query = [dict(row) for row in db_session.execute(query_discord_music.all_query)]
|
query = [dict(row) for row in db_session.execute(query_discord_music.all_query)]
|
||||||
elif name == "halloween":
|
elif name == "halloween2018":
|
||||||
game_name = "Rituale di Halloween"
|
game_name = "Rituale di Halloween"
|
||||||
query = db_session.query(db.Halloween).all()
|
query = db_session.query(db.Halloween).all()
|
||||||
else:
|
else:
|
||||||
|
@ -267,12 +269,17 @@ def page_wiki(key: str):
|
||||||
# Embed YouTube videos
|
# Embed YouTube videos
|
||||||
converted_md = markdown2.markdown(wiki_page.content.replace("<", "<"),
|
converted_md = markdown2.markdown(wiki_page.content.replace("<", "<"),
|
||||||
extras=["spoiler", "tables", "smarty-pants", "fenced-code-blocks"])
|
extras=["spoiler", "tables", "smarty-pants", "fenced-code-blocks"])
|
||||||
converted_md = re.sub(r"{https?:\/\/(?:www\.)?(?:youtube\.com\/watch\?.*?&?v=|youtu.be\/)([0-9A-Za-z-]+).*?}",
|
converted_md = re.sub(r"{https?://(?:www\.)?(?:youtube\.com/watch\?.*?&?v=|youtu.be/)([0-9A-Za-z-]+).*?}",
|
||||||
r'<div class="youtube-embed">'
|
r'<div class="youtube-embed">'
|
||||||
r' <iframe src="https://www.youtube-nocookie.com/embed/\1?rel=0&showinfo=0" frameborder="0"'
|
r' <iframe src="https://www.youtube-nocookie.com/embed/\1?rel=0&showinfo=0"'
|
||||||
r' allow="autoplay; encrypted-media" allowfullscreen width="640px" height="320px"></iframe>'
|
r' frameborder="0"'
|
||||||
r'</div>', converted_md)
|
r' allow="autoplay; encrypted-media"'
|
||||||
converted_md = re.sub(r"{https?:\/\/clyp.it\/([a-z0-9]+)}",
|
r' allowfullscreen'
|
||||||
|
r' width="640px"'
|
||||||
|
r' height="320px">'
|
||||||
|
r' </iframe>'
|
||||||
|
r'</div>', converted_md)
|
||||||
|
converted_md = re.sub(r"{https?://clyp.it/([a-z0-9]+)}",
|
||||||
r'<div class="clyp-embed">'
|
r'<div class="clyp-embed">'
|
||||||
r' <iframe width="100%" height="160" src="https://clyp.it/\1/widget" frameborder="0">'
|
r' <iframe width="100%" height="160" src="https://clyp.it/\1/widget" frameborder="0">'
|
||||||
r' </iframe>'
|
r' </iframe>'
|
||||||
|
@ -309,14 +316,15 @@ def page_wiki(key: str):
|
||||||
new_log = db.WikiLog(editor=user, edited_key=key, timestamp=datetime.datetime.now(), reason=edit_reason)
|
new_log = db.WikiLog(editor=user, edited_key=key, timestamp=datetime.datetime.now(), reason=edit_reason)
|
||||||
db_session.add(new_log)
|
db_session.add(new_log)
|
||||||
db_session.commit()
|
db_session.commit()
|
||||||
|
message = f'ℹ️ La pagina wiki <a href="https://ryg.steffo.eu/wiki/{key}">{key}</a> è stata' \
|
||||||
|
f' modificata da' \
|
||||||
|
f' <a href="https://ryg.steffo.eu/profile/{user.username}">{user.username}</a>' \
|
||||||
|
f' {"(" + edit_reason + ")" if edit_reason else ""}' \
|
||||||
|
f' [{"+" if difference > 0 else ""}{difference}]\n'
|
||||||
|
if fioryg_roll > fioryg_chance:
|
||||||
|
message += f"⭐️ {user.username} è stato premiato con 1 fioryg per la modifica!"
|
||||||
try:
|
try:
|
||||||
telegram_bot.send_message(config["Telegram"]["main_group"],
|
telegram_bot.send_message(config["Telegram"]["main_group"], message,
|
||||||
f'ℹ️ La pagina wiki <a href="https://ryg.steffo.eu/wiki/{key}">{key}</a> è stata'
|
|
||||||
f' modificata da'
|
|
||||||
f' <a href="https://ryg.steffo.eu/profile/{user.username}">{user.username}</a>'
|
|
||||||
f' {"(" + edit_reason + ")" if edit_reason else ""}'
|
|
||||||
f' [{"+" if difference > 0 else ""}{difference}]\n'
|
|
||||||
f' {user.username + " è stato premiato con 1 fioryg!" if fioryg_roll > fioryg_chance else ""}',
|
|
||||||
parse_mode="HTML", disable_web_page_preview=True, disable_notification=True)
|
parse_mode="HTML", disable_web_page_preview=True, disable_notification=True)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
@ -416,7 +424,8 @@ def hooks_github():
|
||||||
message = f"🐙 Nuovi aggiornamenti a Royalnet:\n"
|
message = f"🐙 Nuovi aggiornamenti a Royalnet:\n"
|
||||||
for commit in j.get("commits", []):
|
for commit in j.get("commits", []):
|
||||||
if commit["distinct"]:
|
if commit["distinct"]:
|
||||||
message += f'<a href="{commit["url"]}">{commit["message"]}</a> di <b>{commit["author"].get("username", "anonimo")}</b>\n'
|
message += f'<a href="{commit["url"]}">{commit["message"]}</a>' \
|
||||||
|
f' di <b>{commit["author"].get("username", "anonimo")}</b>\n'
|
||||||
telegram_bot.send_message(config["Telegram"]["main_group"], message,
|
telegram_bot.send_message(config["Telegram"]["main_group"], message,
|
||||||
parse_mode="HTML", disable_web_page_preview=True, disable_notification=True)
|
parse_mode="HTML", disable_web_page_preview=True, disable_notification=True)
|
||||||
return "Done."
|
return "Done."
|
||||||
|
|
Loading…
Reference in a new issue