hedwig-im / hedwig

An Adapter-based Bot Framework for Elixir Applications
MIT License
650 stars 73 forks source link

Can't compile responder when there are chinese characters in regular expression #53

Closed bossyang closed 7 years ago

bossyang commented 7 years ago
defmodule Bot.Responders.Hello do
  use Hedwig.Responder

  respond ~r/你好嗎/iu, msg do
    emote msg, "Hi there!"
  end
end
== Compilation error on file lib/bot/responders/hello.ex ==
** (ArgumentError) argument error
    :erlang.binary_to_atom("__你好嗎__", :utf8)
    lib/hedwig/responder.ex:176: Hedwig.Responder.regex_to_name/1
    lib/hedwig/responder.ex:165: Hedwig.Responder."MACRO-respond"/5
    expanding macro: Hedwig.Responder.respond/3
    lib/bot/responders/hello.ex:13: Bot.Responders.Hello (module)
scrogson commented 7 years ago

@bossyang, thanks for reporting this issue! I'll look into a fix today.

scrogson commented 7 years ago

@bossyang can you please try master?

bossyang commented 7 years ago

It can compile now. And the mix.exs is as follows

  defp deps do
    [
      {:hedwig_xmpp, github: "hedwig-im/hedwig_xmpp"},
      {:romeo, github: "scrogson/romeo", override: true},
      {:hedwig, github: "hedwig-im/hedwig", override: true, branch: "master"},
    ]
  end
warning: function Bot.Robot.after_connect/1 is undefined or private
  lib/bot/robot.ex:2
scrogson commented 7 years ago

Cool...looks like we're good now! Thanks for verifying.