The Battle for Wesnoth  1.19.5+dev
chat_events.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 - 2024
3  by Joerg Hinrichs <joerg.hinrichs@alice-dsl.de>
4  Copyright (C) 2003 by David White <dave@whitevine.net>
5  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY.
13 
14  See the COPYING file for more details.
15 */
16 
17 #pragma once
18 
19 class config;
20 #include <ctime>
21 #include <string>
22 
23 namespace events {
24 
26 {
27 public:
28  chat_handler();
29  virtual ~chat_handler();
30 
32 
33  void send_command(const std::string& cmd, const std::string& args="");
34 
35  virtual void send_to_server(const config& cfg) = 0;
36 protected:
37  void do_speak(const std::string& message, bool allies_only=false);
38 
39  //called from do_speak
40  virtual void add_chat_message(const std::time_t& time,
41  const std::string& speaker, int side, const std::string& message,
43  virtual void send_chat_message(const std::string& message, bool allies_only=false) = 0;
44 
45  //Why are these virtual?
46  virtual void send_whisper(const std::string& receiver, const std::string& message);
47 
48  virtual void add_whisper_sent(const std::string& receiver, const std::string& message);
49 
50  virtual void add_whisper_received(const std::string& sender, const std::string& message);
51 
52  virtual void send_chat_room_message(const std::string& room, const std::string& message);
53 
54  virtual void add_chat_room_message_sent(const std::string& room, const std::string& message);
55 
56  virtual void add_chat_room_message_received(const std::string& room,
57  const std::string& speaker, const std::string& message);
58 
59  /**
60  * Called when a processed command results in a relation (friend/ignore) change
61  * for a user whose name is passed as the 'name' arg
62  */
63  virtual void user_relation_changed(const std::string& name);
64 
65  void change_logging(const std::string& data);
66 
67  virtual void clear_messages() = 0;
68 
69  friend class chat_command_handler;
70 };
71 
72 }
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
virtual void add_chat_room_message_received(const std::string &room, const std::string &speaker, const std::string &message)
virtual void send_chat_room_message(const std::string &room, const std::string &message)
virtual void clear_messages()=0
virtual void add_chat_room_message_sent(const std::string &room, const std::string &message)
virtual void user_relation_changed(const std::string &name)
Called when a processed command results in a relation (friend/ignore) change for a user whose name is...
virtual void add_whisper_received(const std::string &sender, const std::string &message)
virtual void add_whisper_sent(const std::string &receiver, const std::string &message)
void do_speak(const std::string &message, bool allies_only=false)
void change_logging(const std::string &data)
Change the log level of a log domain.
Definition: chat_events.cpp:42
virtual void send_chat_message(const std::string &message, bool allies_only=false)=0
virtual void send_whisper(const std::string &receiver, const std::string &message)
virtual void add_chat_message(const std::time_t &time, const std::string &speaker, int side, const std::string &message, MESSAGE_TYPE type=MESSAGE_PRIVATE)=0
virtual void send_to_server(const config &cfg)=0
void send_command(const std::string &cmd, const std::string &args="")
Definition: chat_events.cpp:82
Handling of system events.
std::string_view data
Definition: picture.cpp:178