This is how telegram send the request:-
POST / HTTP/1.1
Host: xxx.ngrok.io
Content-Type: application/json
Content-Length: 247
Accept-Encoding: gzip, deflate
X-Forwarded-Proto: https
X-Forwarded-For: 149.0.16.14
| module['exports'] = function chat (hook) { | |
| var TelegramBot = require('node-telegram-bot-api'); | |
| var token = hook.env['TG_TOKEN']; | |
| // Setup polling way | |
| var bot = new TelegramBot(token); | |
| bot.setWebHook('https://hook.io/k4ml/infomy') | |
| // Matches /echo [whatever] | |
| bot.onText(/\/echo (.+)/, function (msg, match) { |
One common error faced by new python developer. The error message is a bit obscure if you don’t have fully grasp of the language — like what ‘callable’ is.
This error happen when you have code such as:-
print("Hello %s, your name is %s" (name, yourname))| # curl -LO http://wiki.alpinelinux.org/cgi-bin/dl.cgi/v3.3/releases/x86_64/alpine-3.3.3-x86_64.iso | |
| curl -LO http://wiki.alpinelinux.org/cgi-bin/dl.cgi/v3.3/releases/x86/alpine-3.3.3-x86.iso | |
| # create hdd image (8GB) | |
| dd if=/dev/zero of=hdd.img bs=1g count=8 | |
| # extract kernel and initramfs | |
| brew install cdrtools | |
| isoinfo -i alpine-3.3.1-x86.iso -J -x /boot/initramfs-grsec > initramfs-grsec | |
| isoinfo -i alpine-3.3.1-x86.iso -J -x /boot/vmlinuz-grsec > vmlinuz-grsec |
| #!/usr/bin/env python | |
| # encoding: utf-8 | |
| __author__ = 'kamal@belajar.github.io' | |
| import sys | |
| import telegram | |
| def main(token, message): | |
| bot = telegram.Bot(token) # Telegram Bot Authorization Token |
| local tg_token = 'your token' | |
| if request.query['admin_command'] == 'setURL' and request.query['pass'] == 'xxx' then | |
| local response = http.request { | |
| url = 'https://api.telegram.org/bot' .. tg_token .. '/setWebhook', | |
| params = { | |
| url='https://demo-xxxx.webscript.io/script' | |
| }, | |
| method='post', | |
| } |
| import bottle | |
| import requests | |
| @bottle.route('/', method='POST') | |
| def telegram_bot(): | |
| data = bottle.request.json | |
| url = 'https://api.telegram.org/bot<YOUR_TOKEN>/sendMessage' | |
| try: |
| from peewee import * | |
| db = SqliteDatabase(None) | |
| class BaseModel(Model): | |
| class Meta: | |
| database = db | |
| class TGUser(BaseModel): | |
| id_ = IntegerField(primary_key=True) |
| import requests | |
| base_url = 'https://gst.customs.gov.my/TAP' | |
| s = requests.session() | |
| # STEP 1 | |
| response = s.get('%s/GetWlbToken' % base_url) | |
| print response.headers | |
| token = response.headers['fast-ver-last'] |
| <?php | |
| /* | |
| Plugin Name: My Widget | |
| Plugin URI: http://mydomain.com | |
| Description: My first widget | |
| Author: Me | |
| Version: 1.0 | |
| Author URI: http://mydomain.com | |
| Original Source: https://github.com/pommiegranit/wp-widgets/blob/master/mywidget-basic.php | |
| */ |