本文整理汇总了Java中org.kitteh.irc.client.library.Client类的典型用法代码示例。如果您正苦于以下问题:Java Client类的具体用法?Java Client怎么用?Java Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Client类属于org.kitteh.irc.client.library包,在下文中一共展示了Client类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
@Override
public boolean init(String botId, Map<String, String> configs, String[] channels) {
logger = LogManager.getLogger(IrcBot.class.getSimpleName() + ":" + botId);
if (!configs.containsKey(USERNAME_KEY))
return false;
if (!configs.containsKey(HOST_KEY))
return false;
client = Client.builder()
.nick(configs.get(USERNAME_KEY))
.serverHost(configs.get(HOST_KEY))
.listenInput(line -> logger.debug("[I]: " + line))
.listenOutput(line -> logger.debug("[O]: " + line))
.listenException(logger::error)
.defaultMessageMap(new SimpleDefaultMessageMap())
.build();
client.getEventManager().registerEventListener(this);
this.botId = botId;
this.configs = configs;
this.channels = channels;
return true;
}
开发者ID:KDE,项目名称:brooklyn,代码行数:26,代码来源:IrcBot.java
示例2: buildClient
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
/**
* Builds the client for KICL. The client will be in the process of
* connecting to the server when this method returns.
*
* @return the built client
*/
@Nonnull
private Client buildClient()
{
final ClientBuilder builder = Client.builder();
final String password = config.values().get("password").toString();
builder.server(ConfigUtils.getString(config, "server"));
builder.server(ConfigUtils.getInt(config, "port"));
builder.nick(ConfigUtils.getString(config, "nick"));
if (! password.isEmpty()) {
builder.serverPassword(password);
}
return builder.build();
}
开发者ID:tmazeika,项目名称:ExplodingKittens,代码行数:23,代码来源:EKBot.java
示例3: createBot
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
public void createBot()
{
final ClientBuilder builder = Client.builder()
.user(prop("login", prop("nick"))) // login, default to nick
.server(prop("server")) // server
.server(Integer.parseInt(prop("port", "6666"))) // port, default to 6666
.nick(prop("nick")); // nick
if (isPropSet("password")) builder.serverPassword(prop("password")); // server password
bot = builder.build();
bot.getEventManager().registerEventListener(new IRCListener(faxDater));
if (isPropSet("channels"))
{
for (String c : prop("channels").split(","))
{
bot.addChannel("#" + c); // channels
}
}
}
开发者ID:tmazeika,项目名称:LolBot,代码行数:23,代码来源:LolBot.java
示例4: sendNotifications
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
public void sendNotifications(@NotNull final User requester, @NotNull final Channel channel, @NotNull final Client client) {
Preconditions.checkNotNull(requester, "requester was null");
Preconditions.checkNotNull(channel, "channel was null");
Preconditions.checkNotNull(client, "client was null");
final List<String> accountsInChannel = channel.getUsers().stream()
.map(User::getAccount)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList());
this.getRegistrations().stream()
.filter(r -> accountsInChannel.contains(r.getServicesAccount()))
.filter(r -> r.hasOption(PingRegistrationOption.RECEIVE))
.filter(r -> !r.getServicesAccount().equalsIgnoreCase(requester.getAccount().orElse(null)))
.forEach(r -> {
final boolean privmsg = r.hasOption(PingRegistrationOption.PRIVMSG);
final Set<User> users = client.getChannels().stream().flatMap(ch -> ch.getUsers().stream()).distinct().filter(user -> r.getServicesAccount().equalsIgnoreCase(user.getAccount().orElse(null))).filter(account -> account != null).collect(Collectors.toSet());
if (r.hasOption(PingRegistrationOption.PING_ALL_AUTHED_NICKS)) {
users.forEach(user -> this.sendNotification(requester, channel, client, user.getNick(), privmsg));
} else {
users.stream().findFirst().ifPresent(user -> this.sendNotification(requester, channel, client, user.getNick(), privmsg));
}
});
}
开发者ID:RoyalDev,项目名称:TheHumanity,代码行数:24,代码来源:PingRegistry.java
示例5: apiViewChannel
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
@ResponseBody
@RequestMapping(value = "/api/channel/{server}/{channel}", method = RequestMethod.GET, produces = APIHelper.PRODUCES)
public String apiViewChannel(@PathVariable String server, @PathVariable final String channel, final HttpServletResponse response) {
final Client client = this.clientService.getFromHostname(server);
final Channel c = this.channelService.getFromName(client, "#" + channel);
if (c == null || !this.channelService.getAll(client).contains(c)) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return APIHelper.makeError("No such channel.");
}
return APIHelper.makeJSON(jw -> {
jw.array();
for (final User user : c.getUsers()) {
jw
.object()
.key("nickname")
.value(user.getNick())
.key("user")
.value(user.getUserString())
.key("hostname")
.value(user.getHost())
.endObject();
}
jw.endArray();
});
}
开发者ID:RoyalDev,项目名称:TheHumanity,代码行数:26,代码来源:ChannelController.java
示例6: apiViewGameRound
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
@ResponseBody
@RequestMapping(value = "/api/game/{server}/{channel}/{round}", method = RequestMethod.GET, produces = APIHelper.PRODUCES)
public String apiViewGameRound(@PathVariable String server, @PathVariable String channel, @PathVariable int round, final HttpServletResponse response) {
final Client client = this.clientService.getFromHostname(server);
final TheHumanityGame g = this.gameService.getFromChannelName(client, "#" + channel);
if (g == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return APIHelper.makeError("No such game");
}
try {
return g.getPreviousRounds().get(round - 1).toJSON();
} catch (final IndexOutOfBoundsException ex) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return APIHelper.makeError("No such round.");
}
}
开发者ID:RoyalDev,项目名称:TheHumanity,代码行数:17,代码来源:GameController.java
示例7: getConfig
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
/**
* Gets a raw ClientConfig object to retrieve Client settings from.
*
* @param client The Client to get settings for
* @return The ClientConfig for the passed Client parameter
*/
public ClientConfig getConfig(Client client) {
if (clientConfigs.containsKey(client)) {
return clientConfigs.get(client);
}
return null;
}
开发者ID:FoxDev,项目名称:FoxBotNG,代码行数:13,代码来源:ClientManager.java
示例8: buildClient
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
/**
* Builds a KittehIRCClientLib client and connects it.
*
* @param config ClientConfig this client gets its settings from
* @return a connected Client
*/
public Client buildClient(ClientConfig config) {
log.info("Connecting {} to {}", config.getBotNick(), config.getServerHost());
Client.Builder clientBuilder = Client.builder().nick(config.getBotNick())
.user(config.getBotIdent())
.realName(config.getBotRealname())
.serverHost(config.getServerHost())
.serverPort(config.getServerPort())
.secure(config.isServerSsl())
.serverPassword(config.getServerPassword())
.messageDelay(0);
if (!config.isVerifySsl() && config.isServerSsl()) {
log.warn("NOT VERIFYING SERVER SSL CERTIFICATE");
log.warn("This is dangerous, consider adding the server certificate to your Java trust store instead.");
clientBuilder.secureTrustManagerFactory(new AcceptingTrustManagerFactory());
}
Client client = clientBuilder.build();
clientConfigs.put(client, config);
client.getEventManager().registerEventListener(new MessageListener());
client.getEventManager().registerEventListener(new ServerListener());
config.getChannels().forEach(client::addChannel);
return client;
}
开发者ID:FoxDev,项目名称:FoxBotNG,代码行数:33,代码来源:ClientManager.java
示例9: sendNotification
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
public void sendNotification(@NotNull final User requester, @NotNull final Channel channel, @NotNull final Client client, @NotNull final String nickname, final boolean privmsg) {
Preconditions.checkNotNull(requester, "requester was null");
Preconditions.checkNotNull(channel, "channel was null");
Preconditions.checkNotNull(client, "client was null");
Preconditions.checkNotNull(nickname, "nickname was null");
final String message = "Your presence has been requested by " + requester.getMessagingName() + " for a game of Cards Against Humanity in " + channel.getMessagingName() + ".";
if (privmsg) {
client.sendMessage(nickname, message);
} else {
client.sendNotice(nickname, message);
}
}
开发者ID:RoyalDev,项目名称:TheHumanity,代码行数:13,代码来源:PingRegistry.java
示例10: getFromChannelName
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
@Override
public TheHumanityGame getFromChannelName(@NotNull final Client client, @NotNull final String channel) {
final Channel actualChannel = client.getChannel(channel).orElse(null);
if (actualChannel == null) {
return null;
}
return this.getFromChannel(actualChannel);
}
开发者ID:RoyalDev,项目名称:TheHumanity,代码行数:9,代码来源:HumanityGameService.java
示例11: getServerInfo
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
@Nullable
@Override
public ServerInfo getServerInfo(@NotNull String hostname) {
final Client client = this.clientService.getFromHostname(hostname);
if (client == null) {
return null;
}
return this.getServerInfo(client);
}
开发者ID:RoyalDev,项目名称:TheHumanity,代码行数:10,代码来源:HumanityServerInfoService.java
示例12: apiViewAllChannels
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
@ResponseBody
@RequestMapping(value = "/api/channels/{server}", method = RequestMethod.GET, produces = APIHelper.PRODUCES)
public String apiViewAllChannels(@PathVariable String server, final HttpServletResponse response) {
final Client client = this.clientService.getFromHostname(server);
return APIHelper.makeObjectMapperJSON(
response,
om -> om.writeValueAsString(this.channelService.getAll(client).stream().map(Channel::getName).collect(Collectors.toSet()))
);
}
开发者ID:RoyalDev,项目名称:TheHumanity,代码行数:10,代码来源:ChannelController.java
示例13: viewChannel
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
@RequestMapping(value = "/channel/{server}/{name}", method = RequestMethod.GET)
public String viewChannel(@PathVariable String server, @PathVariable String name, final Model model) {
final Client client = this.clientService.getFromHostname(server);
final Channel channel = this.channelService.getFromName(client, "#" + name);
if (channel == null || !this.channelService.getAll(client).contains(channel)) {
return "redirect:/";
}
model.addAttribute("channel", channel);
return "channels/channel";
}
开发者ID:RoyalDev,项目名称:TheHumanity,代码行数:11,代码来源:ChannelController.java
示例14: gameInChannel
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
@RequestMapping(value = "/game/{server}/{channel}", method = RequestMethod.GET)
public String gameInChannel(@PathVariable String server, @PathVariable String channel, final Model model) {
final Client client = this.clientService.getFromHostname(server);
final TheHumanityGame g = this.gameService.getFromChannelName(client, "#" + channel);
if (g == null) {
return "redirect:/";
}
model.addAttribute("game", g);
return "games/game";
}
开发者ID:RoyalDev,项目名称:TheHumanity,代码行数:11,代码来源:GameController.java
示例15: ChannelListMessage
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
public ChannelListMessage(Client client) {
this(client.getChannels().stream().map(Channel::getName));
}
开发者ID:bendem,项目名称:IrcSockets,代码行数:4,代码来源:ChannelListMessage.java
示例16: Application
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
public Application(int wsPort, String startupChannel, boolean debug, boolean ircSsl, boolean wsSsl, int ircPort,
String host, String username, String password, String nick, Set<String> userAccounts) {
// TODO Nullcheck stuff
ClientBuilder builder = Client.builder()
.server(host)
.server(ircPort)
.listenException(Throwable::printStackTrace);
if(nick != null) {
builder
.nick(nick)
.realName(nick)
.name(nick);
}
if(username != null) {
builder.user(username);
}
if(password != null) {
builder.serverPassword(password);
}
if(ircSsl) {
builder.secure(true);
}
if(debug) {
WebSocketImpl.DEBUG = true;
builder
.listenInput(i -> System.out.println("> " + i))
.listenOutput(i -> System.out.println("< " + i));
}
client = builder.build();
if(startupChannel != null) {
client.addChannel(startupChannel);
}
client.getEventManager().registerEventListener(new EventManager(this, userAccounts));
messageQueue = new LinkedBlockingQueue<>();
server = new Server(this, messageQueue, wsPort, wsSsl);
}
开发者ID:bendem,项目名称:IrcSockets,代码行数:46,代码来源:Application.java
示例17: getClient
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
public Client getClient() {
return client;
}
开发者ID:bendem,项目名称:IrcSockets,代码行数:4,代码来源:Application.java
示例18: getBot
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
@Override
public Client getBot()
{
return bot;
}
开发者ID:tmazeika,项目名称:LolBot,代码行数:6,代码来源:LolBot.java
示例19: getAllForClient
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
@Override
public Set<TheHumanityGame> getAllForClient(@NotNull final Client client) {
return this.humanity.getGameRegistrar().all().stream().filter(game -> client.getChannels().contains(game.getChannel())).collect(Collectors.toSet());
}
开发者ID:RoyalDev,项目名称:TheHumanity,代码行数:5,代码来源:HumanityGameService.java
示例20: getServerInfo
import org.kitteh.irc.client.library.Client; //导入依赖的package包/类
@NotNull
ServerInfo getServerInfo(@NotNull final Client client);
开发者ID:RoyalDev,项目名称:TheHumanity,代码行数:3,代码来源:ServerInfoService.java
注:本文中的org.kitteh.irc.client.library.Client类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论