원본파일이 원래 오토핫키로 제작한 exe파일이었는데요
카카오토로 적용시켜서 해봣더니 전송이 안돼서 무엇이 문제인가해서 찾다가 디컴파일이 되길래
제가 원하는대로 수정할려고 하는데요
(원본-텍스트전송, 사진전송 원하는대로 가능)
(수정-텍스트 2가지를 상황에 맞게 전송)
할려고 하는데요
단순히 텍스트전송 스크립트만 바꿔치기 하니 밑줄친 부분이 중복이라고 뜨더라고여..
해결방법이 있을까요??
프로그래밍의 프도 모르는 사람입니다ㅠㅜㅜ
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ원본ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
; <COMPILER: v1.1.35.00>
FileReadLine, Telegram_Token, telemsg.ini, 1
FileReadLine, Telegram_chatid, telemsg.ini, 2
Param1 = %1%
if Param1 = message
{
FileRead, TG_Message, %A_ScriptDir%\Message.txt
SendMsg(Telegram_Token, Telegram_chatid, TG_Message)
SendMsg(token, chatID, message) {
param := "chat_id=" chatID "&text=" message
URL := "https://api.telegram.org/bot" . token . "/sendmessage?"
WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
Try {
WebRequest.Open("POST", URL)
WebRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
WebRequest.Send(param)
res := WebRequest.ResponseText
return res
}
Catch e{
ExitApp
}
}
}
else if Param1 = photo
{
IfExist %A_ScriptDir%\Screenshot.jpg
{
SendPhoto(Telegram_Token, Telegram_chatid, A_ScriptDir . "\Screenshot.jpg")
}
}
SendPhoto(token, chatID, file, caption := "" )
{
url_str := "https://api.telegram.org/bot" token "/sendPhoto?caption=" caption
objParam := { "chat_id" : chatID
, "photo" : [file] }
return UploadFormData(url_str, objParam)
}
UploadFormData(url_str, objParam)
{
CreateFormData(postData, hdr_ContentType, objParam)
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
Try {
whr.Open("POST", url_str, true)
whr.SetRequestHeader("Content-Type", hdr_ContentType)
whr.Option(6) := False
whr.Send(postData)
whr.WaitForResponse()
json_resp := whr.ResponseText
whr :=
return json_resp
}
Catch e{
ExitApp
}
}
CreateFormData(ByRef retData, ByRef retHeader, objParam) {
New CreateFormData(retData, retHeader, objParam)
}
CreateFormData_WinInet(ByRef retData, ByRef retHeader, objParam) {
New CreateFormData(safeArr, retHeader, objParam)
size := safeArr.MaxIndex() + 1
VarSetCapacity(retData, size, 1)
DllCall("oleaut32\SafeArrayAccessData", "ptr", ComObjValue(safeArr), "ptr*", pdata)
DllCall("RtlMoveMemory", "ptr", &retData, "ptr", pdata, "ptr", size)
DllCall("oleaut32\SafeArrayUnaccessData", "ptr", ComObjValue(safeArr))
}
Class CreateFormData {
__New(ByRef retData, ByRef retHeader, objParam) {
CRLF := "`r`n"
Boundary := this.RandomBoundary()
BoundaryLine := "------------------------------" . Boundary
binArrs := []
For k, v in objParam
{
If IsObject(v) {
For i, FileName in v
{
str := BoundaryLine . CRLF
. "Content-Disposition: form-data; name=""" . k . """; filename=""" . FileName . """" . CRLF
. "Content-Type: " . this.MimeType(FileName) . CRLF . CRLF
binArrs.Push( BinArr_FromString(str) )
binArrs.Push( BinArr_FromFile(FileName) )
binArrs.Push( BinArr_FromString(CRLF) )
}
} Else {
str := BoundaryLine . CRLF
. "Content-Disposition: form-data; name=""" . k """" . CRLF . CRLF
. v . CRLF
binArrs.Push( BinArr_FromString(str) )
}
}
str := BoundaryLine . "--" . CRLF
binArrs.Push( BinArr_FromString(str) )
retData := BinArr_Join(binArrs*)
retHeader := "multipart/form-data; boundary=----------------------------" . Boundary
}
RandomBoundary() {
str := "0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z"
Sort, str, D| Random
str := StrReplace(str, "|")
Return SubStr(str, 1, 12)
}
MimeType(FileName) {
n := FileOpen(FileName, "r").ReadUInt()
Return (n = 0x474E5089) ? "image/png"
: (n = 0x38464947) ? "image/gif"
: (n&0xFFFF = 0x4D42 ) ? "image/bmp"
: (n&0xFFFF = 0xD8FF ) ? "image/jpeg"
: (n&0xFFFF = 0x4949 ) ? "image/tiff"
: (n&0xFFFF = 0x4D4D ) ? "image/tiff"
: "application/octet-stream"
}
}
BinArr_FromString(str) {
oADO := ComObjCreate("ADODB.Stream")
oADO.Type := 2
oADO.Mode := 3
oADO.Open
oADO.Charset := "UTF-8"
oADO.WriteText(str)
oADO.Position := 0
oADO.Type := 1
oADO.Position := 3
return oADO.Read, oADO.Close
}
BinArr_FromFile(FileName) {
oADO := ComObjCreate("ADODB.Stream")
oADO.Type := 1
oADO.Open
oADO.LoadFromFile(FileName)
return oADO.Read, oADO.Close
}
BinArr_Join(Arrays*) {
oADO := ComObjCreate("ADODB.Stream")
oADO.Type := 1
oADO.Mode := 3
oADO.Open
For i, arr in Arrays
oADO.Write(arr)
oADO.Position := 0
return oADO.Read, oADO.Close
}
BinArr_ToString(BinArr, Encoding := "UTF-8") {
oADO := ComObjCreate("ADODB.Stream")
oADO.Type := 1
oADO.Mode := 3
oADO.Open
oADO.Write(BinArr)
oADO.Position := 0
oADO.Type := 2
oADO.Charset := Encoding
return oADO.ReadText, oADO.Close
}
BinArr_ToFile(BinArr, FileName) {
oADO := ComObjCreate("ADODB.Stream")
oADO.Type := 1
oADO.Open
oADO.Write(BinArr)
oADO.SaveToFile(FileName, 2)
oADO.Close
}
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ수정ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
; <COMPILER: v1.1.37.02>
FileReadLine, Telegram_Token, telemsg.ini, 1
FileReadLine, Telegram_chatid, telemsg.ini, 2
Param1 = %1%
if Param1 = Concurrent
{
FileRead, TG_Message, %A_ScriptDir%\Message.txt, 1
SendMsg(Telegram_Token, Telegram_chatid, TG_Message)
SendMsg(token, chatID, message) {
param := "chat_id=" chatID "&text=" message
URL := "https://api.telegram.org/bot" . token . "/sendmessage?"
WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
Try {
WebRequest.Open("POST", URL)
WebRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
WebRequest.Send(param)
res := WebRequest.ResponseText
return res
}
Catch e{
ExitApp
}
}
}
else if Param1 = Unread_Whisper
{
FileRead, TG_Message, %A_ScriptDir%\Message.txt, 2
SendMsg(Telegram_Token, Telegram_chatid, TG_Message)
SendMsg(token, chatID, message) {
param := "chat_id=" chatID "&text=" message
URL := "https://api.telegram.org/bot" . token . "/sendmessage?"
WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
Try {
WebRequest.Open("POST", URL)
WebRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
WebRequest.Send(param)
res := WebRequest.ResponseText
return json_resp
}
Catch e{
ExitApp
}
}
CreateFormData(ByRef retData, ByRef retHeader, objParam) {
New CreateFormData(retData, retHeader, objParam)
}
CreateFormData_WinInet(ByRef retData, ByRef retHeader, objParam) {
New CreateFormData(safeArr, retHeader, objParam)
size := safeArr.MaxIndex() + 1
VarSetCapacity(retData, size, 1)
DllCall("oleaut32\SafeArrayAccessData", "ptr", ComObjValue(safeArr), "ptr*", pdata)
DllCall("RtlMoveMemory", "ptr", &retData, "ptr", pdata, "ptr", size)
DllCall("oleaut32\SafeArrayUnaccessData", "ptr", ComObjValue(safeArr))
}
Class CreateFormData {
__New(ByRef retData, ByRef retHeader, objParam) {
CRLF := "`r`n"
Boundary := this.RandomBoundary()
BoundaryLine := "------------------------------" . Boundary
binArrs := []
For k, v in objParam
{
If IsObject(v) {
For i, FileName in v
{
str := BoundaryLine . CRLF
. "Content-Disposition: form-data; name=""" . k . """; filename=""" . FileName . """" . CRLF
. "Content-Type: " . this.MimeType(FileName) . CRLF . CRLF
binArrs.Push( BinArr_FromString(str) )
binArrs.Push( BinArr_FromFile(FileName) )
binArrs.Push( BinArr_FromString(CRLF) )
}
} Else {
str := BoundaryLine . CRLF
. "Content-Disposition: form-data; name=""" . k """" . CRLF . CRLF
. v . CRLF
binArrs.Push( BinArr_FromString(str) )
}
}
str := BoundaryLine . "--" . CRLF
binArrs.Push( BinArr_FromString(str) )
retData := BinArr_Join(binArrs*)
retHeader := "multipart/form-data; boundary=----------------------------" . Boundary
}
RandomBoundary() {
str := "0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z"
Sort, str, D| Random
str := StrReplace(str, "|")
Return SubStr(str, 1, 12)
}
MimeType(FileName) {
n := FileOpen(FileName, "r").ReadUInt()
Return (n = 0x474E5089) ? "image/png"
: (n = 0x38464947) ? "image/gif"
: (n&0xFFFF = 0x4D42 ) ? "image/bmp"
: (n&0xFFFF = 0xD8FF ) ? "image/jpeg"
: (n&0xFFFF = 0x4949 ) ? "image/tiff"
: (n&0xFFFF = 0x4D4D ) ? "image/tiff"
: "application/octet-stream"
}
}
BinArr_FromString(str) {
oADO := ComObjCreate("ADODB.Stream")
oADO.Type := 2
oADO.Mode := 3
oADO.Open
oADO.Charset := "UTF-8"
oADO.WriteText(str)
oADO.Position := 0
oADO.Type := 1
oADO.Position := 3
return oADO.Read, oADO.Close
}
BinArr_FromFile(FileName) {
oADO := ComObjCreate("ADODB.Stream")
oADO.Type := 1
oADO.Open
oADO.LoadFromFile(FileName)
return oADO.Read, oADO.Close
}
BinArr_Join(Arrays*) {
oADO := ComObjCreate("ADODB.Stream")
oADO.Type := 1
oADO.Mode := 3
oADO.Open
For i, arr in Arrays
oADO.Write(arr)
oADO.Position := 0
return oADO.Read, oADO.Close
}
BinArr_ToString(BinArr, Encoding := "UTF-8") {
oADO := ComObjCreate("ADODB.Stream")
oADO.Type := 1
oADO.Mode := 3
oADO.Open
oADO.Write(BinArr)
oADO.Position := 0
oADO.Type := 2
oADO.Charset := Encoding
return oADO.ReadText, oADO.Close
}
BinArr_ToFile(BinArr, FileName) {
oADO := ComObjCreate("ADODB.Stream")
oADO.Type := 1
oADO.Open
oADO.Write(BinArr)
oADO.SaveToFile(FileName, 2)
oADO.Close
}
추가하신게 함수입니다
같은 이름의 함수는 단 1개만 존재해야 합니다
고로 추가한 함수의 이름을 바꾸고 호출할때도 바꾼 함수를 이용하면 되겠습니다