Created
June 12, 2015 05:34
-
-
Save rotoshine/fbbfc14ecfbad1b7bd97 to your computer and use it in GitHub Desktop.
telegram-cli bot test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assembler = {} | |
function on_msg_receive (msg) | |
print_r(msg) | |
local chat_name = msg.to.print_name | |
local username = msg.from.print_name | |
local receive_msg = string.lower(msg.text) | |
if ( string.find(receive_msg, "assemble!") or string.find(receive_msg, "어셈블!") ) then | |
assembler[username] = username | |
local assemble_users = ""; | |
for k, v in pairs(assembler) do | |
assemble_users = assemble_users .. k .. " " | |
end | |
send_msg_default(chat_name, "오늘의 어셈블러들 : " .. assemble_users) | |
return | |
elseif ( receive_msg == "assemble reset" or receive_msg == "어셈블 리셋" ) then | |
assembler = {}; | |
send_msg_default(chat_name, "어셈블이 초기화되었다 임마.") | |
elseif ( msg.from.username == "awevengers" ) then | |
if ( string.find(receive_msg,"ㅎㅇ") ) then | |
send_msg_default(chat_name, "ㅃㅇ") | |
elseif ( string.find(receive_msg, "ㅗ") ) then | |
fxxk_string = "ㅗ"; | |
for i = 1, string.len(receive_msg) + 1 do | |
if( string.sub(receive_msg, i, i + 1) == "ㅗ") then | |
fxxk_string = fxxk_string .. "ㅗ" | |
end | |
end | |
send_msg_default(chat_name, fxxk_string) | |
end | |
elseif ( string.find(receive_msg, "부댕해") ) then | |
send_msg_default(chat_name, "퓨ㅠㅠㅠㅠㅠㅠ") | |
end | |
end | |
function send_msg_default(chat_name, msg) | |
send_msg(chat_name, msg, ok_cb, false) | |
end | |
function ok_cb(extra, success, result) | |
end | |
function print_r ( t ) | |
local print_r_cache={} | |
local function sub_print_r(t,indent) | |
if (print_r_cache[tostring(t)]) then | |
print(indent.."*"..tostring(t)) | |
else | |
print_r_cache[tostring(t)]=true | |
if (type(t)=="table") then | |
for pos,val in pairs(t) do | |
if (type(val)=="table") then | |
print(indent.."["..pos.."] => "..tostring(t).." {") | |
sub_print_r(val,indent..string.rep(" ",string.len(pos)+8)) | |
print(indent..string.rep(" ",string.len(pos)+6).."}") | |
elseif (type(val)=="string") then | |
print(indent.."["..pos..'] => "'..val..'"') | |
else | |
print(indent.."["..pos.."] => "..tostring(val)) | |
end | |
end | |
else | |
print(indent..tostring(t)) | |
end | |
end | |
end | |
if (type(t)=="table") then | |
print(tostring(t).." {") | |
sub_print_r(t," ") | |
print("}") | |
else | |
sub_print_r(t," ") | |
end | |
print() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment