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


Java SlackMessagePosted类代码示例

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


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

示例1: getLastWeeksMessages

import com.ullink.slack.simpleslackapi.events.SlackMessagePosted; //导入依赖的package包/类
private List<SlackMessagePosted> getLastWeeksMessages() {
    SlackSession slackSession = getSlackSession();

    SlackChannel slackChannel = slackSession.findChannelByName("publicaties");

    ChannelHistoryModule channelHistoryModule = ChannelHistoryModuleFactory.createChannelHistoryModule(slackSession);

    List<SlackMessagePosted> lastWeeksMesages = IntStream.of(7, 6, 5, 4, 3, 2, 1)
            .mapToObj(daysAgo -> LocalDate.now().minus(daysAgo, ChronoUnit.DAYS))
            .flatMap(date -> getMessagesOfDay(slackChannel, channelHistoryModule, date))
            .collect(toList());

    try {
        slackSession.disconnect();
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }

    return lastWeeksMesages;
}
 
开发者ID:bobvandenberge,项目名称:publicaties-generator,代码行数:21,代码来源:SlackAPI.java

示例2: generatePost

import com.ullink.slack.simpleslackapi.events.SlackMessagePosted; //导入依赖的package包/类
private String generatePost(final List<SlackMessagePosted> publicaties) {
    String content = "";

    content += "Hieronder is de lijst met #publicaties van deze week (" + WeekUtil.getWeekNumber() + ") te vinden. Veel leesplezier!";

    content += System.lineSeparator();

    content += IntStream.range(0, publicaties.size())
            .mapToObj(index -> (index + 1) + ". " + messageParser.parse(publicaties.get(index).getMessageContent()))
            .reduce("", (identity, accu) -> identity + System.lineSeparator() + accu);

    content += System.lineSeparator() + System.lineSeparator();

    String publicators = publicaties.stream()
            .map(message -> message.getSender().getUserName())
            .distinct()
            .reduce((identity, accu) -> identity + ", @" + accu).get();

    content += "De lijst is deze week mogelijk gemaakt door @" + publicators + ". Bedankt!";
    content += System.lineSeparator() + System.lineSeparator();
    content += "Kom je een interessante publicatie (foto/video/textueel) tegen? Deel deze dan in het #publicaties kanaal zodat iedereen er van kan leren :slightly_smiling_face:";
    content += System.lineSeparator() + System.lineSeparator();
    content += "Nog een fijne zondag!";

    return content;
}
 
开发者ID:bobvandenberge,项目名称:publicaties-generator,代码行数:27,代码来源:PublicatiesGenerator.java

示例3: getImageFromIntegrations

import com.ullink.slack.simpleslackapi.events.SlackMessagePosted; //导入依赖的package包/类
private FirehoseMessage getImageFromIntegrations(IAdapter service, SlackMessagePosted event) {
  SlackAttachment attachment = event.getAttachments().get(0);

  String userName = event.getSender().getUserName();

  if(!userName.equals("RightGIF") && !userName.equals("ZOMG Memes!")) {
    return null;
  }

  return new FirehoseMessage(
      "slack",
      "post",
      userName,
      service.getIdentifier(),
      event.getChannel().getName(),
      attachment.getImageUrl()
  );
}
 
开发者ID:dmitriid,项目名称:tetrad,代码行数:19,代码来源:TransformSlackNiceties.java

示例4: run

import com.ullink.slack.simpleslackapi.events.SlackMessagePosted; //导入依赖的package包/类
@Override
public void run(WatchWordBot bot, SlackMessagePosted event,
		LinkedList<String> args, SlackSession session) {
	if (args.isEmpty()) {
		fireIncorrectUsage();
		return;
	}

	String banishedWord = args.pop();

	boolean match = bot.getWordGenerator().isWordPresent(banishedWord);

	if (!match) {
		session.sendMessage(event.getChannel(), "'" + banishedWord
				+ "' not found in wordlist.");
		return;
	}

	session.sendMessage(event.getChannel(),
			"Banish command not implemented.");

}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:23,代码来源:BanishCommand.java

示例5: run

