-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Haze
committed
May 9, 2017
0 parents
commit 92d93b9
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
# shitpost.py | ||
|
||
example: `shitpost i could kill for some sushi right about now...` | ||
|
||
to install use PyInstaller | ||
* pip3 install Nuitka | ||
* nuitka --show-progress --lto --output-dir=build src/shitpost.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
pip3 install Nuitka | ||
nuitka --show-progress --lto --remove-output src/shitpost.py | ||
sudo mv shitpost.exe /usr/local/bin/shitpost | ||
echo 'done' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import sys | ||
from random import randint | ||
import requests | ||
|
||
DANGO_ENPOINT = 'https://emoji.getdango.com/api/emoji' | ||
|
||
def get_relevant_emojis(x): | ||
r = requests.get(DANGO_ENPOINT, params={'q':x}) | ||
return r.json()['results'] | ||
|
||
def emojify(x): | ||
relevant = get_relevant_emojis(x) | ||
if relevant[0]['score'] < 0.012: | ||
return x | ||
if x.endswith('.'): | ||
return x[:len(x)-1] + " " + ' '.join(list(map(lambda x: x['text'], get_relevant_emojis(x)[:randint(1, 3)]))) + '. ' | ||
else: | ||
return x + " " + ' '.join(list(map(lambda x: x['text'], get_relevant_emojis(x)[:randint(1, 3)]))) + ' ' | ||
|
||
def split_by_random(base, char, a, e): | ||
buff = [] | ||
b = base.split(char) | ||
while not len(b) == 0: | ||
to = randint(a, e) | ||
section = b[0:to] | ||
buff.append(' '.join(section)) | ||
b = b[to:] | ||
return buff | ||
|
||
base = ' '.join(sys.argv[1:]) | ||
if not base: | ||
print('no input found.') | ||
exit(1) | ||
|
||
split_base = split_by_random(base, ' ', 1, 3) | ||
print(' '.join(list(map(emojify, split_base)))) |