Search in sources :

Example 1 with AutoMessageSQL

use of com.github.jonteohr.tejbz.twitch.sql.AutoMessageSQL in project pgda by jonteohr.

the class AutoMessage method updateAutoMessages.

public static void updateAutoMessages() {
    AutoMessageSQL sql = new AutoMessageSQL();
    List<String> newMessages = sql.getMessages();
    // Remove old ones
    for (int i = 0; i < autoMessages.size(); i++) if (!newMessages.contains(autoMessages.get(i)))
        autoMessages.remove(i);
    // Add new ones
    for (String newMessage : newMessages) if (!autoMessages.contains(newMessage))
        autoMessages.add(newMessage);
}
Also used : AutoMessageSQL(com.github.jonteohr.tejbz.twitch.sql.AutoMessageSQL)

Example 2 with AutoMessageSQL

use of com.github.jonteohr.tejbz.twitch.sql.AutoMessageSQL in project pgda by jonteohr.

the class AutoMessage method autoMessageTimer.

public static void autoMessageTimer() {
    Timer timer = new Timer();
    AutoMessageSQL sql = new AutoMessageSQL();
    timer.scheduleAtFixedRate(new TimerTask() {

        @Override
        public void run() {
            if (count < sql.getInterval())
                return;
            String message = autoMessages.get(pagination);
            if (message.contains("[video]")) {
                PropertyHandler props = new PropertyHandler();
                message = message.replace("[video]", props.getPropertyValue("recent_video"));
            }
            Twitch.twitchClient.getChat().sendMessage("tejbz", message);
            count = 0;
            if (pagination == (autoMessages.size() - 1))
                pagination = 0;
            else
                pagination++;
        }
    }, 7 * 60 * 1000, 7 * 60 * 1000);
}
Also used : AutoMessageSQL(com.github.jonteohr.tejbz.twitch.sql.AutoMessageSQL) Timer(java.util.Timer) TimerTask(java.util.TimerTask) PropertyHandler(com.github.jonteohr.tejbz.PropertyHandler)

Aggregations

AutoMessageSQL (com.github.jonteohr.tejbz.twitch.sql.AutoMessageSQL)2 PropertyHandler (com.github.jonteohr.tejbz.PropertyHandler)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1