Closed pharmak0n closed 2 years ago
Hi @pharmak0n,
sure! Any host with PHP and MySQL will work. The database schema can be found in the repo at sql/treasurehuntbot.sql
, while the src/hook.php
script must be registered as a Telegram webhook for your bot (take a look to src/register-bot.sh
).
No special requirements for the Telegram bot: just create your own bot on Telegram through the @botmaster
.
Let me know if you run into any issues. Cheers, Lorenz
Hi,
@BotFather
, inline queries
enabledsrc/config.php
(renamed from config-template.php
) filled in with bot api token and mysql infosql/treasurehuntbot.sql
Then i think started the problem, i checked the 'src/register-bot.sh' file. I cannot run an .sh on the shared server, i have at least a chroot access via ssh. I have a SSL certificate installed on it.
I also tried to register the bot in webhooks as described here
I don't know the second parameter https://api.telegram.org/bot{my_bot_token}/setWebhook?url={url_to_send_updates_to}
.
What can i do? Thanks in advance for your patience :)
You are right about the config.php
file, I forgot about that. I'll put together a complete guide as soon as we get your bot running. 😊
You do not necessarily need to execute the SH files luckily: once your bot is correctly configured via config.php
file, you have two alternatives:
pull.php
script manually, by running php pull.php
, if you have SSH access to your server,hook.php
script as a wekhook in Telegram. To do so, you need to perform a simple HTTP request, for instance using cURL:curl -F "url=https://YOURDOMAIN/PATH-TO-BOT/src/hook.php" https://api.telegram.org/botBOTTOKEN/setWebhook
Once the webhook is configured, Telegram will call hook.php
when your bot receives new messages. At that point, if the database is configured correctly, your bot should work correctly.
I have added some instructions to the project's readme.
Hi Lorenzo, i checked your instructions and i registered the bot with curl from chrooted bash. I tried to chat with the bot but it doesn't respond and do nothing.
I tried to run php /.../telegram/src/pull.php
from bash
and it says:
PHP Fatal error: Arrays are not allowed as constants in /.../telegram/src/lib_localization.php on line 30
I tried with php 7.1.5 on apache and it generate a series of error related to arrays declaration and use. I also tried with php 7.0.19.
I tried some dirty fix in lib_localization.php
but then errors appears in other file.
That is very strange, the "arrays are not allowed as constants" sounds as it should be due to an older version of PHP (5.x or something like that). We are using PHP 7.0.27
on our server. Can you double-check that your Apache installation is indeed using PHP 7? Perhaps creating a sample .php file with the following?
<?php phpinfo(); ?>
The previous tests were made checking with phpinfo.
I explore the problem and discovered a first issue related to my host:
ModSecurity: Access denied with code 406 (phase 2). Operator EQ matched 0 at REQUEST_HEADERS.
, disabled firewall and mod_security.
The second issue was with mod_fcgid: stderr: PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 1044480 bytes) in /data/.../tgbot/src/lib_database.php on line 269
, increased memory limit to 1024M but the error still persist.
On next pull another issue appears:
Error 405 | POST /tgbot/src/hook.php - HTTP/1.1
The second issue was with mod_fcgid: stderr: PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 1044480 bytes) in /data/.../tgbot/src/lib_database.php on line 269, increased memory limit to 1024M but the error still persist.
This is very strange: the bot shouldn't require much memory at all. I just added some performance logging to the code and in our tests the bot never crosses the 2MB mark.
The 405
HTTP status indicates that the POST
method was disabled (Telegram webhooks always send POST
requests). I'm guessing this is due to some Apache server setting or some other configuration of your web host.
I continue to this thread because my question is a follow-up. I created my own bot at my own server and the webhook is up and running (after many tries it is called digifestbot) but my database has only the empty tables and when I try to start a game by https://t.me/digifestbot?start i get only this cmd_start_registered and then when I try other /commands I get similar responses like fallback_response. Do I need more compilation to do?
Hi @tzorbagreek, to fix that you'll need to run translation/compile.sh
which transforms the raw translation files into compiled text resources.
Also, you'll have to enable the locales on your Unix installation. Start with:
sudo apt install -y locales
and then edit the /etc/locale.gen
file uncommenting the locales you want to activate (for instance en_US.UTF-8
) and regenerate locales:
sudo locale-gen
sudo dpkg-reconfigure --frontend=noninteractive locales
sudo update-locale LANG=en_US.utf8
To be sure, also set the following environment variables:
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
This should fix the text output!
Hi, i want to fork the project to try to modify some logic and create a new bot. What about the requirements to create a new bot and host the software on a different host?
Thanks