Skip to content

Commit 3e81355

Browse files
committed
update 3.2.1
1 parent 34f2dff commit 3e81355

6 files changed

Lines changed: 194 additions & 38 deletions

File tree

App/Plugins/mysql.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
class mysql{
4+
public $conDB;
5+
protected $connection;
6+
7+
function __construct($dbs, $options = [
8+
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
9+
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
10+
PDO::ATTR_EMULATE_PREPARES => false,])
11+
{
12+
$host = $dbs['host'];
13+
$dbname = $dbs['dbname'];
14+
$user = $dbs['user'];
15+
$pass = $dbs['user'];
16+
$charset = $dbs['charset'];
17+
$this->conDB = TRUE;
18+
try {
19+
$this->connection = new PDO("mysql:host=$host;dbname=$dbname;charset=$charset", $user, $pass, $options);
20+
} catch (PDOException $e) {
21+
throw new PDOException($e->getMessage(), (int)$e->getCode());
22+
}
23+
}
24+
25+
public function DisConnect()
26+
{
27+
$this->connection = NULL;
28+
$this->conDB = FALSE;
29+
}
30+
31+
public function query($query)
32+
{
33+
try {
34+
$stmt = $this->connection->prepare($query);
35+
return $stmt->execute();
36+
37+
} catch (PDOException $e) {
38+
throw new Exception($e->getMessage());
39+
}
40+
}
41+
42+
public function onerow($query, $params = [])
43+
{
44+
try {
45+
$stmt = $this->connection->prepare($query);
46+
$stmt->execute($params);
47+
return $stmt->fetch(PDO::FETCH_OBJ);
48+
} catch (PDOException $e) {
49+
throw new Exception($e->getMessage());
50+
}
51+
}
52+
53+
public function row($query, $params = [])
54+
{
55+
try {
56+
$stmt = $this->connection->prepare($query);
57+
$stmt->execute($params);
58+
return $stmt->fetchAll(PDO::FETCH_OBJ);
59+
} catch (PDOException $e) {
60+
throw new Exception($e->getMessage());
61+
}
62+
}
63+
64+
public function query_cruid($query, $params = [])
65+
{
66+
try {
67+
$stmt = $this->connection->prepare($query);
68+
return $stmt->execute($params);
69+
} catch (PDOException $e) {
70+
throw new PDOException($e->getMessage());
71+
}
72+
}
73+
74+
public function count($table_name)
75+
{
76+
try {
77+
$stmt = $this->connection->prepare("SELECT * FROM " . $table_name);
78+
$stmt->execute();
79+
return $stmt->rowCount();
80+
} catch (PDOException $e) {
81+
throw new Exception($e->getMessage());
82+
}
83+
}
84+
}

App/Plugins/sqlite.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
4+
5+
class sqlite{
6+
7+
protected $db;
8+
protected $sql;
9+
10+
11+
public function __construct($joylashuv){
12+
$this->db = new PDO('sqlite:'.$joylashuv);
13+
$this->sql = new SQLite3($joylashuv);
14+
}
15+
16+
17+
public function query($sql, $params = []) {
18+
$stmt = $this->db->prepare($sql);
19+
if (!empty($params)) {
20+
foreach ($params as $key => $val) {
21+
if (is_int($val)) {
22+
$type = PDO::PARAM_INT;
23+
} else {
24+
$type = PDO::PARAM_STR;
25+
}
26+
$stmt->bindValue(':'.$key, $val, $type);
27+
}
28+
}
29+
$stmt->execute();
30+
return $stmt;
31+
}
32+
33+
public function row($sql, $params = []) {
34+
$result = $this->query($sql, $params);
35+
return $result->fetchAll(PDO::FETCH_ASSOC);
36+
}
37+
38+
public function onerow($sql, $params = []) {
39+
$result = $this->query($sql, $params);
40+
return $result->fetch(PDO::FETCH_ASSOC);
41+
}
42+
43+
public function column($sql, $params = []) {
44+
$result = $this->query($sql, $params);
45+
return $result->fetchColumn();
46+
}
47+
48+
public function autoCount($tableName, $params=[]){
49+
$result = $this->query("SELECT count(*) FROM $tableName", $params);
50+
return $result->fetchColumn();
51+
}
52+
53+
54+
}

