Commit 814ccee4 authored by LONGMAN's avatar LONGMAN

Init

parent 146cf701
# IDE & System Related Files #
.buildpath
.project
.settings
.DS_Store
.idea
.phpintel
composer.phar
# Local System Files (i.e. cache, logs, etc.) #
/cache
/build/logs
/build/coverage
/tmp
# Test Related Files #
/phpunit.xml
# Composer
vendor/
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
# phpDocumentor Logs #
phpdoc-*
# OSX #
._*
.Spotlight-V100
.Trashes
\ No newline at end of file
The MIT License (MIT)
Copyright (c) 2015 Avtandil Kikabidze
Copyright (c) 2015 Avtandil Kikabidze aka LONGMAN
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
# telegram-api
telegram-api
# Kautilities
[![Join the chat at https://gitter.im/akalongman/kautilities](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/akalongman/kautilities?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/akalongman/kautilities.svg?branch=master)](https://travis-ci.org/akalongman/kautilities)
[![Latest Stable Version](https://img.shields.io/packagist/v/Longman/Kautilities.svg)](https://packagist.org/packages/longman/kautilities)
[![Total Downloads](https://img.shields.io/packagist/dt/Longman/Kautilities.svg)](https://packagist.org/packages/longman/kautilities)
[![Downloads Month](https://img.shields.io/packagist/dm/Longman/Kautilities.svg)](https://packagist.org/packages/longman/kautilities)
[![License](https://img.shields.io/packagist/l/Longman/Kautilities.svg)](https://packagist.org/packages/stichoza/longman/kautilities)
PHP class for convert KA letters to LAT and back
## Installation
Install this package through [Composer](https://getcomposer.org/). Edit your project's `composer.json` file to require `longman/kautilities`.
```json
"require": {
"longman/kautilities": "~1.0"
}
```
**Or** run a command in your command line:
```
composer require longman/kautilities
```
## Usage
```php
use Longman\Kautilities\Converter;
echo Converter::kaToLat('ა ბ გ დ'); // output: a b g d
echo Converter::latToKa('a b g d'); // output: ა ბ გ დ
```
{
"name": "longman/telegram-api",
"type": "library",
"description": "PHP library for convert KA letters to LAT and back",
"keywords": ["ka", "georgia", "converter", "string", "utilities", "translit"],
"license": "MIT",
"homepage": "https://github.com/akalongman/kautilities",
"support": {
"issues": "https://github.com/akalongman/kautilities/issues",
"source": "https://github.com/akalongman/kautilities"
},
"authors": [
{
"name": "Avtandil Kikabidze aka LONGMAN",
"email": "akalongman@gmail.com",
"homepage": "http://longman.ge",
"role": "Developer"
}
],
"require": {
"php": ">=5.3.0"
},
"autoload": {
"psr-4": {
"Longman\\TelegramApi\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"require-dev": {
"phpunit/phpunit": "4.1.*",
"phpspec/phpspec": "~2.1",
"squizlabs/php_codesniffer": "2.3.*"
}
}
This diff is collapsed.
<?php
class Command extends Request
{
public function execute() {
}
}
<?php
class EchoCommand extends Commands
{
public function execute() {
$args = func_get_args();
}
}
$db_user = 'dbuser';
$db_pass = '8CihEPdp';
$API_KEY = '115402299:AAH-5SiSZKGiZinOgA8TfyCkO9ml9GmIFXc';
$action = 'sendMessage';
$post = array(
'chat_id'=>0,
'text'=>'',
);
$post = file_get_contents('php://input');
$status = file_put_contents('data.log', $post."\n\n", FILE_APPEND);
if (!empty($_GET['cmd'])) {
$post = $_GET['cmd'];
}
$post = json_decode($post, true);
$chat_id = $post['message']['chat']['id'];
if (empty($chat_id)) {
return false;
}
$text = $post['message']['text'];
if (empty($text)) {
return false;
}
$cmd = strtok($text, ' ');
switch ($cmd) {
case '/echo';
$text = str_replace($cmd, '', $text);
$post['chat_id'] = $chat_id;
$post['text'] = $text;
request($post, 'sendMessage');
break;
case '/help';
$text = 'GeoBot v1.0.0';
$text = 'Commands:
/echo - Echo message
';
$post['chat_id'] = $chat_id;
$post['text'] = $text;
request($post, 'sendMessage');
break;
}
function request($post, $action) {
global $API_KEY;
$ch = curl_init();
$curlConfig = array(
CURLOPT_URL => 'https://api.telegram.org/bot'.$API_KEY.'/'.$action,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $post
);
curl_setopt_array($ch, $curlConfig);
$result = curl_exec($ch);
curl_close($ch);
}
/*$data = '';
$data .= 'POST: '.print_r(json_decode($post), true)."\n";
$data .= "= = = =\n\n";
$status = file_put_contents('data.log', $data, FILE_APPEND);
*/
<?php
namespace TelegramApi\entities;
class Message
{
public function __construct($post) {
$this->api_key = $api_key;
}
}
<?php
namespace TelegramApi\entities;
class Update
{
protected $update_id;
protected $message;
public function __construct($data) {
}
}
<?php
namespace TelegramApi;
class TelegramApi
{
private $api_key = '';
public function __construct($api_key) {
$this->api_key = $api_key;
}
public function execute() {
$input = file_get_contents('php://input');
if (empty($input)) {
throw new Exception('Input is empty!');
}
$post = json_decode($input, true);
if (empty($post)) {
throw new Exception('Invalid JSON!');
}
print_r($post);
die;
$message = new Message($post);
$cmd = $this->getCommand($post);
var_dump($cmd);
die;
}
public function getCommand($post) {
$cmd = strtok($post, ' ');
if (substr($cmd, 0, 1) === '/') {
$cmd = substr($cmd, 1);
}
return $cmd;
}
public function request($action, $data) {
$ch = curl_init();
$curlConfig = array(
CURLOPT_URL => 'https://api.telegram.org/bot'.$this->api_key.'/'.$action,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
//CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
CURLOPT_POSTFIELDS => $data
);
curl_setopt_array($ch, $curlConfig);
$result = curl_exec($ch);
curl_close($ch);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment