Add smile support to annna. - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit 2628bd5e8d723212320200938832049a502acbaa DIR parent 69bb3614ffb26988dfe3210716e422ee922094ec HTML Author: Annna Robert-Houdin <annna@bitreich.org> Date: Thu, 26 Dec 2024 18:25:55 +0100 Add smile support to annna. Diffstat: M annna-message-common | 4 ++++ A smile | 73 +++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 0 deletions(-) --- DIR diff --git a/annna-message-common b/annna-message-common @@ -1216,6 +1216,10 @@ case "${text}" in "For humanity!") annna-say -s "${server}" -c "${channel}" "${user}, for humanity! gophers://bitreich.org/0/memecache/annna-rchism.txt" ;; +":)"|":))"|":)))"|":-)"|":-))"|":-)))"|":--)"|":--))"|":--)))"|":---)"|":----)") + smileface="$(smile)" + annna-say -s "${server}" -c "${channel}" -- "${smileface}" + ;; "${ircuser}, please dance."|"\\o/"|"\^o^/") dancemoves="$(dance-moves-gen)" annna-say -s "${server}" -c "${channel}" -- "${dancemoves}" DIR diff --git a/smile b/smile @@ -0,0 +1,73 @@ +#!/usr/bin/env python +# coding=utf-8 + +import os +import sys +import getopt +import random + +def usage(app): + app = os.path.basename(app) + print("usage: %s [-h] [-n moves]" % (app), file=sys.stderr) + sys.exit(1) + +def main(args): + horiz_hair = ["w", "W", "~"] + horiz_eyes = ["o", "O", + "𓁹", "𓁺", "𓁻", "𓁼", "𓁽", "𓁾", "𓁿", "𓂀", + "{.}", "(.)", "{o}", "{O}", "(o)", "(.)", "{.}", + "𓂂", "𓏗", "𓇳", "𓇸", "𓃉", + "0"] + horiz_nose = ["m", "v", "i", "."] + horiz_moustache = ["~~~", "===", "---", "w"] + horiz_mouth = ["\\/", "\\_/", + "𓂋", "𓂌", "𓂍", "𓂎", "𓂏", "𓂑", "𓂒", + ] + + vert_hair = ["d", "c|", "<|", "~"] + vert_eyes = [":", "8", ";"] + vert_moustache = ["{", "#", "B", "3"] + vert_nose = ["-"] + vert_mouth = [")", "}", "P", "p", "b", "*", ">", "D", "]", "O", "o"] + vert_tie = ["x", "X"] + vert_body = ["|-<", "|o<", "|O<", "|~<"] + + try: + opts, largs = getopt.getopt(args[1:], "hb") + except getopt.GetoptError as err: + print(str(err)) + usage(args[0]) + + vertical=1 + withbody=0 + for o, a in opts: + if o == "-h": + usage(args[0]) + elif o == "-b": + withbody=1 + else: + assert False, "unhandled option" + + ostr = "" + if vertical == 1: + if random.randrange(1, 10) > 7: + ostr += random.choice(vert_hair) + ostr += random.choice(vert_eyes) + nose = random.choice(vert_nose) + for i in range(1, random.randrange(2, 5)): + ostr += nose + if random.randrange(1, 10) > 8: + ostr += random.choice(vert_moustache) + ostr += random.choice(vert_mouth) + if random.randrange(1, 10) > 8: + ostr += random.choice(vert_tie) + if withbody == 1: + ostr += random.choice(vert_body) + + print("%s" % (ostr)) + + return 0 + +if __name__ == "__main__": + sys.exit(main(sys.argv)) +