Add external ASCII plugin

This commit is contained in:
Pedro de Oliveira 2019-11-25 11:41:33 +00:00
parent bbfeab6962
commit c4435e3cbf
8 changed files with 2061 additions and 0 deletions

BIN
ASCII/DejaVu.ttf Normal file

Binary file not shown.

221
ASCII/README.md Normal file
View File

@ -0,0 +1,221 @@
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=T8E56M6SP9JH2)
<b>ASCII Art Plugin</b><br>
Convert text to ASCII art or image URLs to ASCII/ANSI art. Covert ASCII art to PNG. Get ASCII weather, moon phase, and cryptocurrecy rates.
Requires Limnoria https://github.com/ProgVal/Limnoria and Python3
pip install -r requirements.txt
```
config protocols.irc.throttletime 0.0
config plugins.ascii.delay 0.5
```
If you want delays < 1.0 seconds then disable Limnoria's throttling and use this plugin's delay option. 0.5 is 2 lines per second for example. You can also use --delay with commands and override the delay with your own. Default delay config can
be set per channel. Set a value that won't get you kicked.
```
!cq
@cq
.cq
etc.
```
Stop the scroll. cq command must be prefixed by a command character. This command can not be renamed.
Support for the Paste.ee API to save art conversions for later use.
Get an API key from https://paste.ee/account/api (FREE. Not required to use plugin, disabled by default).
```
config plugins.ascii.pasteAPI <PASTE.EE_API_KEY_HERE> (set paste.ee API key)
config channel plugins.ascii.pasteEnable <True/False> (enable/disable paste.ee links)
```
ASCII Weather from wttr.in
```
wttr <location>
wttr moon
wttr --16 (use 16 colors. Default)
wttr --99 (use 99 colors)
wttr <location>?u (use imperial units, degrees F, miles, etc.)
wttr <location>?m (use metric units, degrees C, km, etc.)
wttr <location>?<1-3> (number of days to forecast)
```
![Image of Wttr Command Output](https://i.imgur.com/o0kf25O.png)
![Image of Wttr Command Output](https://i.imgur.com/mTHJfuI.png)<br>
ASCII crypto exchange rates from rate.sx
```
rate (get rates in united states dollars)
rate --sub <currency> (get rates in EUR, USD, BTC, etc.)
rate <coin> (get a graph showing rate fluctuation)
rate --sub <currency> <coin> (get graphs with desired currency)
```
![Image of Rate Command Output](https://i.imgur.com/tuYTQbw.png)
Return a random fortune entry from http://www.asciiartfarts.com/fortune.txt
```
fortune
```
Cowsay. Generate a cowsay ascii. choose character with --type. https://easyapis.soue.tk/api/cowsay
```
cow --type <type> <text> (make a cowsay message. type is optional. defaults to cow)
________
< cowsay >
--------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```
Text-to-ASCII Art (split lines with | ex. ascii|art for large fonts):
```
ascii <text> (convert <text> to ascii art)
ascii --font <font> <text> (to use chosen <font>)
ascii --color <color> <text> (to set a foreground <color>)
ascii --color <color1,color2> <text> (to set a foreground/background <color>)
fontlist (get list of availble <fonts>)
88 88
"" ""
,adPPYYba, ,adPPYba, ,adPPYba, 88 88
"" `Y8 I8[ "" a8" "" 88 88
,adPPPPP88 `"Y8ba, 8b 88 88
88, ,88 aa ]8I "8a, ,aa 88 88
`"8bbdP"Y8 `"YbbdP"' `"Ybbd8"' 88 88
```
Image URL to ASCII/ANSI Art:
```
img <url> (convert an image <url> to ascii art using 99 color palette)
img --w <###> <url> (how many columns wide. defauls to 100)
img --16 <url> (convert using 16 color palette)
img --ascii <url> (convert image to colored ascii art)
img --block <url> (colored space block art)
img --chars "TEXT" <url> (convert image to colorized custom text)
img --ramp "TEXT" <url> (use a custom greyscale ramp e.g. " .-:=+x#%@")
img --ramp "░▒▓█" <url> (image to colorized ansi shader blocks)
img --nocolor <url> (text only greyscale character ramp output)
img --invert <url> (invert the greyscale character ramp)
img --bg <0-99> <url> (set a background color)
img --fg <0-99> <url> (set a foreground color)
img --fast <url> (use Euclidean color difference.)
img --slow <url> (use cie2000 color difference. best quality, default)
img --dither <url> (dither source image to 256 colors. trades off quality for speed)
```
Here are some images using 99 color default output:
![Image of Img Command Output](https://i.imgur.com/33tCGXC.png)<br>
^ output of img https://i.imgur.com/aF9wihd.jpg (image command with default settings)
![Image of Img Command Output](https://i.imgur.com/2BSUjnw.png)<br>
^ output of img --block https://i.imgur.com/aF9wihd.jpg (image command with colored space blocks)
![Image of Img Command Output](https://i.imgur.com/eOQAzTo.png)<br>
^ output of img --ascii https://i.imgur.com/aF9wihd.jpg (image command with colored space blocks)
```
***************+*++++++++++++++++++++++++++++++++++++++=++=++========================---------------
***********+++++++++++++++++++++++++++++++++++++++++++++++============================--------------
***********++++++++++++++++++++++++++++***++++**********+++++++======================---------------
********++++++++++++++++++++++++++++*******++****#********+***++++====================--------------
********++*++++++++++++++++++++++************##%%#####%#*****++***++==================--------------
******+*++++++++++++++++++++++++**+***#*+++*%@%%#*##%###****++++++++++===============---------------
******+++++++++++++++++++++++**++++####++*+##@@#+**##%%@@%##*****++++==+=========-------------------
******++++++++++++++++++++++*#*=*+####*+*++%++@*=*#%@@@@@@@%#**++++==+============------------------
****+++++++++++++++++++++++*+##++#%###+=*+-+#=*%%@@@@@@@@@@@%##*+======+========--------------------
***++++++++++++++++++++++++**###*++***+=*#+==#%#****##%%@@@@@@%#*==============---------------------
**++++++++++++++++++++++++++**#%%%##%@@@@%*+=++=+#%%%@%%@@@@@@@@@#+============-=-------------------
***++++++++==========++++++++#%@@@@@@@@#*+**#*==*%@@@%@@@@@%%@@@%@@*+===========--------------------
**+++++++**#%%@@%#*+=---===+*%%@@@@@@@**#%%@@@#*+++**=*##*****#%@@@@#+===========-------------------
*++++++++#%@@@%###%%%%#*=--=+*%@@@@@@%+#%@@@#%@#++=++++=+++*****##%@@%*=======-==-------------------
*++++++++*###%%#*++*%@@@@@#++*%@@@@@@%*%@@@@*#*=++*++=++**+++++++++*****====---=--------------------
**++++++++**###%@%%%@@@@@@@%##@@@@@@@@*%@%%#*+=+**+++++*++====++++++**##*=--------------------------
**++++++++++**##%@@#*#%%@@###%@@@@@@@@*++++==++**=+++**+=========++****#%%*-------------------------
***+++++++++++**#%%#+++#%@#+**####%%@#+=+++**++*++++*#*+=====+++==+==+*#**%#=-----------------------
*+++++++++++++++**#%%*+*#%#+****#****#*+****++**+++***+=====++=---:-==#@%**#%=----------------------
++++++++++++++++++**#%%%%*+=+**#*****%*####*++**++++**+====++=-+%%*=:-=#@@#+#%=---------------------
++++++++++++++++++++*##%%#++++*#**#*#*+*##*+++#*++++**+===+++=-*@@@@*--=+%%++##-----------------::::
+++++++++++++++++++++*###**+++**###*+++****+++#*+++++**=====+===*%@@%=-==+**+*#=----------------::::
+++++++++++++++++++++++*++++=+#####+=+++*#*+++*#+++*+*#+++==++==--=+=====++***#*---------------:::::
+++++++++++++++++++++========*####*++++++##+++*#*++*++*#++==+++=====--===++***%*---------------:::::
++++++++++++++++++++++++++**%#*##*+++==++*%#****#*****+*#*+==++*+=======++**##%+---------:::::::::::
+++++++++++++++++++++++***##**#%#+++++++++*%%#**####*****##****##**++++++*##%%*--------:::::::::::::
+++++++++++++++++++++++####**#%%#++++++++++*#%####%%######%%%*+*@@@@%###%%@@%*+==----:-:::::::::::::
+++++++++++++++++++++++#%%#####*#****++++++**#%%%%%@@@@@@@@@@%**@@@@@@@@@%%%%#*++==--:::::::::::::::
+++++++++++++++++=+++++*#%%%%%%%###****+***###%%@@@@@@@@@@@@@@@@@@@@%*#%%%%%%##*+++=-:::::::::::::::
++++++++++++++++++++++****#%%%%#############%%@@@@%#%@@@#*%@@@@@@@@@= .+%%@%%%#*++=--:::::::::::::::
+++++++++++++++++++++*+++*###******#*#%%%%%%%%%#*+++++**: :%@@@@@@@@%+*%#%%%%%%#*++===----::::::::::
++++++++++++++++==++*++**###**###*#**##%##****++====+==-===+%@@@@@@%%@######%%@@@@@@%%#**++===-:::::
++++++++++++++++++=+++***#######**##**#%#*#*####*++++=====+===+*********####%%@@@@@@@@@@%%##**+==--:
+++++++++++++++++++++++****###%##%%#**###%%%%%%%%##*++==========+++++**++**%%%@@@@@@@@@@@@@@%%##*+=-
+++++++++++++++++==+++++****###%%%%##*##%@@@%%@%%%####***+====++++***##***#%%%@@@@@@@@@@@@@@@@@%%#*+
++++++++++++++++++++++++***#######%#*###%%@@@@@@%@@%%@%%#####******##%#%%@@@@@@@@@@@@@@@@@@@@@@%%%#*
++++++++++++++++++++*****######%#########%%%@@@@@@@@@@@@@@@%%%%%%%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@%####
+++++++++++++=+++++++**#%%#####%%%%%%###%%#%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%####***
++++++++++++++++++***##%%@%##%%%%%%%%%%@@%%@%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%#*******#
++++++++++++=++++*##%%%##%%%%%%%%%%%%%%%%%#%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%#***++**##
++++++++++==+****#%%%%####%##%%%%%%%#**++*+*@%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%****++*##
++++++++++**####**####%###%#%%#@%@%#*+*****#**%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%###**#***#
++++++++*#######**####%%##%##*%@@@%%##*+**+**%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%@@@@%#*****#**
+++++**########%##%%%%%%%#####%@@@@%**+*#**#%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%@%%%#**##**#
+++**###########+#%%%%%##%%%*#%@@@@#**#####%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%####**###*
+**#%%%%%%%%##*++*#####**##***###%%####*****####**%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%#########%#
##%%%%%%%%%#*++=+++*****+++++++++++++===========+#%%@@@@@@@@@@@@@@@@@@@@@%%%%@@@@@@@@@@@@%%%%%##*##%
%%%@@@@@@@%#*++====+*****++*+++++++++=========++***%@@@@@@@@@@@@@@@@@%%%#**###%%@@@@@@@@@@@@@@%%#**#
%@@@@@@@###**+++=+++++**#*+***++*++++++++++==+***+*%%@@@@@@@@@@@@@@@%%###**####%%%@@@@@@@@@@@@@@@%##
@@@@@@@%#++**+***+++*****+**#####***++++==+=+****+*#%%@@@@@@@@@@@@@@%%####**##%@%%%%%%%##%%@@@@@@@@@
```
^ Output of img --nocolor --invert https://i.imgur.com/aF9wihd.jpg
Scroll ASCII/ANSI Art text files
```
scroll <url> (playback of ansi/ascii art .txt files from the web)
```
Create PNG images from ascii art text files.
```
png <url>
png --size 10-99 <url> (set a font size. defaults to 15pt)
png --bg 0-99 <url> (set a background color)
png --fg 0-99 <url> (set a foreground color)
```
Get your imgur Client ID from https://imgur.com/account/settings (FREE).
```
config plugins.ascii.imgurAPI <CLIENT_ID_HERE> (set imgur API key)
```
<b>THE COMMANDS BELOW REQUIRE ADDITIONAL INSTALLS AND ARE OPTIONAL. YOU WILL NEED TO VISIT THE GITHUB
PAGES BELOW AND INSTALL THE PROGRAMS IF YOU WANT TO USE THESE COMMANDS. </b>
ANSI Art to IRC converrter:
```
a2m <url> (conversion and playback of ansi art .ans files from the web.)
```
a2m command requires A2M https://github.com/tat3r/a2m (optional. disable command if not installing a2m.)
Picture to Unicode
```
p2u <url>
```
![Image of p2u command](https://i.imgur.com/CBarBzz.png)<br>
^ Output of p2u https://i.imgur.com/aF9wihd.jpg
p2u command requires p2u https://git.trollforge.org/p2u/about/ (optional. disable command if not installing p2u.)
TDFiglet. Text to tdfiglet
```
tdf [-f <font>] <text> (select font with -f <fontname>)
fonts (list of figlet fonts)
```
![image of tdf commad](https://i.imgur.com/Jctpbno.png)<br>
tdf command requires tdfiglet https://github.com/tat3r/tdfiglet (optional. disable command if not installing tdfiglet.)
Toilet. Requires installation of toilet. sudo apt install toilet etc. (optional as usual)
```
toilet -f <font> -F <filter1,filter2> <text> (do the text to toilet stuff)
```
get fonts. looks for fonts in /usr/share/figlet/
```
fonts --toilet
```
![Image of toilet command](https://i.imgur.com/dJChPnj.png)

43
ASCII/__init__.py Normal file
View File

@ -0,0 +1,43 @@
###
# Copyright (c) 2019 oddluck
# All rights reserved.
#
#
###
"""
ASCII: Uses API to retrieve information
"""
import supybot
import supybot.world as world
# Use this for the version of this plugin. You may wish to put a CVS keyword
# in here if you're keeping the plugin in CVS or some similar system.
__version__ = ""
# XXX Replace this with an appropriate author or supybot.Author instance.
__author__ = supybot.authors.unknown
# This is a dictionary mapping supybot.Author instances to lists of
# contributions.
__contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = ''
from . import config
from . import plugin
from imp import reload
# In case we're being reloaded.
reload(config)
reload(plugin)
# Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing:
from . import test
Class = plugin.Class
configure = config.configure

57
ASCII/config.py Normal file
View File

@ -0,0 +1,57 @@
###
# Copyright (c) 2019, oddluck
# All rights reserved.
#
#
###
import supybot.conf as conf
import supybot.registry as registry
try:
from supybot.i18n import PluginInternationalization
_ = PluginInternationalization('ASCII')
except:
# Placeholder that allows to run the plugin on a bot
# without the i18n module
_ = lambda x: x
def configure(advanced):
# This will be called by supybot to configure this module. advanced is
# a bool that specifies whether the user identified themself as an advanced
# user or not. You should effect your configuration by manipulating the
# registry as appropriate.
from supybot.questions import expect, anything, something, yn
conf.registerPlugin('ASCII', True)
ASCII = conf.registerPlugin('ASCII')
conf.registerGlobalValue(ASCII, 'pasteAPI',
registry.String('', _("""Paste.ee API Key""")))
conf.registerGlobalValue(ASCII, 'imgurAPI',
registry.String('', _("""Imgur Client ID""")))
conf.registerChannelValue(ASCII, 'pasteEnable',
registry.Boolean(False, _("""Turns on and off paste.ee support""")))
conf.registerChannelValue(ASCII, 'delay',
registry.Float(1.0, _("""Set the time delay betwen lines. Not currently implemented.""")))
conf.registerChannelValue(ASCII, 'dither',
registry.Boolean(True, _("""Enable dithering. Results in much faster rendering at a slight decrease in quality. Default: True""")))
conf.registerChannelValue(ASCII, 'speed',
registry.String('Slow', _("""Set the speed of the color rendering. 'Slow' (default) to use CIEDE2000 color difference. 'Fast' to use Euclidean color difference.""")))
conf.registerChannelValue(ASCII, 'imgDefault',
registry.String('1/2', _("""Set the default art type for the img command. Options are 'ascii', '1/2' (default), '1/4', 'block', and 'no-color'""")))
conf.registerChannelValue(ASCII, 'asciiWidth',
registry.Integer(100, _("""Set the default column width for ascii art images""")))
conf.registerChannelValue(ASCII, 'blockWidth',
registry.Integer(70, _("""Set the default column width for 1/2 and 1/4 block art images""")))
conf.registerChannelValue(ASCII, 'colors',
registry.Integer(99, _("""Set the default number of colors to use. Options are 16 for colors 0-15 only, 83 for colors 16-98 only, and 99 (default) to use all available colors""")))

1713
ASCII/plugin.py Normal file

File diff suppressed because it is too large Load Diff

6
ASCII/requirements.txt Normal file
View File

@ -0,0 +1,6 @@
requests
numpy
pillow
fake-useragent
pexpect
pyimgur

17
ASCII/test.py Normal file
View File

@ -0,0 +1,17 @@
17 lines (10 sloc) 216 Bytes
###
# Copyright (c) 2019, oddluck
# All rights reserved.
#
#
###
from supybot.test import *
class AdviceTestCase(PluginTestCase):
plugins = ('ASCII',)
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

4
ASCII/tmp/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore