Readmes
This commit is contained in:
parent
2347defd47
commit
7431a44281
7
README.md
Normal file
7
README.md
Normal file
@ -0,0 +1,7 @@
|
||||
DennyDai/D-Bot
|
||||
==============================
|
||||
a php bot
|
||||
|
||||
Supported Chat Tools List
|
||||
------------
|
||||
[Telegram](https://telegram.org) - [README](https://github.com/dennydai/D-bot/blob/master/readmes/Telegram/Telegram.md)
|
25
readmes/Telegram/Telegram.md
Normal file
25
readmes/Telegram/Telegram.md
Normal file
@ -0,0 +1,25 @@
|
||||
DennyDai/D-Bot
|
||||
==============================
|
||||
a php bot
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
- a running [telegram-cli](https://github.com/vysheng/tg/) listening on a unix-socket (`-S`) or a port (`-P`). Needs to be configured already (phone-number, etc.).
|
||||
- php >= 5.3.0
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
###Setup telegram-cli
|
||||
[telegram-cli](https://github.com/vysheng/tg/) needs to be installed.
|
||||
|
||||
Then
|
||||
|
||||
./bin/telegram-cli -s [onmessage.lua Path Here] -dWS /tmp/tg.sck &
|
||||
|
||||
Finally,
|
||||
|
||||
chmod 0777 /tmp/tg.sck
|
||||
|
||||
If you never started telegram-cli before, you need to start it first in normal mode, so you can type in your telegram-phone-number and register it, if needed (`./bin/telegram-cli`).
|
10
readmes/Telegram/onmessage.lua
Normal file
10
readmes/Telegram/onmessage.lua
Normal file
@ -0,0 +1,10 @@
|
||||
function encodeURI(s)
|
||||
s = string.gsub(s, "([^%w%.%- ])", function(c) return string.format("%%%02X", string.byte(c)) end)
|
||||
return string.gsub(s, " ", "+")
|
||||
end
|
||||
|
||||
function on_msg_receive (msg)
|
||||
local handle = io.popen( "wget [your BOT.php url here]?to="..encodeURI(msg.to.print_name).."&from="..encodeURI(msg.from.print_name).."&text="..encodeURI(msg.text) )
|
||||
local result = handle:read("*a")
|
||||
handle:close()
|
||||
end
|
Loading…
Reference in New Issue
Block a user