App/framework/app.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
class App{
4+
5+
public function parser($url){
6+
7+
$curl = curl_init();
8+
curl_setopt($curl, CURLOPT_URL, $url);
9+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
10+
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
11+
12+
$html = curl_exec($curl);
13+
return $html;
14+
}
15+
16+
public function convert_seconds($seconds){
17+
$dt1 = new DateTime("@0");
18+
$dt2 = new DateTime("@$seconds");
19+
return $dt1->diff($dt2)->format('%i:%s');
20+
}
21+
22+
23+
public function sizeconvert($size){
24+
$size = round($size / 1024, 2);
25+
if($size > 1024000){
26+
$size = round($size / 1024000, 2).' GB';
27+
}elseif($size > 1024){
28+
$size = round($size / 1024, 2).' MB';
29+
}else{ $size = $size.' KB'; }
30+
return $size;
31+
}
32+
33+
public function genrate($length = 5) {
34+
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
35+
$charactersLength = strlen($characters);
36+
$randomString = '';
37+
for ($i = 0; $i < $length; $i++) {
38+
$randomString .= $characters[rand(0, $charactersLength - 1)];
39+
}
40+
return $randomString;
41+
}
42+
}

App/framework/framework.php

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -188,21 +188,6 @@ public function sendPhoto($chat_id, $photo, $caption = '', $params = []){
188188
], $params));
189189
}
190190

191-
/**
192-
* @param $chat_id
193-
* @param $video
194-
* @param string $caption
195-
* @param array $params
196-
* @return bool|string
197-
*/
198-
public function sendVideo($chat_id, $video, $caption = '', $params = []){
199-
return $this->bot('sendVideo', array_merge([
200-
'chat_id'=>$chat_id,
201-
'video' => $video,
202-
'caption'=>$caption
203-
], $params));
204-
}
205-
206191
/**
207192
* @param $chat_id
208193
* @param $document
@@ -213,21 +198,11 @@ public function sendVideo($chat_id, $video, $caption = '', $params = []){
213198
public function sendDocument($chat_id, $document, $caption = '', $params = []){
214199
return $this->bot('sendDocument', array_merge([
215200
'chat_id'=>$chat_id,
216-
'document' => $document,
201+
'Document' => $document,
217202
'caption'=>$caption
218203
], $params));
219204
}
220205

221-
/**
222-
* @param $chat_id
223-
* @param array $params
224-
* @return bool|string
225-
*/
226-
public function getUserProfilePhotos($chat_id, $params = []){
227-
return $this->bot('getUserProfilePhotos', array_merge([
228-
'chat_id'=>$chat_id,
229-
], $params));
230-
}
231206

232207
/**
233208
* @param $chat_id
@@ -239,20 +214,11 @@ public function getUserProfilePhotos($chat_id, $params = []){
239214
public function sendAudio($chat_id, $audio, $caption = '', $params = []){
240215
return $this->bot('sendAudio', array_merge([
241216
'chat_id'=>$chat_id,
242-
'audio' => $audio,
217+
'photo' => $audio,
243218
'caption'=>$caption
244219
], $params));
245220
}
246221

247-
// answerInlineQuery
248-
249-
public function answerInlineQuery($inline_query_id, $audio, $results, $params = []){
250-
return $this->bot('answerInlineQuery', array_merge([
251-
'inline_query_id'=>$inline_query_id,
252-
'is_personal' => true,
253-
'results'=>$caption
254-
], $params));
255-
}
256222
/**
257223
* @param $id
258224
* @param $action
@@ -280,6 +246,17 @@ public function sendContact($chat_id, $phone_number, $first_name, $params = []){
280246
], $params));
281247
}
282248

249+
public function answerInlineQuery($inline_id, $audio_url, $title, $params = []){
250+
return $this->bot('answerInlineQuery',[
251+
'inline_query_id' => $inline_id,
252+
'results'=>array_merge([
253+
'type'=>'audio',
254+
'audio_url'=>$audio_url,
255+
'title'=>$title
256+
],$params)
257+
]);
258+
}
259+
283260
}
284261

285262

_config.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "coderlast/clframework",
33
"description": "Framework Telegram bots",
44
"license": "MIT",
5-
"keywords": ["Telegram Bot","Telegram Bot framework"],
5+
"keywords": ["Telegram Bot","Telegram Bot framework","BotApp","BotPlugin"],
66
"homepage": "https://coderlast.github.io/CLFramework/",
77
"authors": [
88
{

0 commit comments

Comments
 (0)