shourya90

Untitled

Aug 9th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. public SendDC(channel[], const fmat[], va_args<>)
  2. {
  3. new
  4. str[256];
  5. va_format(str, sizeof (str), fmat, va_start<2>);
  6. BotChannel = DCC_FindChannelById(channel);
  7. return DCC_SendChannelMessage(BotChannel, str);
  8. }
  9. /*public DCC_OnChannelMessage(DCC_Channel:channel, DCC_User:author, const message[])
  10. {
  11. new channel_name[100 + 1];
  12. if(!DCC_GetChannelName(channel, channel_name))
  13. return 0; // invalid channel
  14.  
  15. new user_name[32 + 1];
  16. if (!DCC_GetUserName(author, user_name))
  17. return 0; // invalid user
  18.  
  19. new str[145];
  20. format(str, sizeof str, "[DISCORD]%s: %s", user_name, message);
  21. SendClientMessageToAll(-1, str);
  22. return 1;
  23. }*/
  24. forward DCC_OnChannelMessage(DCC_Channel:channel, DCC_User:author, const message[]);
  25. public DCC_OnChannelMessage(DCC_Channel:channel, DCC_User:author, const message[])
  26. {
  27. new channel_name[100 + 1];
  28. if(!DCC_GetChannelName(channel, channel_name))
  29. return 0; // invalid channel
  30.  
  31. new user_name[32 + 1];
  32. if (!DCC_GetUserName(author, user_name))
  33. return 0; // invalid user
  34.  
  35.  
  36. if(!strcmp(user_name, BOT_NAME, true)) return 1;
  37.  
  38. if(!strcmp(channel_name, BOT_CHANNEL, true)) // If user is bot then quit the callback.
  39. {
  40. new dmsg[10][128];
  41. explode(dmsg, message, " ", 2); // Used so we can see if the arguments next to command are empty or have value.
  42.  
  43. new command[128], args[512];
  44. sscanf(message, "s[128]s[512]", command, args); // Sperate message in COMMAND and arguments.
  45. if(strfind(command, CMD_PREFIX, true) != -1) // Check if command have prefix defined above.
  46. {
  47. new funcdc[128];
  48. strdel(command, 0, 1);
  49. format(funcdc, sizeof(funcdc), "dc_cmd_%s", command); // Format function.
  50.  
  51. if(isnull(dmsg[1])) {
  52. CallLocalFunction("OnDCCommandPerformed", "si", message, CallLocalFunction(funcdc, "ss", user_name, "\1"));
  53. } else CallLocalFunction("OnDCCommandPerformed", "si", message, CallLocalFunction(funcdc, "ss", user_name, args));
  54.  
  55.  
  56. }
  57. else
  58. {
  59. new str[145];
  60. format(str, sizeof str, "{ff146a}[FROM DISCORD]{FFFFFF}%s: %s", user_name, message);
  61. SendClientMessageToAll(-1, str);
  62. }
  63. }
  64. if(!strcmp(user_name, BOT_NAME_ADMIN, true)) return 1;
  65.  
  66. if(!strcmp(channel_name, BOT_CHANNEL_ADMIN, true)) // If user is bot then quit the callback.
  67. {
  68. new dmsg2[16][128];
  69. explode(dmsg2, message, " ", 2); // Used so we can see if the arguments next to command are empty or have value.
  70.  
  71. new command[128], args[512];
  72. sscanf(message, "s[128]s[512]", command, args); // Sperate message in COMMAND and arguments.
  73. if(strfind(command, CMD_PREFIX_ADMIN, true) != -1) // Check if command have prefix defined above.
  74. {
  75. new funcdc[128];
  76. strdel(command, 0, 1);
  77. format(funcdc, sizeof(funcdc), "dc_cmd_%s", command); // Format function.
  78.  
  79. if(isnull(dmsg2[1]))
  80. {
  81. CallLocalFunction("OnDCCommandPerformed", "si", message, CallLocalFunction(funcdc, "ss", user_name, "\1"));
  82. }
  83. else
  84. CallLocalFunction("OnDCCommandPerformed", "si", message, CallLocalFunction(funcdc, "ss", user_name, args));
  85.  
  86.  
  87. }
  88. }
  89. return 1;
  90. }
Add Comment
Please, Sign In to add comment