This commit is contained in:
2024-12-06 14:20:29 +03:00
commit ae115cfbcb
38 changed files with 1178 additions and 0 deletions

22
msg/AdminNotifMsg.py Normal file
View File

@@ -0,0 +1,22 @@
from bot.HtmlMsg import HtmlMsg
class AdminNotifMsg(HtmlMsg):
def get_msg(self, data=None) -> str:
if data is None:
data = {}
cl = ""
recipient = ""
status = ""
if data['admin']['status'] == 2:
cl = "<b>Ссылка:</b> {channel_link}\n".format(channel_link=data['post']['channel_link'])
if 'recipient_respond' in data:
recipient = "Эксперт @{username} откликнулся на вакансию\n".format(username=data['recipient']['username'])
if 'status' in data:
status = "Статус: <b>{status}</b>\n".format(status=data['status'])
ct = "<b>Название:</b> {channel_title}\n".format(channel_title=data['post']['channel_title'])
content = "<b>Текст:</b>\n{content}".format(content=data['post']['content'])
msg = "{recipient}{status}{cl}{ct}{content}".format(cl=cl, ct=ct, content=content, recipient=recipient, status=status)
return self.get_stylized_msg(msg)

22
msg/CryptocurrencyMsg.py Normal file
View File

@@ -0,0 +1,22 @@
from bot.DaMsg import DaMsg
from pycoingecko import CoinGeckoAPI
from bot import config
class CryptocurrencyMsg(DaMsg):
@staticmethod
def get_msg(data=None) -> str:
if data is None:
data = {}
cg = CoinGeckoAPI()
codes = config['CRYPTO_CHARCODES'].split(" ")
res = cg.get_price(ids=codes, vs_currencies=['usd'])
msg = '&#128200; Курс криптовалют на сегодня:\n\n'
for currency in codes:
msg = msg + "<b>" + currency + "</b>: " + str(res[currency]['usd']) + "$\n\n"
msg = msg + "&#128073; <a href='https://t.me/prosmi_bot'>Предложить новость</a>"
return msg

35
msg/ExchangeMsg.py Normal file
View File

@@ -0,0 +1,35 @@
from bot.DaMsg import DaMsg
from exchange.Cbr import Cbr
class ExchangeMsg(DaMsg):
@staticmethod
def get_msg(data=None) -> str:
if data is None:
data = {}
cbr = Cbr()
currencies = cbr.get_by_codes()
msg = '&#128200; Курс валют ЦБ РФ на сегодня:\n\n'
for currency in currencies:
circle = ExchangeMsg.get_circle(currency['Value'], currency['Previous'])
arrow = ExchangeMsg.get_arrow(currency['Value'], currency['Previous'])
msg = msg + "{n}: {c} <b>{v}</b> {a}\n\n".format(n=currency['Name'], c=circle, v=currency['Value'], a=arrow)
msg = msg + "&#128073; <a href='https://t.me/prosmi_bot'>Предложить новость</a>"
return msg
@staticmethod
def get_arrow(value, previous) -> str:
if value > previous:
return "&#11014;"
return "&#11015;"
@staticmethod
def get_circle(value, previous) -> str:
if value > previous:
return "&#128994;"
return "&#128308;"

7
msg/SetEmailMsg.py Normal file
View File

@@ -0,0 +1,7 @@
from bot.DaMsg import DaMsg
class SetEmailMsg(DaMsg):
def get_msg(data=None) -> str:
return "Укажите пожалуйста email, который вы используете на ITGuild, если у вас нет учетной записи, то мы ее создадим."

9
msg/UserMsg.py Normal file
View File

@@ -0,0 +1,9 @@
from bot.DaMsg import DaMsg
class HelloMsg(DaMsg):
def get_msg(data=None) -> str:
return ("Здравствуйте. Для более удобной работы с нашим ботом, вам необходимо авторизироваться. "
"Перейдите по сслыки <a href='https://itguild.info/profile/settings'>https://itguild.info/profile/settings</a>, "
"в блоке «Телеграмм бот» нажмите на кнопку «Сгенерировать», полученный код отправте в телеграмм бот.")

13
msg/UserPostMsg.py Normal file
View File

@@ -0,0 +1,13 @@
from bot.HtmlMsg import HtmlMsg
class UserPostMsg(HtmlMsg):
def get_msg(self, data=None) -> str:
if data is None:
data = {}
content = "{content}".format(content=data['post']['content'])
msg = "{content}".format(content=content)
msg = self.replace_tag_with_content(msg, "secure")
return self.get_stylized_msg(msg)