GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


weather plugin by statler
1
 
public class WeatherPlugin extends PluginBase
{
    public int getSupportedEvents()
    {
        // TODO Auto-generated method stub
        return EVENT_MESSAGE;
    } // getSupportedEvents

    public void onMessage(String channel,
                String sender,
                String login,
                String hostname,
                String message)
        {
            if (message.equals("!weather"))
            {
                Metar metar = null;
                metar = Weather.getMetar("KHKS"); // hard-coded, Hawkins Field
                StringBuffer weatherStr = new StringBuffer();
                weatherStr.append(sender + ": temp ");
                weatherStr.append(metar.getTemperatureInFahrenheit() + "F ");
                weatherStr.append(metar.getTemperatureInCelsius() + "C, pressure ");
                weatherStr.append(metar.getPressure() + " in Hg, winds ");
                weatherStr.append(metar.getWindSpeedInMPH() + " mph, visibility ");
                weatherStr.append(metar.getVisibility() + " mile(s).");
                bot.sendMessage(channel, weatherStr.toString());
            } // if
        } // onMessage

} // WeatherPlugin