Skip to content

Instantly share code, notes, and snippets.

@scotthelm
Last active February 14, 2022 14:49
Show Gist options
  • Save scotthelm/0f721f83b8d9b41bb564cc36d6f766d6 to your computer and use it in GitHub Desktop.
Save scotthelm/0f721f83b8d9b41bb564cc36d6f766d6 to your computer and use it in GitHub Desktop.
slack to utf-8 wordle converter

Slack Emjoi to UTF-8 Wordle Converter

This utility converts a wordle message from slack to the utf-8 equivalent.

Installation

Place the wconv.rb file in a directory in your PATH and make it executable chmod +x.

Usage

wconv.rb "<pasted string>"

#!/usr/bin/env ruby
def square(word)
result = {
black_large_square: '⬛',
large_yellow_square: '🟨',
large_green_square: '🟩',
white_large_square: '⬜',
large_blue_square: '🟦',
large_orange_square: '🟧'
}[word.to_sym]
(result || word).encode('utf-8')
end
input = ARGV[0]
lines = input.split("\n")
lines_with_words = lines.map do |line|
line.split(':').reject(&:empty?).map { |word| square(word) }.join
end
puts lines_with_words.join("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment