Add a super basic /info command
Signed-off-by: Sayan Biswas <sayan@pokurt.me>
This commit is contained in:
parent
a926428437
commit
9c4623f033
|
@ -0,0 +1,8 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/SynicalBot.iml" filepath="$PROJECT_DIR$/.idea/SynicalBot.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,94 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PhpIncludePathManager">
|
||||
<include_path>
|
||||
<path value="//wsl$/Ubuntu-20.04/var/ppm" />
|
||||
<path value="//wsl$/Ubuntu-20.04/usr/share/php" />
|
||||
<path value="//wsl$/Ubuntu-20.04/etc/ppm/includes" />
|
||||
<path value="//wsl$/Ubuntu-20.04/etc/ppm/packages/net.intellivoid.tdlib==1.0.1.3" />
|
||||
<path value="//wsl$/Ubuntu-20.04/etc/ppm/packages/net.intellivoid.telegram_client_manager==2.0.0.6" />
|
||||
<path value="//wsl$/Ubuntu-20.04/etc/ppm/packages/net.intellivoid.background_worker==1.0.2.6" />
|
||||
<path value="//wsl$/Ubuntu-20.04/etc/ppm/packages/net.intellivoid.msqg==1.0.0.2" />
|
||||
<path value="//wsl$/Ubuntu-20.04/etc/ppm/packages/net.intellivoid.verbose_adventure==1.0.0.4" />
|
||||
<path value="//wsl$/Ubuntu-20.04/etc/ppm/packages/net.intellivoid.acm2==1.0.0.2" />
|
||||
</include_path>
|
||||
</component>
|
||||
<component name="PhpInterpreters">
|
||||
<interpreters>
|
||||
<interpreter id="9617b796-cde9-4a78-a7d8-c435a1d50420" name="Ubuntu-20.04" home="\\wsl$\Ubuntu-20.04/usr/bin/php" debugger_id="php.debugger.XDebug">
|
||||
<remote_data INTERPRETER_PATH="/usr/bin/php" HELPERS_PATH="" INITIALIZED="false" VALID="true" RUN_AS_ROOT_VIA_SUDO="false" DISTRIBUTION_ID="Ubuntu-20.04" />
|
||||
</interpreter>
|
||||
</interpreters>
|
||||
</component>
|
||||
<component name="PhpInterpretersPhpInfoCache">
|
||||
<phpInfoCache>
|
||||
<interpreter name="Ubuntu-20.04">
|
||||
<phpinfo binary_type="PHP" php_cli="/usr/bin/php8.0" path_separator=":" remote_host="8.8.8.8" version="8.0.13">
|
||||
<additional_php_ini>/etc/php/8.0/cli/conf.d/10-mysqlnd.ini, /etc/php/8.0/cli/conf.d/10-opcache.ini, /etc/php/8.0/cli/conf.d/10-pdo.ini, /etc/php/8.0/cli/conf.d/15-xml.ini, /etc/php/8.0/cli/conf.d/20-bcmath.ini, /etc/php/8.0/cli/conf.d/20-calendar.ini, /etc/php/8.0/cli/conf.d/20-ctype.ini, /etc/php/8.0/cli/conf.d/20-curl.ini, /etc/php/8.0/cli/conf.d/20-dom.ini, /etc/php/8.0/cli/conf.d/20-exif.ini, /etc/php/8.0/cli/conf.d/20-ffi.ini, /etc/php/8.0/cli/conf.d/20-fileinfo.ini, /etc/php/8.0/cli/conf.d/20-ftp.ini, /etc/php/8.0/cli/conf.d/20-gd.ini, /etc/php/8.0/cli/conf.d/20-gearman.ini, /etc/php/8.0/cli/conf.d/20-gettext.ini, /etc/php/8.0/cli/conf.d/20-gmagick.ini, /etc/php/8.0/cli/conf.d/20-iconv.ini, /etc/php/8.0/cli/conf.d/20-igbinary.ini, /etc/php/8.0/cli/conf.d/20-mbstring.ini, /etc/php/8.0/cli/conf.d/20-mcrypt.ini, /etc/php/8.0/cli/conf.d/20-mysqli.ini, /etc/php/8.0/cli/conf.d/20-pdo_mysql.ini, /etc/php/8.0/cli/conf.d/20-phar.ini, /etc/php/8.0/cli/conf.d/20-posix.ini, /etc/php/8.0/cli/conf.d/20-readline.ini, /etc/php/8.0/cli/conf.d/20-redis.ini, /etc/php/8.0/cli/conf.d/20-shmop.ini, /etc/php/8.0/cli/conf.d/20-simplexml.ini, /etc/php/8.0/cli/conf.d/20-sockets.ini, /etc/php/8.0/cli/conf.d/20-sysvmsg.ini, /etc/php/8.0/cli/conf.d/20-sysvsem.ini, /etc/php/8.0/cli/conf.d/20-sysvshm.ini, /etc/php/8.0/cli/conf.d/20-tokenizer.ini, /etc/php/8.0/cli/conf.d/20-xmlreader.ini, /etc/php/8.0/cli/conf.d/20-xmlwriter.ini, /etc/php/8.0/cli/conf.d/20-xsl.ini</additional_php_ini>
|
||||
<configuration_file>/etc/php/8.0/cli/php.ini</configuration_file>
|
||||
<configuration_options>
|
||||
<configuration_option name="include_path" value=".:/usr/share/php" />
|
||||
</configuration_options>
|
||||
<debuggers />
|
||||
<loaded_extensions>
|
||||
<extension name="Core" />
|
||||
<extension name="FFI" />
|
||||
<extension name="PDO" />
|
||||
<extension name="Phar" />
|
||||
<extension name="Reflection" />
|
||||
<extension name="SPL" />
|
||||
<extension name="SimpleXML" />
|
||||
<extension name="Zend OPcache" />
|
||||
<extension name="bcmath" />
|
||||
<extension name="calendar" />
|
||||
<extension name="ctype" />
|
||||
<extension name="curl" />
|
||||
<extension name="date" />
|
||||
<extension name="dom" />
|
||||
<extension name="exif" />
|
||||
<extension name="fileinfo" />
|
||||
<extension name="filter" />
|
||||
<extension name="ftp" />
|
||||
<extension name="gd" />
|
||||
<extension name="gearman" />
|
||||
<extension name="gettext" />
|
||||
<extension name="gmagick" />
|
||||
<extension name="hash" />
|
||||
<extension name="iconv" />
|
||||
<extension name="igbinary" />
|
||||
<extension name="json" />
|
||||
<extension name="libxml" />
|
||||
<extension name="mbstring" />
|
||||
<extension name="mcrypt" />
|
||||
<extension name="mysqli" />
|
||||
<extension name="mysqlnd" />
|
||||
<extension name="openssl" />
|
||||
<extension name="pcntl" />
|
||||
<extension name="pcre" />
|
||||
<extension name="pdo_mysql" />
|
||||
<extension name="posix" />
|
||||
<extension name="readline" />
|
||||
<extension name="redis" />
|
||||
<extension name="session" />
|
||||
<extension name="shmop" />
|
||||
<extension name="sockets" />
|
||||
<extension name="sodium" />
|
||||
<extension name="standard" />
|
||||
<extension name="sysvmsg" />
|
||||
<extension name="sysvsem" />
|
||||
<extension name="sysvshm" />
|
||||
<extension name="tokenizer" />
|
||||
<extension name="xml" />
|
||||
<extension name="xmlreader" />
|
||||
<extension name="xmlwriter" />
|
||||
<extension name="xsl" />
|
||||
<extension name="zlib" />
|
||||
</loaded_extensions>
|
||||
</phpinfo>
|
||||
</interpreter>
|
||||
</phpInfoCache>
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="7.1">
|
||||
<option name="suggestChangeDefaultLanguageLevel" value="false" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpUndefinedClassInspection */
|
||||
/** @noinspection PhpUnused */
|
||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
||||
|
||||
namespace Longman\TelegramBot\Commands\SystemCommands;
|
||||
|
||||
use Longman\TelegramBot\Commands\SystemCommand;
|
||||
use Longman\TelegramBot\Entities\ServerResponse;
|
||||
use Longman\TelegramBot\Exception\TelegramException;
|
||||
use Longman\TelegramBot\Request;
|
||||
use SpamProtectionBot;
|
||||
|
||||
/**
|
||||
* Info command
|
||||
*
|
||||
* Gets executed when user sends /info
|
||||
*/
|
||||
|
||||
class InfoCommand extends SystemCommand {
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'info';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Gets executed when user sends /info';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $usage = '/info';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $version = '1.0.0';
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $private_only = false;
|
||||
|
||||
/**
|
||||
* The whois command used for finding targets
|
||||
*
|
||||
* @var WhoisCommand|null
|
||||
*/
|
||||
public $WhoisCommand = null;
|
||||
|
||||
/**
|
||||
* Command execute method
|
||||
*
|
||||
* @return ServerResponse
|
||||
* @throws TelegramException
|
||||
* @noinspection DuplicatedCode
|
||||
*/
|
||||
public function execute(): ServerResponse
|
||||
{
|
||||
// Ignore forwarded commands
|
||||
if($this->getMessage()->getForwardFrom() !== null || $this->getMessage()->getForwardFromChat())
|
||||
{
|
||||
return Request::emptyResponse();
|
||||
}
|
||||
$user = $this->getMessage()->getFrom();
|
||||
|
||||
if ($user == null) {
|
||||
return Request::sendMessage([
|
||||
"chat_id" => $this->getMessage()->getChat()->getId(),
|
||||
"reply_to_message_id" => $this->getMessage()->getMessageId(),
|
||||
"parse_mode" => "html",
|
||||
"text" => "User not found"
|
||||
]);
|
||||
}
|
||||
$txt = "<b>User info</b>\n";
|
||||
$txt .= "<b>FirstName</b>: " . "<code>" . $user->getFirstName() . "</code>\n";
|
||||
$txt .= "<b>LastName</b>: " . "<code>" . $user->getLastName() . "</code>\n";
|
||||
// $txt .= "<b>Username</b>:" . "<code>" . $user->getUsername() . "</code>\n";
|
||||
$txt .= "<b>UserID</b>: " . "<code>" . $user->getId() . "</code>\n";
|
||||
$txt .= "<b>Mention</b>: " . $user->tryMention() . "\n";
|
||||
return Request::sendMessage([
|
||||
"chat_id" => $this->getMessage()->getChat()->getId(),
|
||||
"reply_to_message_id" => $this->getMessage()->getMessageId(),
|
||||
"parse_mode" => "html",
|
||||
"text" => $txt
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -83,17 +83,21 @@
|
|||
"components": [
|
||||
{
|
||||
"required": true,
|
||||
"file": "SynicalBot.php"
|
||||
"file": "commands/InfoCommand.php"
|
||||
},
|
||||
{
|
||||
"required": true,
|
||||
"file": "commands/StartCommand.php"
|
||||
},
|
||||
{
|
||||
"required": true,
|
||||
"file": "SynicalBot.php"
|
||||
}
|
||||
],
|
||||
"files": [
|
||||
"package.json",
|
||||
"worker",
|
||||
".htaccess",
|
||||
"main"
|
||||
"main",
|
||||
"package.json",
|
||||
"worker"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue