当前位置: 首页>>代码示例>>Java>>正文


Java SlackSessionFactory类代码示例

本文整理汇总了Java中com.ullink.slack.simpleslackapi.impl.SlackSessionFactory的典型用法代码示例。如果您正苦于以下问题:Java SlackSessionFactory类的具体用法?Java SlackSessionFactory怎么用?Java SlackSessionFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SlackSessionFactory类属于com.ullink.slack.simpleslackapi.impl包,在下文中一共展示了SlackSessionFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入依赖的package包/类
public void run(ITetradCallback callback) {
    logger.debug("Run");
    logger.info(MessageFormat.format("Connecting with botid {0}",
                                     slackConfig.botid
                                    ));
    slackSession = SlackSessionFactory.createWebSocketSlackSession(slackConfig.botid);
    slackSession.addMessagePostedListener(this::onEvent);
    slackSession.addMessageUpdatedListener(this::onUpdateEvent);
    slackSession.addPinAddedListener((event, session) -> {
        logger.info("yo");
    });
    slackSession.addReactionAddedListener((event, session) -> {
        logger.info("a");
    });
    //slackSession.add
    this.callback = callback;
    try {
        slackSession.connect();
    } catch (IOException e) {
        logger.error(MessageFormat.format("Error connecting with botid {0}. Message: {1}",
                                          slackConfig.botid,
                                          e.getMessage()
                                         ));
    }
}
 
开发者ID:dmitriid,项目名称:tetrad,代码行数:26,代码来源:TetradSlack.java

示例2: listen

import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入依赖的package包/类
@Override
public void listen() {
    session = SlackSessionFactory.createWebSocketSlackSession(januszConfiguration.slack.apiToken);

    session.addMessageListener(new SlackMessageListener() {
        @Override
        public void onSessionLoad(SlackSession slackSession) {
        }

        @Override
        public void onMessage(SlackMessage slackMessage) {
            janusz.processCommand(
                slackMessage.getMessageContent(),
                slackMessage.getSender().getUserName(),
                result -> session.sendMessageOverWebSocket(slackMessage.getChannel(), result, null)
            );
        }
    });

    session.connect();
}
 
开发者ID:TouK,项目名称:janusz,代码行数:22,代码来源:SlackJanusz.java

示例3: main

import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入依赖的package包/类
public static void main(String[] args) throws IOException, SchedulerException {
    //Start the job scheduler
    JobManager.getInstance().startScheduler();

    String slackBotToken = System.getenv("SLACK_BOT_TOKEN");
    logger.info("Bot token: " + slackBotToken);
    SlackSession session = SlackSessionFactory.createWebSocketSlackSession(slackBotToken);
    session.connect();
    logger.info("=> Connected to slack <=");
    MessageListener listener = new MessageListener();
    listener.registerListener(session);
}
 
开发者ID:sjsucohort6,项目名称:amigo-chatbot,代码行数:13,代码来源:MessageListener.java

示例4: main

import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入依赖的package包/类
public static void main(String[] args) throws IOException, JMSException {

        System.out.println("starting slack channel listener....");
        new BatheTimeWatcher().startWatching();
		String authToken = System.getenv("authToken");
		SlackSession session = SlackSessionFactory.createWebSocketSlackSession(authToken);
        session.addMessagePostedListener(new MessageListener());
        session.connect();
    }
 
开发者ID:ClearPointNZ,项目名称:connect-sample-apps,代码行数:10,代码来源:SlackListenerApplication.java

示例5: triggerFinalized

import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入依赖的package包/类
@Override
public void triggerFinalized(Trigger trigger) {

    SlackSession session = SlackSessionFactory.createWebSocketSlackSession(token);
    try {
        session.connect();
    } catch (IOException e) {
        LOG.error(e.getMessage());
    }
    SlackChannel channel = session.findChannelByName(this.channel);
    session.sendMessage(channel, "Data Provider has finished.");
}
 
开发者ID:visp-streaming,项目名称:dataProvider,代码行数:13,代码来源:SlackSchedulerListener.java

示例6: getSlackSession

import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入依赖的package包/类
private SlackSession getSlackSession() {
    try {
        SlackSession slackSession = SlackSessionFactory.createWebSocketSlackSession(token);
        slackSession.connect();
        return slackSession;
    } catch (Exception ex) {
        // Because screw checked exceptions
        throw new RuntimeException(ex);
    }
}
 
