Help Cleo webhook discord help

webi

New member
Joined
Jul 7, 2021
Messages
1
Reaction score
0
Location
chisinau
I want to make a cleo that detects when someone writes "hi" in the chat to send a webhook on discord, can someone help me?



{$CLEO}
0000: NOP

repeat
wait 0
until 0AFA: SAMP_IS_READY

// host
alloc 0@ 30
0AD3: 0@ = format "discordapp.com"

// path
alloc 1@ 200
call @construct_path 1 1@ // Citim webhook-ul din discord.ini

// data
alloc 2@ 1000
0AD3: 2@ = format "content=test message!&username=samp"

// response buffer
alloc 3@ 1500

while true
wait 0
if
0B61: samp is_local_player_spawned
then
for 0@ = 0 TO 9
0AC8: 4@ = allocate_memory_size 260
0AC8: 5@ = allocate_memory_size 260
0B75: samp get_chat_string 0@ text_to 4@ prefix_to 5@ color_to 6@ prefix_color_to 7@
if
0C29: $NOT_USED = stristr string1 4@ string2 "hi"
then
chatmsg "hi detected " 0x00FF00 // Debug

0AB1: call_scm_func @HTTP_POST 5 host 0@ file_path 1@ response_buffer 3@ data 2@ is_https true _ret_is_success 31@
if
31@ == true
then
0AF8: samp add_message_to_chat "success!" color 0x00FF00
else
0AF8: samp add_message_to_chat "error" color 0xFF0000
end

wait 10000
end

0AC9: free_allocated_memory 4@
0AC9: free_allocated_memory 5@
end
end
end

:construct_path
{
Params:
0@ - pointer to path
}
alloc 30@ 200
alloc 31@ 200
0AF4: 30@ = read_string_from_ini_file "cleo\discord.ini" section "my_server" key "webhook_channel_id"
0AF4: 31@ = read_string_from_ini_file "cleo\discord.ini" section "my_server" key "webhook_token"
0AD3: 0@ = format "api/webhooks/%s/%s" 30@ 31@
free 30@
free 31@
ret 0

{$INCLUDE includes/http_requests.txt}
 
Top