59 static const Uint16 _messages[] = {
161 Log::warn(
"Received GPMSG_SAY for unknown being with id %i."
162 " (Message is: %s)",
id, chatMsg.c_str());
166 std::string mes = being->
getName() +
" : " + chatMsg;
171 event.setString(
"text", chatMsg);
172 event.setString(
"nick", being->
getName());
173 event.setInt(
"beingId",
id);
175 .checkPermissionSilently(being->
getName(),
187 auto *channel =
new Channel(channelId, channelName, announcement);
189 ChatTab *tab = channel->getTab();
193 std::string userModes;
201 if (userModes.find(
'o') != std::string::npos)
221 if (channelName.empty())
223 std::ostringstream numUsers;
225 channelName +=
" - ";
226 channelName += numUsers.str();
238 event.setString(
"nick", userNick);
239 event.setString(
"message", chatMsg);
248 event.setString(
"message", sender +
" : " + chatMsg);
260 channel->getTab()->chatLog(userNick, chatMsg);
265 Log::info(
"Couldn't find chat channel id: %hi", channelId);
282 std::string userNick;
283 std::string userModes;
289 if (userNick.empty())
294 if (userModes.find(
'o') != std::string::npos)
296 userNick =
"@" + userNick;
330 int first = line.find(
":");
331 int second = line.find(
":", first+1);
332 std::string user1 = line.substr(0, first);
333 std::string user2 = line.substr(first+1, second);
334 std::string mode = line.substr(second+1, line.length());
336 "on user %s."), user1.c_str(), mode.c_str(),
342 int first = line.find(
":");
343 std::string user1 = line.substr(0, first);
344 std::string user2 = line.substr(first+1, line.length());
361 if (userNick.empty())
398 const std::string &text)
413 const std::string &password)
ActorSpriteManager * actorSpriteManager
ChannelManager * channelManager
Being * findBeing(int id) const
Returns a specific Being, by id;.
const std::string & getName() const
Returns the name of the being.
Channel * findByName(const std::string &name) const
void addChannel(Channel *channel)
void removeChannel(Channel *channel)
Channel * findById(int id) const
A tab for the chat window.
void chatLog(std::string line, Own own=BY_SERVER, bool ignoreRecord=false)
Adds a line of text to our message list.
static void setState(State state)
void setString(const std::string &key, const std::string &value)
Sets the given variable to the given string, if it isn't already set.
void handleWhoResponse(MessageIn &msg)
Handle who responses.
void handleListChannelsResponse(MessageIn &msg)
Handle list channels responses.
void userList(const std::string &channel) override
void handlePrivateMessage(MessageIn &msg)
Handle private messages.
void enterChannel(const std::string &channel, const std::string &password) override
void handleAnnouncement(MessageIn &msg)
Handle announcements.
void me(const std::string &text) override
void handleQuitChannelResponse(MessageIn &msg)
Handle quit channel responses.
void handleListChannelUsersResponse(MessageIn &msg)
Handle list channel users responses.
void privateMessage(const std::string &recipient, const std::string &text) override
void sendToChannel(int channelId, const std::string &text) override
void handleMessage(MessageIn &msg) override
Handle the given message appropriately.
void kickUser(int channelId, const std::string &name) override
void handleEnterChannelResponse(MessageIn &msg)
Handle channel entry responses.
void channelList() override
void setChannelTopic(int channelId, const std::string &text) override
void setUserMode(int channelId, const std::string &name, int mode) override
void handleChannelEvent(MessageIn &msg)
Handle channel events.
void quitChannel(int channelId) override
void handleGameChatMessage(MessageIn &msg)
Handle chat messages sent from the game server.
void talk(const std::string &text) override
void handleChatMessage(MessageIn &msg)
Handle chat messages.
bool isConnected()
Returns whether the server is connected.
void send(const ManaServ::MessageOut &msg)
Sends a message.
void disconnect()
Disconnects from the given server.
Used for parsing an incoming message from manaserv.
uint16_t readInt16()
Reads an unsigned 16-bit integer from the message.
unsigned int getUnreadLength() const
Returns the length of unread data.
std::string readString(int length=-1)
Reads a string.
uint16_t getId() const
Returns the message ID.
uint8_t readInt8()
Reads an unsigned 8-bit integer from the message.
Used for building an outgoing message to manaserv.
void writeInt16(uint16_t value)
Writes an unsigned 16-bit integer to the message.
void writeInt8(uint8_t value)
Writes an unsigned 8-bit integer to the message.
void writeString(const std::string &string, int length=-1)
Writes a string.
const uint16_t * handledMessages
void serverNotice(const std::string &message)
LocalPlayer * local_player
Net::ChatHandler * chatHandler
void warn(const char *log_text,...) LOG_PRINTF_ATTR
void info(const char *log_text,...) LOG_PRINTF_ATTR
@ CHAT_EVENT_LEAVING_PLAYER
@ CHAT_EVENT_TOPIC_CHANGE
@ CHAT_EVENT_KICKED_PLAYER
Connection * gameServerConnection
Connection * chatServerConnection
@ CPMSG_ENTER_CHANNEL_RESPONSE
@ PCMSG_LIST_CHANNELUSERS
@ CPMSG_QUIT_CHANNEL_RESPONSE
@ CPMSG_LIST_CHANNELUSERS_RESPONSE
@ CPMSG_LIST_CHANNELS_RESPONSE
@ CPMSG_DISCONNECT_RESPONSE
PlayerRelationsManager player_relations
std::string strprintf(char const *format,...)
A safe version of sprintf that returns a std::string of the result.