SHARE
TWEET

Discord Whisper @request

existence_dev92 May 31st, 2020 1,126 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/conf/char_athena.conf b/conf/char_athena.conf
  2. index a99d616..219fd2d 100644
  3. --- a/conf/char_athena.conf
  4. +++ b/conf/char_athena.conf
  5. @@ -284,4 +284,8 @@ mail_return_days: 15
  6.  // Default: 15
  7.  mail_delete_days: 15
  8.  
  9. +//Discord @request integration
  10. +gm_whisp_webhook: on
  11. +gm_whisp_webhook_url:
  12. +
  13.  import: conf/import/char_conf.txt
  14. diff --git a/configure b/configure
  15. index 672d335..9144184 100755
  16. --- a/configure
  17. +++ b/configure
  18. @@ -630,6 +630,9 @@ PCRE_CFLAGS
  19.  PCRE_LIBS
  20.  PCRE_VERSION
  21.  HAVE_PCRE
  22. +LCURL_CFLAGS
  23. +LCURL_LIBS
  24. +HAVE_LCURL
  25.  MYSQL_LIBS
  26.  MYSQL_CFLAGS
  27.  MYSQL_VERSION
  28. @@ -715,6 +718,7 @@ with_mysql
  29.  with_MYSQL_CFLAGS
  30.  with_MYSQL_LIBS
  31.  with_pcre
  32. +with_lcurl
  33.  with_zlib
  34.  '
  35.        ac_precious_vars='build_alias
  36. @@ -1386,6 +1390,7 @@ Optional Packages:
  37.                            to /usr/local or /usr if not found in /usr/local).
  38.                            Assumes that the header files are in DIR/include and
  39.                            the library files are in DIR/lib
  40. +  --with-lcurl            Compile with libcurl? Default no
  41.  
  42.  Some influential environment variables:
  43.    CXX         C++ compiler command
  44. @@ -3557,6 +3562,15 @@ else
  45.  fi
  46.  
  47.  
  48. +#
  49. +# enable libcurl
  50. +#
  51. +if test "${with_lcurl+set}" = set; then :
  52. +  want_lcurl="yes"
  53. +else
  54. +  want_lcurl="no"
  55. +
  56. +
  57.  
  58.  #
  59.  # Specify the path of the zlib library (required library)
  60. @@ -6821,7 +6835,20 @@ fi
  61.  
  62.  
  63.  
  64. -
  65. +#
  66. +# Libcurl Library (optional)
  67. +#
  68. +LCURL_LIBS=""
  69. +LCURL_CFLAGS=""
  70. +if test "$want_lcurl" = "no"; then
  71. +  { $as_echo "$as_me:${as_lineno-$LINENO}: ignoring Libcurl (optional)" >&5
  72. +$as_echo "$as_me: ignoring Libcurl (optional)" >&6;}
  73. +else
  74. +  { $as_echo "$as_me:${as_lineno-$LINENO}: assuming you have libcurl" >&5
  75. +$as_echo "assuming you have libcurl... " >&6; }
  76. +  LCURL_LIBS="-lcurl"
  77. +  HAVE_LCURL="yes"
  78. +fi
  79.  
  80.  
  81.  
  82. diff --git a/src/char/Makefile.in b/src/char/Makefile.in
  83. index 3fddf5e..50af922 100644
  84. --- a/src/char/Makefile.in
  85. +++ b/src/char/Makefile.in
  86. @@ -32,6 +32,13 @@ else
  87.  endif
  88.  ALL_DEPENDS=server
  89.  
  90. +HAVE_LCURL=@HAVE_LCURL@
  91. +ifeq ($(HAVE_LCURL),yes)
  92. +   LCURL_CFLAGS=-DHAVE_LIBCURL -DCURL_STATICLIB @LCURL_CFLAGS@
  93. +else
  94. +   LCURL_CFLAGS=
  95. +endif
  96. +
  97.  @SET_MAKE@
  98.  
  99.  #####################################################################
  100. @@ -57,7 +64,7 @@ help:
  101.  
  102.  char-server: obj $(CHAR_DIR_OBJ) $(LIBCONFIG_AR) $(COMMON_AR) $(YAML_CPP_AR)
  103.     @echo " LD  @OCHR@@EXEEXT@"
  104. -   @@CXX@ @LDFLAGS@ -o ../../@OCHR@@EXEEXT@ $(CHAR_DIR_OBJ) $(LIBCONFIG_AR) $(COMMON_AR) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) $(YAML_CPP_AR) @LIBS@ @MYSQL_LIBS@
  105. +   @@CXX@ @LDFLAGS@ -o ../../@OCHR@@EXEEXT@ $(CHAR_DIR_OBJ) $(LIBCONFIG_AR) $(COMMON_AR) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) $(YAML_CPP_AR) @LIBS@ @MYSQL_LIBS@ @LCURL_LIBS@
  106.  
  107.  needs_mysql:
  108.     @echo "MySQL not found or disabled by the configure script"
  109. @@ -69,11 +76,11 @@ obj:
  110.  
  111.  obj/%.o: %.c $(CHAR_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) $(YAML_CPP_H)
  112.     @echo " CC  $<"
  113. -   @@CC@ @CFLAGS@ $(COMMON_INCLUDE) $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
  114. +   @@CC@ @CFLAGS@ $(COMMON_INCLUDE) $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(LCURL_CFLAGS) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
  115.    
  116.  obj/%.o: %.cpp $(CHAR_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) $(YAML_CPP_H)
  117.     @echo " CXX $<"
  118. -   @@CXX@ @CXXFLAGS@ $(COMMON_INCLUDE) $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
  119. +   @@CXX@ @CXXFLAGS@ $(COMMON_INCLUDE) $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(LCURL_CFLAGS) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
  120.  
  121.  # missing object files
  122.  $(COMMON_AR):
  123. diff --git a/src/char/char.cpp b/src/char/char.cpp
  124. index 407e07b..59694ef 100644
  125. --- a/src/char/char.cpp
  126. +++ b/src/char/char.cpp
  127. @@ -2781,6 +2781,9 @@ void char_set_defaults(){
  128.     charserv_config.mail_return_days = 14;
  129.     charserv_config.mail_delete_days = 14;
  130.  
  131. +   charserv_config.gm_whisp_webhook = 0;
  132. +   charserv_config.gm_whisp_webhook_url[0] = '\0';
  133. +
  134.  #if defined(RENEWAL) && PACKETVER >= 20151001
  135.     charserv_config.allowed_job_flag = 3;
  136.  #else
  137. @@ -3066,6 +3069,10 @@ bool char_config_read(const char* cfgName, bool normal){
  138.             charserv_config.mail_delete_days = atoi(w2);
  139.         } else if (strcmpi(w1, "allowed_job_flag") == 0) {
  140.             charserv_config.allowed_job_flag = atoi(w2);
  141. +       } else if (strcmpi(w1, "gm_whisp_webhook") == 0) {
  142. +           charserv_config.gm_whisp_webhook = config_switch(w2);
  143. +       } else if (strcmpi(w1, "gm_whisp_webhook_url") == 0) {
  144. +           safestrncpy(charserv_config.gm_whisp_webhook_url, w2, 1024);
  145.         } else if (strcmpi(w1, "import") == 0) {
  146.             char_config_read(w2, normal);
  147.         }
  148. diff --git a/src/char/char.hpp b/src/char/char.hpp
  149. index ab76e89..53142d4 100644
  150. --- a/src/char/char.hpp
  151. +++ b/src/char/char.hpp
  152. @@ -186,6 +186,9 @@ struct CharServ_Config {
  153.     int mail_return_days;
  154.     int mail_delete_days;
  155.  
  156. +   int gm_whisp_webhook;
  157. +   char gm_whisp_webhook_url[1024];
  158. +
  159.     int allowed_job_flag;
  160.  };
  161.  extern struct CharServ_Config charserv_config;
  162. diff --git a/src/char/inter.cpp b/src/char/inter.cpp
  163. index cf9b4b2..92e7204 100644
  164. --- a/src/char/inter.cpp
  165. +++ b/src/char/inter.cpp
  166. @@ -10,6 +10,9 @@
  167.  #include <string>
  168.  #include <vector>
  169.  #include <stdlib.h>
  170. +#ifdef HAVE_LIBCURL
  171. +#include <curl/curl.h>
  172. +#endif
  173.  
  174.  #include "../common/cbasetypes.h"
  175.  #include "../common/malloc.h"
  176. @@ -1245,7 +1248,6 @@ int mapif_parse_WisReply(int fd)
  177.         mapif_wis_reply(wd->fd, wd->src, flag); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
  178.         idb_remove(wis_db, id);
  179.     }
  180. -
  181.     return 0;
  182.  }
  183.  
  184. @@ -1258,6 +1260,34 @@ int mapif_parse_WisToGM(int fd)
  185.     WBUFW(buf, 0) = 0x3803;
  186.     chmapif_sendall(buf, RFIFOW(fd,2));
  187.  
  188. +#ifdef HAVE_LIBCURL
  189. +   if (charserv_config.gm_whisp_webhook != 0 && charserv_config.gm_whisp_webhook_url[0] != 0) {
  190. +       CURL *curl;
  191. +       CURLcode res;
  192. +       curl = curl_easy_init();
  193. +       if (curl) {
  194. +           char buf2[300]; //just the message
  195. +           char * bp = buf2;
  196. +           char * c = RFIFOCP(fd, 8 + NAME_LENGTH);
  197. +           memset(buf, 0, sizeof(buf));
  198. +           while (*c != '\0') {
  199. +               if (*c == '"' || *c == '\\') {
  200. +                   *bp = '\\';
  201. +                   bp++;
  202. +               }
  203. +               *bp = *c;
  204. +               c++;
  205. +               bp++;
  206. +           }
  207. +           *bp = '\0';
  208. +           snprintf((char *)buf, sizeof(buf), "{\"content\": \"[%s] %s\", \"username\": \"%s\"}", RFIFOCP(fd, 4), buf2, server_name);
  209. +           curl_easy_setopt(curl, CURLOPT_URL, charserv_config.gm_whisp_webhook_url);
  210. +           curl_easy_setopt(curl, CURLOPT_POSTFIELDS, buf);
  211. +           res = curl_easy_perform(curl);
  212. +           curl_easy_cleanup(curl);
  213. +       }
  214. +   }
  215. +#endif
  216.     return 0;
  217.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top