class SlackSmartBot def poster(permanent, emoticon_text, emoticon_bg, string, minutes) chars = { a: ["0000", "1111", "1001", "1111", "1001", "1001", "0000"], b: ["0000", "1111", "1001", "1110", "1001", "1111", "0000"], c: ["0000", "0111", "1000", "1000", "1000", "0111", "0000"], d: ["0000", "1110", "1001", "1001", "1001", "1110", "0000"], e: ["0000", "1111", "1000", "1110", "1000", "1111", "0000"], f: ["0000", "1111", "1000", "1110", "1000", "1000", "0000"], g: ["0000", "1111", "1000", "1011", "1001", "1111", "0000"], h: ["0000", "1001", "1001", "1111", "1001", "1001", "0000"], i: ["000", "111", "010", "010", "010", "111", "000"], j: ["0000", "0111", "0010", "0010", "1010", "0110", "0000"], k: ["0000", "1001", "1010", "1100", "1010", "1001", "0000"], l: ["000", "100", "100", "100", "100", "111", "000"], m: ["00000", "10001", "11011", "10101", "10001", "10001", "00000"], n: ["00000", "10001", "11001", "10101", "10011", "10001", "00000"], o: ["0000", "0110", "1001", "1001", "1001", "0110", "0000"], p: ["0000", "1110", "1001", "1110", "1000", "1000", "0000"], q: ["00000", "01100", "10010", "10010", "10010", "01111", "00000"], r: ["0000", "1110", "1001", "1110", "1010", "1001", "0000"], s: ["0000", "0111", "1000", "0110", "0001", "1110", "0000"], t: ["00000", "11111", "00100", "00100", "00100", "00100", "00000"], u: ["00000", "10001", "10001", "10001", "10001", "01110", "00000"], v: ["00000", "10001", "10001", "10001", "01010", "00100", "00000"], w: ["0000000", "1000001", "1000001", "1001001", "1010101", "0100010", "0000000"], x: ["00000", "10001", "01010", "00100", "01010", "10001", "00000"], y: ["00000", "10001", "01010", "00100", "00100", "00100", "00000"], z: ["00000", "11111", "00010", "00100", "01000", "11111", "00000"], '!': ["0", "1", "1", "1", "0", "1", "0"], "'": ["0", "1", "0", "0", "0", "0", "0"], ".": ["0", "0", "0", "0", "0", "1", "0"], "|": ["0", "1", "1", "1", "1", "1", "0"], "%": ["1001", "1001", "0010", "0100", "1001", "1001", "0000"], "$": ["0110", "1001", "0110", "0010", "1001", "0110", "0000"], "*": ["000", "010", "111", "010", "000", "000", "000"], "/": ["000000", "000010", "000100", "001000", "010000", "100000", "000000"], "(": ["000", "001", "010", "010", "010", "001", "000"], ")": ["000", "100", "010", "010", "010", "100", "000"], "<": ["000", "001", "010", "100", "010", "001", "000"], ">": ["000", "100", "010", "001", "010", "100", "000"], "[": ["00", "11", "10", "10", "10", "11", "00"], "]": ["00", "11", "01", "01", "01", "11", "00"], "{": ["00", "01", "10", "01", "10", "01", "00"], "}": ["00", "10", "01", "10", "01", "10", "00"], "_": ["000", "000", "000", "000", "000", "000", "111"], "°": ["0110", "1001", "1001", "0110", "0000", "0000", "0000"], "º": ["0110", "1001", "1001", "0110", "0000", "0000", "0000"], "ª": ["0110", "1001", "0110", "0000", "0000", "0000", "0000"], "&": ["0000", "0110", "1000", "0101", "1010", "0101", "0000"], "#": ["00000", "01010", "11111", "01010", "11111", "01010", "00000"], "@": ["01110", "10001", "10101", "10111", "10000", "01110", "00000"], '^': ["00100", "01010", "10001", "00000", "00000", "00000", "00000"], '"': ["000", "101", "101", "000", "000", "000", "000"], '+': ["000", "000", "010", "111", "010", "000", "000"], '-': ["000", "000", "000", "111", "000", "000", "000"], '=': ["000", "000", "111", "000", "111", "000", "000"], '?': ["000", "111", "001", "010", "000", "010", "000"], '0': ["000", "111", "101", "101", "101", "111", "000"], '1': ["00", "01", "11", "01", "01", "01", "00"], '2': ["000", "111", "001", "010", "100", "111", "000"], '3': ["000", "111", "001", "111", "001", "111", "000"], '4': ["000", "101", "101", "111", "001", "001", "000"], '5': ["000", "111", "100", "111", "001", "111", "000"], '6': ["000", "111", "100", "111", "101", "111", "000"], '7': ["000", "111", "001", "010", "100", "100", "000"], '8': ["000", "111", "101", "111", "101", "111", "000"], '9': ["000", "111", "101", "111", "001", "111", "000"], ' ': ["0", "0", "0", "0", "0", "0", "0"] } emoticon_bg = ":transparent_square:" if emoticon_bg.to_s == "" emoticon_text = ":black_square:" if emoticon_text.to_s == "" string.downcase! messages = [] string = string.strip.split(" ").join(" ") lines = [""] string.split(" ").each do |t| if ("#{lines[-1]}#{t}").size <= 6 lines[-1] = "#{lines[-1]}#{t} " else lines[-1].strip! lines.pop if lines[-1] == "" if t.size > 6 t.chars.each_slice(6).map(&:join).each do |tt| lines << tt.strip end lines[-1] += " " if lines[-1].size < 6 else lines << t.strip + " " end end end lines[-1].strip! messages = [] lines.each do |line| results = [] all_spaces = true line.each_char do |char| if chars.key?(char.to_sym) results << chars[char.to_sym] all_spaces = false else results << chars[:' '] end end unless all_spaces rtxt = "" 7.times do |n| results.size.times do |i| rtxt += "0#{results[i][n]}0" end rtxt += "\n" end rtxt.gsub!("1", emoticon_text) rtxt.gsub!("0", emoticon_bg) txt = "" msgs = [] rtxt.split("\n").each do |m| if (m + txt).size > 4000 msgs << txt unless txt == "" txt = "" end txt += (m + "\n") end msgs << txt msgs.flatten! msgs.each do |msg| messages << respond(msg, return_message: true) end end end unless permanent react :heavy_check_mark sleep (minutes.to_i * 60) messages.delete(nil) messages.each do |message| delete(message.channel, message.ts) end react :heavy_minus_sign end end end