All Downloads are FREE. Search and download functionalities are using the official Maven repository.

za.co.knonchalant.candogram.Bots Maven / Gradle / Ivy

The newest version!
package za.co.knonchalant.candogram;

import za.co.knonchalant.candogram.handlers.IInlineHandler;
import za.co.knonchalant.candogram.handlers.IMessageHandler;
import za.co.knonchalant.candogram.handlers.IUpdate;

import java.util.List;

public class Bots {
    private final String name;
    private List apis;
    private List handlers;
    private IInlineHandler inlineHandler;

    public Bots(String name, List apis, List handlers) {
        this(name, apis, handlers, null);
    }

    public Bots(String name, List apis, List handlers, IInlineHandler inlineHandler) {
        this.apis = apis;
        this.name = name;

        this.handlers = handlers;
        this.inlineHandler = inlineHandler;

        for (IBotAPI api : apis) {
            api.addHandlers(handlers);
            api.setInlineHandler(inlineHandler);
        }
    }

    public String getName() {
        return name;
    }

    public List getApis() {
        return apis;
    }

    public List getHandlers() {
        return handlers;
    }

    public IInlineHandler getInlineHandler() {
        return inlineHandler;
    }

    public void send(long chatId, String message) {
        for (IBotAPI api : apis) {
            api.sendMessage(chatId, message, null, true, null, null);
        }
    }

    public void sendPhoto(IUpdate chatId, byte[] file) {
        for (IBotAPI api : apis) {
            api.sendPhoto(chatId, file);
        }
    }

    @Override
    public String toString() {
        return "Bots{" +
                "name='" + name + '\'' +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy