• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SlackUser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



SlackUser类属于com.ullink.slack.simpleslackapi包,在下文中一共展示了SlackUser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
        }
    }
}
 
开发者ID:sjsucohort6,项目名称:amigo-chatbot,代码行数:26,代码来源:MessageListener.java


示例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);
}
 
开发者ID:DoubleDotLabs,项目名称:ButterySlack,代码行数:20,代码来源:ChannelItemData.java


示例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!");
	}
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:19,代码来源:JoinCommand.java


示例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();
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:26,代码来源:KickCommand.java


示例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);
	}
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:19,代码来源:WatchWordBot.java


示例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;
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:19,代码来源:WatchWordBot.java


示例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;
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:21,代码来源:WatchWordBot.java


示例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();
		}
	}
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:27,代码来源:WatchWordBot.java


示例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;
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:22,代码来源:WatchWordLobby.java


示例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;
}
 
开发者ID:JujaLabs,项目名称:microservices,代码行数:18,代码来源:SlackWebSocketSessionImpl.java


示例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()));
}
 
开发者ID:JujaLabs,项目名称:microservices,代码行数:24,代码来源:SlackJSONParsingUtils.java


示例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;
}
 
开发者ID:JujaLabs,项目名称:microservices,代码行数:20,代码来源:SlackJSONParsingUtils.java


示例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());
    }
}
 
开发者ID:masahitojp,项目名称:botan-core,代码行数:17,代码来源:SlackRTMAdapter.java


示例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);
        }
    }
}
 
开发者ID:sjsucohort6,项目名称:amigo-chatbot,代码行数:13,代码来源:MessageProcessorJob.java


示例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);
    });
}
 
开发者ID:dmitriid,项目名称:tetrad,代码行数:32,代码来源:TetradSlack.java


示例16: getUserById

import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
@Override
public String getUserById(String id) {
    return slackSession
            .getUsers()
            .stream()
            .filter(slackChannel -> slackChannel.getId().equals(id))
            .findFirst()
            .map(SlackUser::getUserName)
            .orElse(id);
}
 
开发者ID:dmitriid,项目名称:tetrad,代码行数:11,代码来源:TetradSlack.java


示例17: onCreate

import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    channelId = getArguments().getString(EXTRA_CHANNEL_ID);

    new Action<SlackChannel>() {
        @NonNull
        @Override
        public String id() {
            return "channel";
        }

        @Nullable
        @Override
        protected SlackChannel run() throws InterruptedException {
            return getButterySlack().session.findChannelById(channelId);
        }

        @Override
        protected void done(@Nullable SlackChannel result) {
            if (result != null) {
                channel = result;
                channelId = result.getId();

                List<SlackUser> members = new ArrayList<>(channel.getMembers());
                if (members.size() > 0) {
                    setTitle(String.format(Locale.getDefault(), getString(R.string.title_instant_name), members.get(0).getUserName()));
                }

                registerListener();
            } else
                Log.e("ChannelFragment", "Channel Id: " + (channelId != null ? channelId : "null"));
        }
    }.execute();
}
 
开发者ID:DoubleDotLabs,项目名称:ButterySlack,代码行数:37,代码来源:InstantMessageFragment.java


示例18: isReply

import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
public boolean isReply() {
    Integer position = getPosition();
    if (position != null) {
        BaseItemAdapter.BaseItem item = getItem(position + 1);
        if (item != null && item instanceof MessageItemData) {
            SlackUser sender = getSender(), otherSender = ((MessageItemData) item).getSender();
            if (sender != null && otherSender != null)
                return sender.getUserName().equals(otherSender.getUserName());
        }
    }

    return false;
}
 
开发者ID:DoubleDotLabs,项目名称:ButterySlack,代码行数:14,代码来源:UserMessageItemData.java


示例19: getChannelName

import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
public static String getChannelName(SlackChannel channel) {
    if (channel.getType() == SlackChannel.SlackChannelType.INSTANT_MESSAGING) {
        List<SlackUser> members = new ArrayList<>(channel.getMembers());
        if (members.size() > 0)
            return members.get(0).getRealName();
    }

    return channel.getName();
}
 
开发者ID:DoubleDotLabs,项目名称:ButterySlack,代码行数:10,代码来源:SlackUtils.java


示例20: stopPomodoro

import com.ullink.slack.simpleslackapi.SlackUser; //导入依赖的package包/类
public void stopPomodoro(SlackUser slackUser) {

        String userName = slackUser.getUserName();

        if (!pomodoroService.pomodoroExists(userName)) {

            slackSession.sendMessageToUser(slackUser,
                    messageSource.getMessage("pomodoro.none.active", null, Locale.ENGLISH), null);
        } else {

            pomodoroService.delete(userName);
            slackSession.sendMessageToUser(slackUser,
                    messageSource.getMessage("command.stop", null, Locale.ENGLISH), null);
        }
    }
 
开发者ID:joelchartier,项目名称:slackbot-pomodoro,代码行数:16,代码来源:PomodoroNotificationService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JumpInsnNode类代码示例发布时间:2022-05-22
下一篇:
Java ClientOperationHeaderProto类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap