From 4ae970a64e723c895a7b6e9b12b066b2abb990a0 Mon Sep 17 00:00:00 2001 From: moutella Date: Fri, 21 Feb 2020 13:54:54 +0000 Subject: [PATCH 1/3] bug updates --- .gitignore | 3 ++- update_bot.py | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index e338357..9d65fa6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ .vscode testfile.py config.json -pokemon_img/* \ No newline at end of file +pokemon_img/* +pokedolar.sh diff --git a/update_bot.py b/update_bot.py index 8f7cda1..717dc63 100644 --- a/update_bot.py +++ b/update_bot.py @@ -34,11 +34,11 @@ data['exchange'] = dolar_real if 'exchange' in config: - if data['exchange'] == dolar_real: + if config['exchange'] == dolar_real: tweet = False else: tweet = True - if float(data['exchange']) < float(dolar_real): + if float(config['exchange']) < float(dolar_real): subiu = True data['exchange'] = dolar_real @@ -55,7 +55,7 @@ if subiu: status_template = "O dólar subiu para R${} :(\n\n #{} - {}" else: - status_template = "O dólar caiu para R${} :()\n\n #{} - {}" + status_template = "O dólar caiu para R${} :)\n\n #{} - {}" else: status_template = "quanto tá o pokédólar? R${}\n\n #{} - {}" @@ -65,4 +65,11 @@ config_file = open('config.json', 'w') json.dump(data, config_file) else: + config_file = open('config.json', 'w') + + last_read = "{}".format(dolar_json[1][-1]['ask']) + + data['last_read'] = last_read + json.dump(data, config_file) + print("Não mudou {}".format(data['exchange'])) \ No newline at end of file From 6763779e43553329db0b4a221b5f910ef6e63df0 Mon Sep 17 00:00:00 2001 From: moutella Date: Thu, 5 Mar 2020 19:07:54 +0000 Subject: [PATCH 2/3] no longer smiles --- update_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_bot.py b/update_bot.py index 717dc63..86414ba 100644 --- a/update_bot.py +++ b/update_bot.py @@ -55,7 +55,7 @@ if subiu: status_template = "O dólar subiu para R${} :(\n\n #{} - {}" else: - status_template = "O dólar caiu para R${} :)\n\n #{} - {}" + status_template = "O dólar caiu para R${}\n\n #{} - {}" else: status_template = "quanto tá o pokédólar? R${}\n\n #{} - {}" From 30c561ecf47d9ab4c8534d9c87b214eaf82d47e0 Mon Sep 17 00:00:00 2001 From: moutella Date: Fri, 20 Mar 2020 21:14:57 +0000 Subject: [PATCH 3/3] added emojis, new readme --- README.MD | 2 +- emojis.py | 10 ++++++++++ update_bot.py | 10 +++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 emojis.py diff --git a/README.MD b/README.MD index fe58dba..26d74cd 100644 --- a/README.MD +++ b/README.MD @@ -17,6 +17,6 @@ Usage # Account Follow the bot at [@PokeDolar](https://twitter.com/PokeDolar) # Special Thanks -[@garotilde](https://twitter.com/garotilde) for the idea. +[@garotilde](https://twitter.com/garotilde) and [Pokedollar-FB](https://www.facebook.com/pokedollar) for the idea. [pokemon.json](https://github.com/fanzeyi/pokemon.json) from [@fanzeyi](https://github.com/fanzeyi) for the pokedex.json file and pictures diff --git a/emojis.py b/emojis.py new file mode 100644 index 0000000..bf99af2 --- /dev/null +++ b/emojis.py @@ -0,0 +1,10 @@ +from random import sample + + +def sad_emoji(): + emojis = '😕😟🙁☹️😮😲🥺😦😧😨😰😥😢😭😱😖😣😞😓😩😫😤😡😠🤬💩😾😿🙀' + return sample(emojis, 1)[0] + +def happy_emoji(): + emojis = '😀😃😄😁😆😅🙂🙃😉😍😛🤑🤡😶' + return sample(emojis, 1)[0] \ No newline at end of file diff --git a/update_bot.py b/update_bot.py index 86414ba..23ed1b7 100644 --- a/update_bot.py +++ b/update_bot.py @@ -4,6 +4,7 @@ import requests from decouple import config +from emojis import sad_emoji, happy_emoji consumer_key = config('consumer_key') consumer_secret = config('consumer_secret') @@ -51,16 +52,19 @@ name = pokemon[pokeid-1]['name']['english'] imagepath = 'pokemon_img/{}.png'.format(pokeid) + emoji = '' if not first_tweet: if subiu: - status_template = "O dólar subiu para R${} :(\n\n #{} - {}" + status_template = "O dólar subiu para R${} {}\n\n #{} - {}" + emoji = sad_emoji() else: - status_template = "O dólar caiu para R${}\n\n #{} - {}" + status_template = "O dólar caiu para R${} {}\n\n #{} - {}" + emoji = happy_emoji() else: status_template = "quanto tá o pokédólar? R${}\n\n #{} - {}" - status = status_template.format(dolar_real, pokeid, name) + status = status_template.format(dolar_real, emoji, pokeid, name) api.update_with_media(imagepath, status) config_file = open('config.json', 'w') json.dump(data, config_file)