Classの使い方がやっとわかったので…
Class部分は下記の通りです。
request = require 'request' qs = require 'querystring' class WeatherClass constructor: -> @url = "http://api.openweathermap.org/data/2.5/weather?" @auth = appid: 'API_KEY' # API_KEY q: 'Tokyo,jp' # 都市 units: 'metric' # 摂氏 send: (msg) -> params = qs.stringify(@auth) request url: @url + params , (err, response, body) -> json = JSON.parse body weatherName = json['weather'][0]['main'] icon = json['weather'][0]['icon'] temp = json['main']['temp'] temp_max = json['main']['temp_max'] temp_min = json['main']['temp_min'] message = "今日の東京の天気は「" + weatherName + "」です。\n気温:"+ temp + "℃ 最高気温:" + temp_max+ "℃ 最低気温:" + temp_min + "℃\nhttp://openweathermap.org/img/w/" + icon + ".png" msg.send message module.exports = WeatherClass
ソース部分は下記の通りです。
WeatherClass = require './weatherClass' module.exports = (robot) -> robot.hear /今日の天気は/i, (msg) -> wc = new WeatherClass wc.send(msg)
色々とスッキリした!