本文整理汇总了Java中com.ullink.slack.simpleslackapi.impl.SlackSessionFactory.createWebSocketSlackSession方法的典型用法代码示例。如果您正苦于以下问题:Java SlackSessionFactory.createWebSocketSlackSession方法的具体用法?Java SlackSessionFactory.createWebSocketSlackSession怎么用?Java SlackSessionFactory.createWebSocketSlackSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ullink.slack.simpleslackapi.impl.SlackSessionFactory
的用法示例。
在下文中一共展示了SlackSessionFactory.createWebSocketSlackSession方法的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()
));
}
}
示例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();
}
示例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);
}
示例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();
}
示例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.");
}
示例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);
}
}
示例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;
}
示例8: slackSession
import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入方法依赖的package包/类
@Bean
public SlackSession slackSession() throws IOException {
slackSession = SlackSessionFactory.createWebSocketSlackSession(slackBotToken);
slackSession.connect();
return slackSession;
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例14: SlackClient
import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory; //导入方法依赖的package包/类
@Autowired
public SlackClient(SlackConfiguration slackConfiguration) {
slack = SlackSessionFactory.createWebSocketSlackSession(slackConfiguration.token);
this.slackConfiguration = slackConfiguration;
connectIfNessesary();
}
示例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)));
}
});
}