diff --git a/strings.py b/strings.py
index ca522458..6c9a87ff 100644
--- a/strings.py
+++ b/strings.py
@@ -256,3 +256,4 @@ SMECDS = "🤔 Secondo me, è colpa {ds}."
class WIKI:
PAGE_LOCKED = '🔒 La pagina wiki {key} è stata bloccata da {user}.'
PAGE_UNLOCKED = '🔓 La pagina wiki {key} è stata sbloccata da {user}.'
+ PAGE_UPDATED = '📖 La pagina wiki {key} è stata modificata da {user}.\n{reason} [{change}]'
diff --git a/telegrambot.py b/telegrambot.py
index f3720490..7321fe6f 100644
--- a/telegrambot.py
+++ b/telegrambot.py
@@ -2,7 +2,7 @@ import datetime
import random
import typing
import db
-from utils import smecds, cast, errors, emojify
+from utils import smecds, cast, errors, emojify, reply_msg
# python-telegram-bot has a different name
# noinspection PyPackageRequirements
import telegram
@@ -56,13 +56,6 @@ sentry = raven.Client(config["Sentry"]["token"],
hook_libraries=[])
-def reply_msg(bot: telegram.Bot, chat_id: int, string: str, ignore_escaping=False, disable_web_page_preview=True, **kwargs) -> telegram.Message:
- string = strings.safely_format_string(string, ignore_escaping=ignore_escaping, words=kwargs)
- return bot.send_message(chat_id, string,
- parse_mode="HTML",
- disable_web_page_preview=disable_web_page_preview)
-
-
def reply(bot: telegram.Bot, update: telegram.Update, string: str, ignore_escaping=False, disable_web_page_preview=True, **kwargs) -> telegram.Message:
while True:
try:
diff --git a/utils/__init__.py b/utils/__init__.py
index 741ccd25..38bc0ae9 100644
--- a/utils/__init__.py
+++ b/utils/__init__.py
@@ -3,5 +3,6 @@ from .mmstatus import MatchmakingStatus
from .cast import Spell
from .stagismo import smecds
from .emojify import emojify
+from .telegramstuff import reply_msg
-__all__ = ["Dirty", "DirtyDelta", "MatchmakingStatus", "Spell", "smecds", "emojify"]
+__all__ = ["Dirty", "DirtyDelta", "MatchmakingStatus", "Spell", "smecds", "emojify", "reply_msg"]
diff --git a/utils/telegramstuff.py b/utils/telegramstuff.py
new file mode 100644
index 00000000..2cf4aa68
--- /dev/null
+++ b/utils/telegramstuff.py
@@ -0,0 +1,9 @@
+import telegram
+import strings
+
+
+def reply_msg(bot: telegram.Bot, chat_id: int, string: str, ignore_escaping=False, disable_web_page_preview=True, **kwargs) -> telegram.Message:
+ string = strings.safely_format_string(string, ignore_escaping=ignore_escaping, words=kwargs)
+ return bot.send_message(chat_id, string,
+ parse_mode="HTML",
+ disable_web_page_preview=disable_web_page_preview)
diff --git a/webserver.py b/webserver.py
index 685c395e..6c59515f 100644
--- a/webserver.py
+++ b/webserver.py
@@ -15,6 +15,7 @@ import functools
import strings
from sqlalchemy.orm.collections import InstrumentedList
from raven.contrib.flask import Sentry
+from utils import reply_msg
app = Flask(__name__)
@@ -274,28 +275,30 @@ def page_wiki_edit(key: str):
difference = len(new_content) - len(wiki_page.content)
wiki_page.content = new_content
# Award fiorygi
- if difference > 50:
- fioryg_chance = -(5000/difference) + 100
- fioryg_roll = random.randrange(0, 100)
- if fioryg_roll > fioryg_chance:
- fl_g.user.fiorygi += 1
+ if difference > 500:
+ fiorygi = difference // 500
+ fiorygi_word = "fioryg" + ("i" if fiorygi != 1 else "")
+ fl_g.user.fiorygi += fiorygi
else:
- fioryg_chance = -1
- fioryg_roll = -2
+ fiorygi = 0
+ fiorygi_word = ""
edit_reason = request.form.get("reason")
new_log = db.WikiLog(editor=fl_g.user, edited_key=key, timestamp=datetime.datetime.now(), reason=edit_reason)
fl_g.session.add(new_log)
fl_g.session.commit()
- message = f'ℹ️ La pagina wiki {key} è stata' \
- f' modificata da' \
- f' {fl_g.user.username}' \
- f' {"(" + edit_reason + ")" if edit_reason else ""}' \
- f' [{"+" if difference > 0 else ""}{difference}]\n'
- if fioryg_roll > fioryg_chance:
- message += f"⭐️ {fl_g.user.username} è stato premiato con 1 fioryg per la modifica!"
try:
- telegram_bot.send_message(config["Telegram"]["main_group"], message,
- parse_mode="HTML", disable_web_page_preview=True, disable_notification=True)
+ reply_msg(telegram_bot, config["Telegram"]["main_group"], strings.WIKI.PAGE_UPDATED,
+ key=key,
+ user=fl_g.user.telegram.mention(),
+ reason=edit_reason,
+ change=f"+{str(difference)}" if difference > 0 else str(difference))
+ if fiorygi > 0:
+ reply_msg(telegram_bot, config["Telegram"]["main_group"], strings.TELEGRAM.FIORYGI_AWARDED,
+ mention=fl_g.user.telegram.mention(),
+ number=fiorygi,
+ fiorygi=fiorygi_word,
+ reason="aver contribuito alla wiki Royal Games")
+
except Exception:
pass
return redirect(url_for("page_wiki", key=key))