Skip to content

Commit

Permalink
fix: fix bot message to improve readbility
Browse files Browse the repository at this point in the history
feat: add stickers
  • Loading branch information
lucaspolo committed Aug 27, 2022
1 parent 315b72a commit a1f3de6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
23 changes: 21 additions & 2 deletions redditbot/ui/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@
from redditbot.config import settings

DEFAULT_MESSAGE = """r/{subreddit} \\- [{upvotes} votos]
**{title}**
[Link]({link})
**[{title}]({link})**\n
[Comentários]({comments})"""

STICKERS = {
'crying_piglet': 'CAACAgIAAxkBAAEXhYNjCojvibG9_v_VIAABGaq0YhoIrYQAAo8BAAIWQmsKO2O0DZs84FkpBA',
'alpaca_hi': 'CAACAgIAAxkBAAEXhaRjComgByhjRuOjuFsM_0pZa9I8sQAClwADO2AkFLPjVSHrbN7ZKQQ',
'duck_finding': 'CAACAgIAAxkBAAEXhapjCoqLx-ApexksbOfFtQeiTXJ8RAACSQIAAladvQoqlwydCFMhDikE',
'ok_piglet': 'CAACAgIAAxkBAAEXhaxjCovR30n5XwH5JmDUGrUNZToNyQACegEAAhZCawqYRZuYnxC0lykE',
}


async def start(update: Update, context: CallbackContext):
await update.message.reply_sticker(
sticker=STICKERS['alpaca_hi']
)
await update.message.reply_text(
text='Está sem o que fazer? Dá um confere no Reddit!'
)
Expand All @@ -30,6 +39,9 @@ async def nada_para_fazer(update: Update, context: CallbackContext):
await update.message.reply_text(
text='Digite o termo da procura, ex: /nadaparafazer dogs;python'
)
await update.message.reply_sticker(
sticker=STICKERS['duck_finding']
)
return

await send_subreddit(update, subreddits)
Expand All @@ -42,6 +54,10 @@ async def send_subreddit(update, subreddits):
await update.message.reply_text(
text=f'Procurando o que está bombando em {canais_message}...'
)
await update.message.reply_sticker(
sticker=STICKERS['ok_piglet']
)

threads = await rc.get_subreddits(subreddits)
filtered_threads = rc.filter_by_votes(threads, min_votes=settings.MIN_VOTES)
for thread in filtered_threads:
Expand All @@ -59,6 +75,9 @@ async def send_subreddit(update, subreddits):
await update.message.reply_text(
text=f'Não encontrei nada bombando em {canais_message}'
)
await update.message.reply_sticker(
sticker=STICKERS['crying_piglet']
)


async def get_version(update: Update, context: CallbackContext):
Expand Down
8 changes: 6 additions & 2 deletions tests/ui/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class TestNadaParaFazerBot:
async def test_get_version_should_return_version(self):
update = MagicMock()
update.message.reply_text = CoroutineMock()
update.message.reply_sticker = CoroutineMock()
context = MagicMock()

await start(update, context)
Expand All @@ -40,6 +41,7 @@ async def test_get_version_should_return_version(self):
async def test_start(self):
update = MagicMock()
update.message.reply_text = CoroutineMock()
update.message.reply_sticker = CoroutineMock()
context = MagicMock()

await start(update, context)
Expand All @@ -51,6 +53,7 @@ async def test_start(self):
async def test_nada_para_fazer_should_send_help(self):
update = MagicMock()
update.message.reply_text = CoroutineMock()
update.message.reply_sticker = CoroutineMock()
context = MagicMock()
context.args = ''

Expand All @@ -67,6 +70,7 @@ async def test_nada_para_fazer_should_send_messages(
update = MagicMock()
update.message.reply_text = CoroutineMock()
update.message.reply_markdown_v2 = CoroutineMock()
update.message.reply_sticker = CoroutineMock()
context = MagicMock()
context.args = ['dogs']
calls_text = [
Expand All @@ -77,8 +81,7 @@ async def test_nada_para_fazer_should_send_messages(
calls_markdown = [
call(
text='r/dogs \\- [9999 votos]'
'\n**Cute Dogs**'
'\n[Link](https://www\\.reddit\\.com/r/cutedogs)'
'\n**[Cute Dogs](https://www\\.reddit\\.com/r/cutedogs)**\n'
'\n[Comentários](https://www\\.reddit\\.com/r/cute\\_dogs)'
)
]
Expand All @@ -96,6 +99,7 @@ async def test_nada_para_fazer_should_send_not_found(
):
update = MagicMock()
update.message.reply_text = CoroutineMock()
update.message.reply_sticker = CoroutineMock()
context = MagicMock()
context.args = ['dogs']
calls = [
Expand Down

0 comments on commit a1f3de6

Please sign in to comment.