本文整理汇总了Java中com.ullink.slack.simpleslackapi.SlackUser类的典型用法代码示例。如果您正苦于以下问题:Java SlackUser类的具体用法?Java SlackUser怎么用?Java SlackUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SlackUser类属于com.ullink.slack.simpleslackapi包,在下文中一共展示了SlackUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processUserMessage
import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
private void processUserMessage(String messageContent, SlackUser messageSender, SlackSession session, SlackChannel channel) {
// TODO change it to be processed asynchronously
// Parse the message content
String parsedMessage = parseMessage(messageContent);
if (parsedMessage != null) {
logger.info("=> Received message from amigo bot:" + parsedMessage);
try {
// Some unique job name
String jobName = "SLACK-MESG-JOB-" + UUID.randomUUID().toString();
String groupName = JOB_GRP_SLACKBOT;
JobDataMap params = new JobDataMap();
params.put(JOB_PARAM_MESSAGE, parsedMessage);
params.put(JOB_PARAM_MSG_SENDER, messageSender);
params.put(JOB_PARAM_SLACK_SESSION, session);
params.put(JOB_PARAM_SLACK_CHANNEL, channel);
params.put(JOB_PARAM_BOT_TOK, System.getenv("SLACK_BOT_TOKEN"));
logger.info("Processing message async with params: " + params);
JobManager.getInstance().scheduleJob(SlackMessageProcessorJob.class, jobName, groupName, params);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error in processing message", e);
}
}
}
示例2: onBindViewHolder
import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
if (channel.getType() == SlackChannel.SlackChannelType.INSTANT_MESSAGING) {
holder.prefix.setText("@");
List<SlackUser> members = new ArrayList<>(channel.getMembers());
if (members.size() > 0) {
SlackUser member = members.get(0);
holder.title.setText(member.getUserName());
holder.subtitle.setText(member.getRealName());
}
} else {
holder.prefix.setText("#");
holder.title.setText(channel.getName());
holder.subtitle.setText(subtitle);
}
holder.itemView.setOnClickListener(this);
}
示例3: run
import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的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!");
}
}
示例4: run
import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的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();
}
示例5: addGuesseePointActivityForMessage
import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
private void addGuesseePointActivityForMessage(SlackUser user) {
if (getLobby() == null) {
return;
}
Player player = getLobby().getPlayer(user);
if (player == null) {
return;
}
Faction faction = getLobby().getTurnOrder().getFactionFor(player);
if (faction == null) {
return;
}
if (faction.getLeader() != player) {
recordELOEvent(ELOEvent.GUESSER_SENT_PLAINTEXT_MESSAGE, player);
}
}
示例6: printWordSmithInstructions
import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
public String printWordSmithInstructions(SlackUser user,
SlackUser opponent, Faction yourFaction, Faction assassinFaction) {
String out = "";
out += "Hi "
+ getUsernameString(user)
+ ", as the Word Smith, try to get your team to guess all of the words marked with "
+ yourFaction.getName() + " *"
+ printAbbreviatedFaction(yourFaction) + "*.\n";
out += "The only information you can give your team each turn is a single word, and the number of guesses your team can make. When you're ready, type ```clue``` to give your team a word.\n";
out += "If your team guesses the Assassin card "
+ printAbbreviatedFaction(assassinFaction)
+ ", the game is immediately over. Try your best to avoid hinting at the assassin.\n";
out += "If you aren't sure if your clue is legal, feel free to pm "
+ getUsernameString(opponent, true)
+ "and ask for clarification.\n";
out += "Good luck!";
return out;
}
示例7: getUserRating
import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
private Rating getUserRating(SlackUser user, boolean isLeader) {
if (!this.getSessionFactory().isPresent()) {
return null;
}
Rating rating = null;
Session session = null;
try {
session = getSessionFactory().get().openSession();
session.beginTransaction();
rating = RatingHelper.getRatingForUser(user, isLeader, session);
session.getTransaction().commit();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (session != null) {
session.close();
}
}
return rating;
}
示例8: assignGBPs
import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
private void assignGBPs(int gbps, String messageText, Player winner) {
if (!this.getSessionFactory().isPresent()) {
return;
}
SlackUser user = this.getLobby().getUser(winner);
Session session = null;
try {
session = getSessionFactory().get().openSession();
session.beginTransaction();
UserEntity entity = UserHelper.readOrCreateUserEntity(user.getId(),
user.getUserName(), session);
int oldGBPs = entity.getGBPs();
entity.setGBPs(oldGBPs + gbps);
session.saveOrUpdate(entity);
session.getTransaction().commit();
String text = messageText + " (+*" + gbps + "*). You now have *"
+ entity.getGBPs() + "* gbps!";
getSession().sendMessageToUser(user, text, null);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (session != null) {
session.close();
}
}
}
示例9: findUserByUsername
import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
public static SlackUser findUserByUsername(String targetUsername,
boolean caseInsensitivity, boolean partialMatch,
Collection<SlackUser> users) {
for (SlackUser user : users) {
String currentUsername = user.getUserName();
if (caseInsensitivity) {
targetUsername = targetUsername.toLowerCase();
currentUsername = currentUsername.toLowerCase();
}
if (partialMatch) {
if (currentUsername.startsWith(targetUsername)) {
return user;
}
} else {
if (currentUsername.equals(targetUsername)) {
return user;
}
}
}
return null;
}
示例10: openMultipartyDirectMessageChannel
import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
@Override
public SlackMessageHandle<SlackChannelReply> openMultipartyDirectMessageChannel(SlackUser... users)
{
SlackMessageHandleImpl<SlackChannelReply> handle = new SlackMessageHandleImpl<SlackChannelReply>(getNextMessageId());
Map<String, String> arguments = new HashMap<>();
arguments.put("token", authToken);
StringBuilder strBuilder = new StringBuilder();
for (int i = 0 ; i < users.length ; i++) {
if (i != 0) {
strBuilder.append(',');
}
strBuilder.append(users[i].getId());
}
arguments.put("users", strBuilder.toString());
postSlackCommand(arguments, MULTIPARTY_DIRECT_MESSAGE_OPEN_CHANNEL_COMMAND, handle);
return handle;
}
示例11: buildSlackUser
import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
static final SlackUser buildSlackUser(JSONObject jsonUser)
{
String id = (String) jsonUser.get("id");
String name = (String) jsonUser.get("name");
String realName = (String) jsonUser.get("real_name");
String tz = (String) jsonUser.get("tz");
String tzLabel = (String) jsonUser.get("tz_label");
Long tzOffset = ((Long) jsonUser.get("tz_offset"));
Boolean deleted = ifNullFalse(jsonUser, "deleted");
Boolean admin = ifNullFalse(jsonUser, "is_admin");
Boolean owner = ifNullFalse(jsonUser, "is_owner");
Boolean primaryOwner = ifNullFalse(jsonUser, "is_primary_owner");
Boolean restricted = ifNullFalse(jsonUser, "is_restricted");
Boolean ultraRestricted = ifNullFalse(jsonUser, "is_ultra_restricted");
Boolean bot = ifNullFalse(jsonUser, "is_bot");
JSONObject profileJSON = (JSONObject) jsonUser.get("profile");
String email = "";
if (profileJSON != null)
{
email = (String) profileJSON.get("email");
}
return new SlackUserImpl(id, name, realName, email, deleted, admin, owner, primaryOwner, restricted, ultraRestricted, bot, tz, tzLabel, tzOffset == null ? null : new Integer(tzOffset.intValue()));
}
示例12: buildSlackChannel
import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
static final SlackChannelImpl buildSlackChannel(JSONObject jsonChannel, Map<String, SlackUser> knownUsersById)
{
String id = (String) jsonChannel.get("id");
String name = (String) jsonChannel.get("name");
String topic = null; // TODO
String purpose = null; // TODO
SlackChannelImpl toReturn = new SlackChannelImpl(id, name, topic, purpose, false);
JSONArray membersJson = (JSONArray) jsonChannel.get("members");
if (membersJson != null)
{
for (Object jsonMembersObject : membersJson)
{
String memberId = (String) jsonMembersObject;
SlackUser user = knownUsersById.get(memberId);
toReturn.addUser(user);
}
}
return toReturn;
}
示例13: say
import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
@Override
public void say(final BotanMessage message) {
SlackChannel slackSession = session.findChannelByName(message.getTo());
if (slackSession == null) {
slackSession = session.findChannelById(message.getTo());
}
if (slackSession == null) {
final SlackUser user = session.findUserByUserName(message.getTo());
if(user != null)slackSession = session.findChannelById(user.getId());
}
if (slackSession != null) {
session.sendMessageOverWebSocket(slackSession, message.getBody());
} else {
log.warn("reply failure {}", message.getTo());
}
}
示例14: sendMessageToUser
import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
private void sendMessageToUser(String userEmail, SlackSession session, String channelId, String message) {
if (channelId != null && !channelId.trim().isEmpty()) {
SlackChannel channel = session.findChannelById(channelId);
session.sendMessage(channel, message);
} else {
if (userEmail != null && !userEmail.trim().isEmpty()) {
SlackUser slackUser = session.findUserByEmail(userEmail);
session.sendMessageToUser(slackUser, message, null);
}
}
}
示例15: onEvent
import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
public void onEvent(SlackMessagePosted event, SlackSession session) {
SlackUser sender = event.getSender();
FirehoseMessage firehoseMessage = new FirehoseMessage(
"slack",
"post",
sender.getUserName(),
slackConfig.identifier,
event.getChannel().getName(),
event.getMessageContent()
);
logger.info("Got post event from service: " + firehoseMessage.toLogString());
Boolean isBot = slackConfig.ignore.getOrDefault(sender.getUserName(), null);
if (isBot != null && isBot == sender.isBot()) {
logger.info(MessageFormat.format("Ignore user {0} due to config", sender.getUserName()));
return;
}
for (ITransformer transfomer : transformers) {
firehoseMessage = transfomer.transform(firehoseMessage, this);
}
if (!firehoseMessage.content.isEmpty())
callback.execute(firehoseMessage);
FirehoseMessage possibleFollowup = new TransformSlackNiceties().transform(firehoseMessage, this, event);
Optional.ofNullable(possibleFollowup).ifPresent(msg -> {
callback.execute(msg);
});
}