Skip to content
Snippets Groups Projects
Commit 370fcc43 authored by Bruce Cowan's avatar Bruce Cowan
Browse files

A couple more functions in Unicode plugin

parent 2c881945
No related branches found
No related tags found
No related merge requests found
import unicodedata
from errbot import BotPlugin, botcmd
......@@ -21,4 +23,26 @@ class Unicode(BotPlugin):
try:
return ''.join([chr(int(i)) for i in args.split()])
except ValueError as e:
return "Error: {}".format(e)
return "**Error**: {}".format(e)
@botcmd
def unicode_lookup(self, message, args):
"""Looks up a character by name"""
if not args:
return "**Usage**: !unicode lookup <name>"
try:
return "Character is {}".format(unicodedata.lookup(args))
except KeyError:
return "**Error**: Character not found"
@botcmd
def unicode_name(self, message, args):
"""Looks up the name of a character"""
if len(args) != 1:
return "**Usage**: !unicode name <chr>"
try:
return "Character's name is {}".format(unicodedata.name(args))
except ValueError:
return "**Error**: Character not found"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment