Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TelegramBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
TelegramBot
Commits
307768c5
Commit
307768c5
authored
Nov 24, 2015
by
MBoretto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added unset webhook
parent
5928fa18
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
5 deletions
+39
-5
README.md
README.md
+2
-1
example-unset.php
example-unset.php
+19
-0
Request.php
src/Request.php
+1
-4
Telegram.php
src/Telegram.php
+17
-0
No files found.
README.md
View file @
307768c5
...
@@ -331,7 +331,8 @@ You can overwrite the default Upload and Download directory with:
...
@@ -331,7 +331,8 @@ You can overwrite the default Upload and Download directory with:
$telegram
->
setDownloadPath
(
"yourpath/Download"
);
$telegram
->
setDownloadPath
(
"yourpath/Download"
);
$telegram
->
setUploadPath
(
"yourpath../Upload"
);
$telegram
->
setUploadPath
(
"yourpath../Upload"
);
```
```
###Unset Webhook
Edit
*example-unset.php*
with your credential and execute it.
### Logging
### Logging
Thrown Exception are stored in TelegramException.log file (in the base directory).
Thrown Exception are stored in TelegramException.log file (in the base directory).
...
...
example-unset.php
0 → 100644
View file @
307768c5
<?php
//Composer Loader
$loader
=
require
__DIR__
.
'/vendor/autoload.php'
;
$API_KEY
=
'your_bot_api_key'
;
$BOT_NAME
=
'namebot'
;
try
{
// create Telegram API object
$telegram
=
new
Longman\TelegramBot\Telegram
(
$API_KEY
,
$BOT_NAME
);
// set webhook
$result
=
$telegram
->
unsetWebHook
();
//Uncomment to use certificate
//$result = $telegram->setWebHook($link, $path_certificate);
if
(
$result
->
isOk
())
{
echo
$result
->
getDescription
();
}
}
catch
(
Longman\TelegramBot\Exception\TelegramException
$e
)
{
echo
$e
;
}
src/Request.php
View file @
307768c5
...
@@ -395,11 +395,8 @@ class Request
...
@@ -395,11 +395,8 @@ class Request
return
$result
;
return
$result
;
}
}
public
static
function
setWebhook
(
$url
,
$file
=
null
)
public
static
function
setWebhook
(
$url
=
''
,
$file
=
null
)
{
{
if
(
empty
(
$url
))
{
throw
new
TelegramException
(
'Url is empty!'
);
}
$data
[
'url'
]
=
$url
;
$data
[
'url'
]
=
$url
;
if
(
!
is_null
(
$file
))
{
if
(
!
is_null
(
$file
))
{
...
...
src/Telegram.php
View file @
307768c5
...
@@ -716,6 +716,23 @@ class Telegram
...
@@ -716,6 +716,23 @@ class Telegram
return
$result
;
return
$result
;
}
}
/**
* Unset Webhook for bot
*
* @return string
*/
public
function
unsetWebHook
()
{
$result
=
Request
::
setWebhook
();
if
(
!
$result
->
isOk
())
{
throw
new
TelegramException
(
'Webhook was not unset! Error: '
.
$result
->
getErrorCode
()
.
' '
.
$result
->
getDescription
()
);
}
return
$result
;
}
/**
/**
* Get available message types
* Get available message types
*
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment