Monday, January 26, 2015

automated telegram reply with centos

searching and i found this:
to send message:
http://stackoverflow.com/questions/24330922/sending-messages-with-telegram-apis-or-cli

to reply message:
http://stackoverflow.com/questions/27671801/pass-string-to-a-linux-cli-interactive-program-with-a-script
http://www.instructables.com/id/Raspberry-remote-control-with-Telegram/

First create a bash script for telegram called tg.sh:
#!/bin/bash
now=$(date)
to=$1
subject=$2
body=$3
tgpath=/home/youruser/tg
LOGFILE="/home/youruser/tg.log"
cd ${tgpath}
${tgpath}/telegram -k ${tgpath}/tg-server.pub -W <<EOF
msg $to $subject
safe_quit
EOF
echo "$now Recipient=$to Message=$subject" >> ${LOGFILE}
echo "Finished" >> ${LOGFILE}


To intercept a new incoming message we create a file action.lua
"Lua is a powerful, fast, lightweight, embeddable scripting language.
Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping."
sudo nano /home/pi/tg/action.lua
with this content
function on_msg_receive (msg)
    if msg.out then
        return
    end
    if (msg.text=='ping') then
        send_msg (msg.from.print_name, 'pong', ok_cb, false)
    end
end

function on_our_id (id)
end

function on_secret_chat_created (peer)
end

function on_user_update (user)
end

function on_chat_update (user)
end

function on_get_difference_end ()
end

function on_binlog_replay_end ()
end
Save and exit, when incoming text message is "ping", Telegram answers us with a text message containing "pong".
move in tg

cd /home/pi/tg
Then type
bin/telegram-cli -k tg-server.pub -W -s action.lua

Tuesday, January 20, 2015

sms gateway update (1)

link: http://nerazan.blogspot.com/2013/07/how-to-configure-gsm-modem-in-linux.html
(previously working but now not working. wondering why.

http://everyday-tech.com/nagiosfan-sms-alerts-via-smstools/

Download & Install CMake for CentOS-5

Install GCC

Install eject

Install comget

.
Configuring Your GSM Modem

1.)  Insert gsm modem in usb port
2.)  Run

3.)
 Check which modem Port it’s connected to

4.)
 Eject the Cd-rom sro & sr1 as per your setup

5.)
 Connect gsm modem to usb port ( USB0 in my case )

6.)
 When the modem is connected you will get a message with your service provider name
7.)  Create symbolic link to /dev/modem

TO TEST THAT THE USB MODEM IS ON USB0

.

Installing & Configuring SMSTools


1.)  Install SMS Tools
-or-

2.)  Make Sure you have the Following SMSTOOLS3 SERVER Files and Folders Installed
  • incoming = /var/spool/sms/incoming
  • outgoing = /var/spool/sms/outgoing
  • checked = /var/spool/sms/checked
  • failed = /var/spool/sms/failed
  • sent = /var/spool/sms/sent
  • logfile = /var/log/smsd.log
  • Configuration = /etc/smsd.conf

3.)  Make sure that SMSTools has the Right Configuration Setting for your modem in:  /etc/smsd.conf( GSM Modem is on USB0 in this example)
device = /dev/ttyUSB0

HOW TO START or STOP THE SMSTOOLS3 SERVER

To Setup SMS Tools to AutoStart on Server Boot….

To Test your SMSTools Install:
Related Posts Plugin for WordPress, Blogger...