开发者ID:bobvandenberge,项目名称:publicaties-generator,代码行数:11,代码来源:SlackAPI.java

示例7: slackSession

import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入依赖的package包/类
@Bean
SlackSession slackSession() throws IOException {
	if (null == slackSession) {
		slackSession = SlackSessionFactory.createWebSocketSlackSession(slackProperties.key);
		slackSession.connect();
		log.debug("New session created: {}", slackSession);
		slackSession.addMessagePostedListener(mycroftListener());
	}
	return slackSession;
}
 
开发者ID:MycroftAI,项目名称:mycroft-slackbot,代码行数:11,代码来源:SlackConfig.java

示例8: slackSession

import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入依赖的package包/类
@Bean
public SlackSession slackSession() throws IOException {
    slackSession = SlackSessionFactory.createWebSocketSlackSession(slackBotToken);
    slackSession.connect();

    return slackSession;
}
 
开发者ID:joelchartier,项目名称:slackbot-pomodoro,代码行数:8,代码来源:SlackSessionConfiguration.java

示例9: connect

import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入依赖的package包/类
public void connect() throws IOException {
	SlackSession session = SlackSessionFactory
			.createWebSocketSlackSession(getAPIKey());
	session.connect();
	session.addMessagePostedListener(this);
	updateSession(session);
	beginHeartbeat();
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:9,代码来源:WatchWordBot.java

示例10: provideSlackSession

import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入依赖的package包/类
@Singleton
@Provides
public SlackSession provideSlackSession(
    @Named("slack.bot.token") String token
) {
    return SlackSessionFactory.createWebSocketSlackSession(token);
}
 
开发者ID:JujaLabs,项目名称:microservices,代码行数:8,代码来源:SlackModule.java

示例11: main

import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
    Properties parameters = new Properties();
    parameters.load(new FileReader(DEFAULT_PROPERTIES_FILE));
    if (!parameters.containsKey(Constants.GERRIT_URL))
    {
        throw new IllegalArgumentException("missing property '" + Constants.GERRIT_URL + "' in " + DEFAULT_PROPERTIES_FILE);
    }
    if (!parameters.containsKey(Constants.CHANGE_INFO_FORMATTER_CLASS))
    {
        throw new IllegalArgumentException("missing property '" + Constants.CHANGE_INFO_FORMATTER_CLASS + "' in " + DEFAULT_PROPERTIES_FILE);
    }
    injector = Guice.createInjector(new BaseModule(parameters));
    SlackSession session;
    if (parameters.containsKey(Constants.PROXY_HOST))
    {
        String proxyURL = parameters.getProperty(Constants.PROXY_HOST);
        int proxyPort = Integer.parseInt(parameters.getProperty(Constants.PROXY_PORT, "80"));
        session = SlackSessionFactory.getSlackSessionBuilder(parameters.getProperty(Constants.BOT_TOKEN)).withProxy(Proxy.Type.HTTP, proxyURL, proxyPort).build();
    }
    else
    {
        session = SlackSessionFactory.createWebSocketSlackSession(parameters.getProperty(Constants.BOT_TOKEN));
    }
    ReviewRequestService reviewRequestService = Connector.injector.getProvider(ReviewRequestService.class).get();
    GerritChangeInfoService gerritChangeInfoService = Connector.injector.getProvider(GerritChangeInfoService.class).get();
    ChangeInfoFormatter gerritChangeDecorator = Connector.injector.getProvider(ChangeInfoFormatter.class).get();
    session.addMessagePostedListener(new ReviewMessageListener());
    scheduledExecutor.scheduleAtFixedRate(new ReviewRequestCleanupTask(reviewRequestService, gerritChangeInfoService, gerritChangeDecorator, session, scheduledExecutor), 1, 5, TimeUnit.MINUTES);
    session.connect();

    Thread.sleep(Long.MAX_VALUE);
}
 
开发者ID:Ullink,项目名称:slack4gerrit,代码行数:34,代码来源:Connector.java

示例12: initialize

import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入依赖的package包/类
/**
 * Initialization of slack connection and slack channels
 */
