should fix #2
This commit is contained in:
parent
f6196f3a1f
commit
9dc407180d
|
@ -63,7 +63,7 @@ public class TelegramAPI implements Runnable {
|
||||||
protected int fetchedUpdates = 0;
|
protected int fetchedUpdates = 0;
|
||||||
protected long start = 0;
|
protected long start = 0;
|
||||||
|
|
||||||
private LinkedList<TUser> users = new LinkedList<>();
|
private Map<Long, TUser> users = new TreeMap<>();
|
||||||
@Setter
|
@Setter
|
||||||
private List<Long> admins = new LinkedList<>(); //required for feedback
|
private List<Long> admins = new LinkedList<>(); //required for feedback
|
||||||
private CommandManager cmdmgr = new CommandManager(this);
|
private CommandManager cmdmgr = new CommandManager(this);
|
||||||
|
@ -435,21 +435,24 @@ public class TelegramAPI implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TUser getUser(String name) {
|
public TUser getUser(String name) {
|
||||||
for(TUser us : users) {
|
for(TUser us : users.values()) {
|
||||||
if(us.getName().equals(name))
|
if(us.getName().equals(name))
|
||||||
return us;
|
return us;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TUser getUser(int id) {
|
public TUser getUser(long id, boolean createIfNotExitsts) {
|
||||||
for(TUser us : users) {
|
TUser u = users.get(id);
|
||||||
if(us.getID() == id)
|
if(u != null || !createIfNotExitsts)
|
||||||
return us;
|
|
||||||
}
|
|
||||||
TUser u = new TUser(id, this);
|
|
||||||
users.add(u);
|
|
||||||
return u;
|
return u;
|
||||||
|
u = new TUser(id, this);
|
||||||
|
users.put(id, u);
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TUser getUser(long id) {
|
||||||
|
return getUser(id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -459,12 +462,12 @@ public class TelegramAPI implements Runnable {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public TUser getUser(JSONObject json) {
|
public TUser getUser(JSONObject json) {
|
||||||
int id = json.getInt("id");
|
long id = json.getLong("id");
|
||||||
TUser user = getUser(id);
|
TUser user = getUser(id, false);
|
||||||
if(user != null)
|
if(user != null)
|
||||||
return user;
|
return user;
|
||||||
user = new TUser(json, this);
|
user = new TUser(json, this);
|
||||||
users.add(user);
|
users.put(id, user);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import java.util.TreeMap;
|
||||||
|
|
||||||
public class FeedbackCommand implements JSONCommandHandler {
|
public class FeedbackCommand implements JSONCommandHandler {
|
||||||
|
|
||||||
protected final TInlineKeyboardMarkup cancelMarkup = new TInlineKeyboardMarkup(1);
|
protected final TInlineKeyboardMarkup cancelMarkup = TInlineKeyboardMarkup.makeSingleButton("❌ cancel", CANCELFEEDBACK);
|
||||||
protected final Map<Long, TMessage> awaitingFeedback = new TreeMap<>(); //maps users chat id -> message that said "please send feedback" TODO: make persistent?
|
protected final Map<Long, TMessage> awaitingFeedback = new TreeMap<>(); //maps users chat id -> message that said "please send feedback" TODO: make persistent?
|
||||||
protected final Map<Long, Long[]> awnser = new TreeMap<>(); // chatid -> [chatid, messageid] to awnser to; next message from key will be fwd to value[0] and reply to value[1]
|
protected final Map<Long, Long[]> awnser = new TreeMap<>(); // chatid -> [chatid, messageid] to awnser to; next message from key will be fwd to value[0] and reply to value[1]
|
||||||
protected final TelegramAPI api;
|
protected final TelegramAPI api;
|
||||||
|
@ -27,9 +27,6 @@ public class FeedbackCommand implements JSONCommandHandler {
|
||||||
public FeedbackCommand(TelegramAPI api, List<Long> admins) {
|
public FeedbackCommand(TelegramAPI api, List<Long> admins) {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.admins = (admins == null ? new LinkedList<>() : admins);
|
this.admins = (admins == null ? new LinkedList<>() : admins);
|
||||||
|
|
||||||
//build markup
|
|
||||||
cancelMarkup.addCallbackButton("❌ cancel", CANCELFEEDBACK, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue