Compare commits

..

No commits in common. "71dad6e25f1e73a14e2600dbbd86fa5fc788a9ba" and "b01a8477581e2f9836c15e4627cb9cbeede4405b" have entirely different histories.

3 changed files with 43 additions and 79 deletions

View File

@ -1,3 +0,0 @@
# grawlix
A bot for posting grids of emojis to GoToSocial or Mastodon

View File

@ -1,4 +1,4 @@
:grawlix_null: mono blank
:grawlix_null: blank
:grawlix_angle: colour yellow
:grawlix_ball1: colour green
:grawlix_ball2: colour blue
@ -6,51 +6,51 @@
:grawlix_bullseye: colour
:grawlix_bun: colour yellow
:grawlix_claw: colour red
:grawlix_cloud: mono
:grawlix_crosses: mono texture
:grawlix_crumple: mono texture
:grawlix_cloud:
:grawlix_crosses: texture
:grawlix_crumple: texture
:grawlix_drop: colour purple
:grawlix_dust1: mono texture
:grawlix_dust2: mono texture
:grawlix_dust1: texture
:grawlix_dust2: texture
:grawlix_feather: colour green
:grawlix_flower: colour blue
:grawlix_fruit: colour green
:grawlix_fungus: colour yellow
:grawlix_fur: mono texture
:grawlix_fur: texture
:grawlix_gadget: colour red
:grawlix_globule: colour pink
:grawlix_glyph1: mono glyph
:grawlix_glyph10: mono glyph
:grawlix_glyph2: mono glyph
:grawlix_glyph3: mono glyph
:grawlix_glyph4: mono glyph
:grawlix_glyph5: mono glyph
:grawlix_glyph6: mono glyph
:grawlix_glyph7: mono glyph
:grawlix_glyph8: mono glyph
:grawlix_glyph9: mono glyph
:grawlix_growth: mono
:grawlix_hatch: mono texture
:grawlix_glyph1: glyph
:grawlix_glyph10: glyph
:grawlix_glyph2: glyph
:grawlix_glyph3: glyph
:grawlix_glyph4: glyph
:grawlix_glyph5: glyph
:grawlix_glyph6: glyph
:grawlix_glyph7: glyph
:grawlix_glyph8: glyph
:grawlix_glyph9: glyph
:grawlix_growth:
:grawlix_hatch: texture
:grawlix_helm: colour red
:grawlix_horizon: colour pink
:grawlix_joint: mono texture
:grawlix_knothole: mono texture
:grawlix_joint: texture
:grawlix_knothole: texture
:grawlix_link: colour trans
:grawlix_lump: colour yellow
:grawlix_mountain: colour blue
:grawlix_orbit: mono
:grawlix_orbit:
:grawlix_popup: colour yellow
:grawlix_rects: colour trans
:grawlix_rough: colour texture pink
:grawlix_scales: colour texture red
:grawlix_scrawl: mono texture
:grawlix_scrawl: texture
:grawlix_scribble: colour texture green
:grawlix_shatter: colour texture
:grawlix_signal: colour
:grawlix_slump: colour texture green
:grawlix_spark1: mono
:grawlix_spark2: mono
:grawlix_sprout: mono
:grawlix_strata: mono texture
:grawlix_vertical: mono texture
:grawlix_spark1:
:grawlix_spark2:
:grawlix_sprout:
:grawlix_strata: texture
:grawlix_vertical: texture
:grawlix_wreck: texture colour blue

View File

@ -1,55 +1,25 @@
import random
import sys
from botclient.botclient import Bot
from collections import defaultdict
GRAWLIX = [
"angle", "ball1", "ball2", "brick", "bullseye", "bun", "claw", "cloud",
"crosses", "crumple", "drop", "dust1", "dust2", "feather", "flower", "fruit",
"fungus", "fur", "gadget", "globule", "glyph1", "glyph10", "glyph2", "glyph3",
"glyph4", "glyph5", "glyph6", "glyph7", "glyph8", "glyph9", "growth", "hatch",
"helm", "horizon", "joint", "knothole", "link", "lump", "mountain", "null",
"orbit", "popup", "rects", "rough", "scales", "scrawl", "scribble", "shatter",
"signal", "slump", "spark1", "spark2", "sprout", "strata", "vertical", "wreck",
]
GRID_TYPES = [ "latin_square", "concentric", "sator", "random", "vertical", "horizontal" ]
BLANK_P = {
0: 3,
1: 2,
2: 2,
3: 1,
4: 1,
5: 1,
6: 0,
7: 0,
8: 0,
9: 0,
}
class Grawlix(Bot):
def __init__(self):
super().__init__()
self.ap.add_argument('-a', '--all', action='store_true', help="Dump a random grid of emojos")
self.ap.add_argument('-t', '--test', action='store_true', help="Dump emojo list")
def load_emojos(self):
self.emojos = []
self.groups = defaultdict(set)
with open(self.cf["emojos"], "r") as efh:
for line in efh:
parts = line.split()
self.emojos.append(parts[0])
for tag in parts[1:]:
self.groups[tag].add(parts[0])
self.tags = [ t for t in self.groups.keys() if not t == "blank" ]
def make_glyphset(self, n):
blanks_r = random.randrange(10)
blanks_n = BLANK_P[blanks_r]
emojos_n = n - blanks_n
if "groups" in self.cf and random.randrange(2) == 0:
tag = random.choice(self.cf["groups"])
glyphset = random.sample(list(self.groups[tag]), emojos_n)
else:
glyphset = random.sample(self.emojos, emojos_n)
blank = list(self.groups["blank"])[0]
glyphset += ( [ blank ] * blanks_n )
random.shuffle(glyphset)
return glyphset
def latin_square(self):
return [
@ -112,6 +82,10 @@ class Grawlix(Bot):
def grid_glyphs(self, grid):
return max([max(row) for row in grid]) + 1
def make_glyphset(self, n):
names = random.sample(GRAWLIX, n)
return [ f":grawlix_{name}:" for name in names ]
def render_row(self, row, glyphs):
return " ".join([glyphs[c] for c in row])
@ -119,14 +93,12 @@ class Grawlix(Bot):
grid = self.make_grid()
n = self.grid_glyphs(grid)
glyphs = self.make_glyphset(n)
if self.args.dry_run:
print(glyphs)
rows = [ self.render_row(r, glyphs) for r in grid ]
return "\n".join(rows)
def header(self):
for r in range(20):
names = [ random.choice(self.emojos) for c in range(100) ]
names = [ random.choice(GRAWLIX) for c in range(100) ]
files = [ f'<img src="grawlix_{n}.png" />&nbsp;' for n in names ]
print(''.join(files))
print('<br />')
@ -136,14 +108,9 @@ class Grawlix(Bot):
if __name__ == '__main__':
g = Grawlix()
g.configure()
g.load_emojos()
if g.args.all:
g.header()
sys.exit(1)
if g.args.test:
print(g.tags)
print(g.cf)
sys.exit(1)
post = g.render()
g.wait()
g.post(post)