import com.ullink.slack.simpleslackapi.events.SlackMessagePosted; //导入依赖的package包/类
@Override
public void run(WatchWordBot bot, SlackMessagePosted event,
		LinkedList<String> args, SlackSession session) {
	SlackUser newUser = event.getSender();
	if (!bot.getLobby().hasUser(newUser)) {
		bot.getLobby().addUser(newUser);
		session.sendMessage(bot.getCurrentChannel(),
				WatchWordBot.getUsernameString(event.getSender())
						+ " has joined the game!");
		session.sendMessage(bot.getCurrentChannel(), bot.printFactions());
		bot.printMatchQuality();

	} else {
		session.sendMessage(event.getChannel(),
				WatchWordBot.getUsernameString(event.getSender())
						+ ", you're already in the game!");
	}
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:19,代码来源:JoinCommand.java

示例6: run

import com.ullink.slack.simpleslackapi.events.SlackMessagePosted; //导入依赖的package包/类
@Override
public void run(WatchWordBot bot, SlackMessagePosted event,
		LinkedList<String> args, SlackSession session) {
	int penaltyAmount = 0;

	if (!args.isEmpty()) {
		try {
			penaltyAmount = Integer.parseInt(args.pop());
			if (penaltyAmount < 0) {
				throw new IllegalArgumentException(
						"Penalty severity must be >= 0");
			}
		} catch (Exception e) {
			bot.printUsage(event.getChannel(), this.getPrimaryAlias()
					+ " <severity(0+)>");
			return;
		}
	}

	bot.penalizeCurrentFaction(penaltyAmount);
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:22,代码来源:PenaltyCommand.java

示例7: run

import com.ullink.slack.simpleslackapi.events.SlackMessagePosted; //导入依赖的package包/类
@Override
public void run(WatchWordBot bot, SlackMessagePosted event,
		LinkedList<String> args, SlackSession session) {
	if (bot.getGameState() == GameState.GAME) {
		session.sendMessage(
				bot.getCurrentChannel(),
				"Game has been canceled by "
						+ WatchWordBot.getUsernameString(event.getSender()));
		bot.partialGameReset();
		session.sendMessage(bot.getCurrentChannel(), bot.printFactions());
	} else {
		session.sendMessage(
				bot.getCurrentChannel(),
				"Lobby has been canceled by "
						+ WatchWordBot.getUsernameString(event.getSender()));
		bot.fullGameReset();
	}
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:19,代码来源:CancelCommand.java

示例8: run

import com.ullink.slack.simpleslackapi.events.SlackMessagePosted; //导入依赖的package包/类
@Override
public void run(WatchWordBot bot, SlackMessagePosted event,
		LinkedList<String> args, SlackSession session) {
	if (args.isEmpty()) {
		bot.printUsage(event.getChannel(),
				"[kick|remove] <player1, player2, ...>");
		return;
	}
	while (!args.isEmpty()) {
		String username = args.pop();
		SlackUser user = bot.getLobby().findUserByUsername(username);
		if (user != null) {
			bot.getLobby().removeUser(user);
			session.sendMessage(bot.getCurrentChannel(),
					event.getSender().getUserName() + " removed "
							+ WatchWordBot.getUsernameString(user));
		} else {
			session.sendMessage(bot.getCurrentChannel(),
					"Could not find user already in game with username '"
							+ username + "'.");
		}
	}
	session.sendMessage(bot.getLobby().getChannel(), bot.printFactions());
	bot.printMatchQuality();
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:26,代码来源:KickCommand.java

示例9: run

import com.ullink.slack.simpleslackapi.events.SlackMessagePosted; //导入依赖的package包/类
@Override
public void run(WatchWordBot bot, SlackMessagePosted event,
		LinkedList<String> args, SlackSession session) {

	if (bot.getGame().getActingFaction() == null) {
		session.sendMessage(event.getChannel(),
				"Game is currently in an invalid state, there is currently no acting faction!");
		return;
	}
	CompetitiveTime time = bot.getGame().getRemainingTime();
	if (time == null) {
		session.sendMessage(event.getChannel(),
				"There is currently no timer enabled for the "
						+ bot.getGame().getActingFaction().getName()
						+ " team.");
		return;
	}
	session.sendMessage(event.getChannel(),
			"Remaining time for the "
					+ bot.getGame().getActingFaction().getName()
					+ " team: " + time.getTime(TimeUnit.SECONDS)
					+ " secs. (" + time.getOvertime(TimeUnit.SECONDS)
					+ " secs. of overtime)");
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:25,代码来源:TimeCommand.java

示例10: run

import com.ullink.slack.simpleslackapi.events.SlackMessagePosted; //导入依赖的package包/类
@Override
public void run(WatchWordBot bot, SlackMessagePosted event,
		LinkedList<String> args, SlackSession session) {
	if (bot.getLobby().getPlayer(event.getSender()) == null) {
		session.sendMessage(event.getChannel(),
				WatchWordBot.getUsernameString(event.getSender())
						+ ", you are currently not in this game!");
		return;
	}
	if (args.isEmpty()) {
		bot.printUsage(event.getChannel(), "guess <word>");
		return;
	}

	String wordBeingGuessed = args.pop();
	bot.makeGuess(wordBeingGuessed, session, event.getChannel(),
			event.getSender());
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:19,代码来源:GuessCommand.java

示例11: handleCommand

import com.ullink.slack.simpleslackapi.events.SlackMessagePosted; //导入依赖的package包/类
private synchronized void handleCommand(SlackMessagePosted event,
		SlackSession session) {
	updateLastIssuedCommandTime();
	LinkedList<String> args = new LinkedList<String>();
	args.addAll(Arrays.asList(event.getMessageContent().split("\\s+")));// event.getMessageContent().split(" ");

	boolean matchingPrefix = true;
	if (DEBUG) {
		String debugPrefix = args.pop().toLowerCase();
		matchingPrefix = debugPrefix.equals("d");
	}

	if (matchingPrefix) {
		String commandText = args.pop().toLowerCase();
		List<Command> commands = generateCommands(event, args, session);
		Command matchingCommand = findMatchingCommand(commandText, args,
				commands, event.getChannel());
		if (matchingCommand != null) {
			matchingCommand.run(this, event, args, session);
		}
	} else {
		handlePlainTextMessage(event, session);
	}
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:25,代码来源:WatchWordBot.java

示例12: generateCommands

import com.ullink.slack.simpleslackapi.events.SlackMessagePosted; //导入依赖的package包/类
public List<Command> generateCommands(final SlackMessagePosted event,
		final LinkedList<String> args, final SlackSession session) {
	List<Command> commands = new ArrayList<Command>();
	commands.add(new BanishCommand());
	commands.add(new BotCommand());
	commands.add(new CancelCommand());
	commands.add(new ClueCommand());
	commands.add(new DefineCommand());
	commands.add(new EndCommand());
	commands.add(new FeatCommand());
	commands.add(new GridCommand());
	commands.add(new GuessCommand());
	commands.add(new HelpCommand());
	commands.add(new JoinCommand());
	commands.add(new KickCommand());
	commands.add(new ListCommand());
	commands.add(new LobbyCommand());
	commands.add(new PenaltyCommand());
	commands.add(new StartCommand());
	commands.add(new SwapCommand());
	commands.add(new SyncCommand());
	commands.add(new TimeCommand());
	commands.add(new WinCommand());
	return commands;
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:26,代码来源:WatchWordBot.java

示例13: onEvent

import com.ullink.slack.simpleslackapi.events.SlackMessagePosted; //导入依赖的package包/类
@Override
public void onEvent(
    final SlackMessagePosted event, final SlackSession session
) {
    final String channel = event.getChannel().getId();
    if (this.channel.equals(channel)) {
        final User user = new User.UserBuilder().withSlackNick(
            event.getSender().getUserName()
        ).build();
        final List<String> codes = Stream.of(
            event.getMessageContent().split("\n")
        ).filter(
            code -> this.progress.codes().contains(code)
        ).collect(Collectors.toList());
        if (!codes.isEmpty()) {
            this.progress.markProgressDone(user, codes.toArray(
                new String[codes.size()])
            );
            this.progress.reactToUserCodes(event.getTimeStamp(), channel);
        }
    }
}
 
开发者ID:JujaLabs,项目名称:microservices,代码行数:23,代码来源:ProgressSlackChannel.java

示例14: marksProgressDoneIfMatchesCodes

import com.ullink.slack.simpleslackapi.events.SlackMessagePosted; //导入依赖的package包/类
/**
 * ProgressSlackChannel can mark codes done with service.
 */
@Test
public void marksProgressDoneIfMatchesCodes() throws Exception {
    final ProgressService service = Mockito.mock(ProgressService.class);
    final String id = "D0FUQEQUF";
    final ProgressSlackChannel channel = new ProgressSlackChannel(
        id, service
    );
    Mockito.when(service.codes()).thenReturn(
        new HashSet<>(Arrays.asList(
            "+code1", "+code2"
        ))
    );
    final String user = "juja";
    final SlackMessagePosted message = this.createMessageWithUserAndChannel(
        id, user, "+code2\n+code3\n+code1"
    );
    channel.onEvent(message, Mockito.mock(SlackSession.class));
    Mockito.verify(service).markProgressDone(
        new User.UserBuilder().withSlackNick(user).build(),
        "+code2", "+code1"
    );
}
 
开发者ID:JujaLabs,项目名称:microservices,代码行数:26,代码来源:ProgressSlackChannelTest.java

示例15: filtersChannel

import com.ullink.slack.simpleslackapi.events.SlackMessagePosted; //导入依赖的package包/类
/**
 * ProgressSlackChannel can filter channel.
 */
@Test
public void filtersChannel() throws Exception {
    final ProgressService service = Mockito.mock(ProgressService.class);
    final ProgressSlackChannel channel = new ProgressSlackChannel(
        "D0FUQEQUF", service
    );
    Mockito.when(service.codes()).thenReturn(
        new HashSet<>(Arrays.asList(
            "+code1", "+code2"
        ))
    );
    final String user = "juja";
    final SlackMessagePosted message = this.createMessageWithUserAndChannel(
        "AnotherChannelId", user, "+code2\n+code3\n+code1"
    );
    channel.onEvent(message, Mockito.mock(SlackSession.class));
    Mockito.verify(service, Mockito.never()).markProgressDone(
        new User.UserBuilder().withSlackNick(user).build(),
        "+code2", "+code1"
    );
}
 
开发者ID:JujaLabs,项目名称:microservices,代码行数:25,代码来源:ProgressSlackChannelTest.java


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