本文整理汇总了Java中com.pengrad.telegrambot.model.User类的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
User类属于com.pengrad.telegrambot.model包,在下文中一共展示了User类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateUser
import com.pengrad.telegrambot.model.User; //导入依赖的package包/类
public boolean updateUser(User user) {
UserPrefs savedUser = getUser(user.id());
if (savedUser != null) {
if ((savedUser.userName != null && !savedUser.userName.equals(user.username())) ||
(savedUser.userName == null && user.username() != null)) {
long lastChat = savedUser.lastChatId;
savedUser = Converters.USER_TO_USERPREFS.apply(user);
if (savedUser != null) {
savedUser.lastChatId = lastChat;
}
addUser(savedUser);
return true;
}
}
return false;
}
示例2: addUser
import com.pengrad.telegrambot.model.User; //导入依赖的package包/类
public UserPrefs addUser(User user, long chatId) {
Prefs.UserPrefs newUser = Converters.USER_TO_USERPREFS.apply(user);
if (newUser != null) {
newUser.lastChatId = chatId;
}
addUser(newUser);
return newUser;
}
示例3: apply
import com.pengrad.telegrambot.model.User; //导入依赖的package包/类
@NonNull
@Override
public Prefs.UserPrefs apply(User user) {
Prefs.UserPrefs newUser = new Prefs.UserPrefs();
newUser.id = user.id();
newUser.isNick = user.username() != null;
if (newUser.isNick) {
newUser.userName = user.username();
} else {
newUser.userName = FabricUtils.defaultIfBlank(user.firstName(), "") +
FabricUtils.defaultIfBlank(user.lastName(), "");
}
return newUser;
}
示例4: requestDescription
import com.pengrad.telegrambot.model.User; //导入依赖的package包/类
@Nullable
public BotInfo requestDescription(@NotNull TelegramSettings settings) {
TelegramBot bot = createBot(settings);
GetMeResponse response = bot.execute(new GetMe());
User user = response.user();
if (user == null) {
return null;
}
return new BotInfo(user.firstName(), user.username());
}
示例5: main
import com.pengrad.telegrambot.model.User; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
Properties properties = new Properties();
properties.load(new FileInputStream("local.properties"));
TelegramBot bot = TelegramBotAdapter.build(properties.getProperty("TEST_TOKEN"));
GetUpdatesResponse updatesResponse;
int j = 0;
while (true) {
try {
updatesResponse = bot.execute(new GetUpdates().offset(j).limit(100).timeout(20));
List<Update> updates = updatesResponse.updates();
for (int z = 0; z < updates.size(); z++) {
j = updates.get(z).updateId() + 1;
Message message = updates.get(z).message();
//
Chat chat = message.chat();
User user = message.from();
//String mes=message.text();
// Base64.getEncoder().encodeToString(s.getBytes(StandardCharsets.UTF_8));
if (message.text() != null) {
System.out.println("New message: " + message.text() + " id: " + message.messageId() + " from " + chat);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例6: checkUser
import com.pengrad.telegrambot.model.User; //导入依赖的package包/类
public static void checkUser(User user, boolean full) {
assertNotNull(user.id());
assertNotNull(user.isBot());
assertNotNull(user.firstName());
assertNotNull(user.username());
if (full) {
assertNotNull(user.lastName());
assertNotNull(user.languageCode());
}
}
示例7: getUser
import com.pengrad.telegrambot.model.User; //导入依赖的package包/类
public UserPrefs getUser(User user) {
return usersDataById.get(user.id());
}
示例8: user
import com.pengrad.telegrambot.model.User; //导入依赖的package包/类
public User user() {
return result;
}