public void initialize() {
    if (Strings.isNullOrEmpty(slackBotToken)) {
        LOG.warn("No Slack Bot Token, Slack Integration will not broadcast at all");
    } else {
        try {
            slackSession = SlackSessionFactory
                    .createWebSocketSlackSession(slackBotToken);
            slackSession.connect();
            if (Strings.isNullOrEmpty(slackVerboseChannel)) {
                LOG.warn("No Slack Verbose Channel, Slack Integration will not broadcast success/failures");
            } else {
                verboseChannel = slackSession.findChannelByName(slackVerboseChannel);
                if (verboseChannel == null) {
                    LOG.warn(String.format("Verbose Channel %s not found, Slack Integration will not broadcast success/failures", slackVerboseChannel));
                } else {
                    slackSession
                            .joinChannel(slackVerboseChannel);
                }
            }
            if (Strings.isNullOrEmpty(slackDigestChannel)) {
                LOG.warn("No Slack Digest Channel, Slack Integration will not broadcast summaries");
            } else {
                digestChannel = slackSession.findChannelByName(slackDigestChannel);
                if (digestChannel == null) {
                    LOG.warn(String.format("Digest Channel %s not found, Slack Integration will not broadcast summaries", slackDigestChannel));
                } else {
                    slackSession
                            .joinChannel(slackDigestChannel);
                }
            }
        } catch (IOException e) {
            LOG.warn(String.format("Could not create session with token %s, Slack Integration will not broadcast at all", slackBotToken), e);
        }
    }
}
 
开发者ID:relateiq,项目名称:AugmentedDriver,代码行数:39,代码来源:SlackIntegration.java

示例13: initialize

import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入依赖的package包/类
@Override
public void initialize(final Botan botan) {

    session = SlackSessionFactory.createWebSocketSlackSession(this.apiToken);
    try {
        session.connect();
    } catch (final IOException e1) {
        log.warn("{}", e1);
    }
    this.botan = botan;
}
 
开发者ID:masahitojp,项目名称:botan-core,代码行数:12,代码来源:SlackRTMAdapter.java

示例14: SlackClient

import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入依赖的package包/类
@Autowired
public SlackClient(SlackConfiguration slackConfiguration) {
    slack = SlackSessionFactory.createWebSocketSlackSession(slackConfiguration.token);
    this.slackConfiguration = slackConfiguration;
    connectIfNessesary();
}
 
开发者ID:Espenhh,项目名称:panopticon,代码行数:7,代码来源:SlackClient.java

示例15: afterSetup

import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入依赖的package包/类
@Override
public void afterSetup(Map<String, String> options) {
    String botName = getBotName();
    String token = requireString(options, OPTIONS_TOKEN);
    String channelName = requireString(options, OPTIONS_CHANNEL);
    slack = SlackSessionFactory.createWebSocketSlackSession(token);

    // connecting
    try {
        log.info("Connect to channel: {}", channelName);
        slack.connect();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    // find channel
    slackChannel = slack.findChannelByName(channelName);

    // find botId
    String botId = slack.getBots().stream()
                        .filter(bot -> botName.equals(bot.getUserName()))
                        .findFirst()
                        .map(SlackPersona::getId)
                        .orElseThrow(() -> {
                            String message = String.format(
                                    "Cannot find target bot: %s\nPlease set `same` name with plugins.yml "
                                    + "name and slack Customize name.",
                                    botName);
                            return new RuntimeException(message);
                        });
    log.info("Found Slack bot: {}", botId);

    // register listener
    slack.addMessagePostedListener((slackMessagePosted, slackSession) -> {
        log.debug("Received Slack Message: {}", slackMessagePosted);
        String receivedMessage = slackMessagePosted.getMessageContent().trim();
        if (channelName.equals(slackMessagePosted.getChannel().getName())
            && isBotMention(receivedMessage, botName, botId)
            && !isSelfMessage(slackMessagePosted.getSender(), botId)) {
            final SlackUser sender = slackMessagePosted.getSender();
            queue.add(new ReceiveMessage(
                    new Sender(sender.getId(), sender.getUserName(), sender.getUserName(), sender.getUserMail()),
                    omitBotInfo(receivedMessage, botName, botId)));
        }
    });
}
 
开发者ID:krrrr38,项目名称:jabot,代码行数:47,代码来源:SlackAdapter.java


注:本文中的com.ullink.slack.simpleslackapi.impl.SlackSessionFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。