Telegram bietet die Möglichkeit, bei Clients auch deren Geolokation abzufragen. Das geht natürlich nicht ohne deren Zustimmung.
Dazu muss das Modul 50_TelegramBot.pm an ein paar Stellen ergänzt werden. Hier das entsprechende Patchfile, inklusive Erweiterung der CommandRef.
--- 50_TelegramBot.pm
+++ 50_TelegramBot.pm
@@ -296,6 +296,7 @@
"sendVideo" => "textField",
"sendLocation" => "textField",
+ "sendGetLocation" => "textField",
"favoritesMenu" => "textField",
@@ -607,7 +608,16 @@
$sendType = 12;
}
- if ( $sendType == 11 ) {
+ if ( $cmd eq 'sendGetLocation' ) {
+ # Request location using a one-time reply keyboard.
+ # Peer resolution and message dispatch use the normal send path.
+ $msg = join(" ", @args);
+ my @locationKeys = ( [ 'Standort senden:request_location' ] );
+ $addPar = TelegramBot_MakeKeyboard( $hash, 1, 0, @locationKeys );
+ return "TelegramBot_Set: Command $cmd, could not create location keyboard"
+ if ( ! defined( $addPar ) );
+
+ } elsif ( $sendType == 11 ) {
# location
return "TelegramBot_Set: Command $cmd, 2 parameters latitude / longitude need to be specified" if ( int(@args) != 2 );
@@ -2114,7 +2124,24 @@
} else {
return $ret if ( ! @keys );
%par = ( "one_time_keyboard" => (( ( defined( $onetime_hide ) ) && ( $onetime_hide ) )?JSON::true:JSON::true ) );
- $par{keyboard} = \@keys;
+ my @parKeys = ();
+
+ foreach my $aKeyRow (@keys) {
+ my @parRow = ();
+
+ foreach my $aKey (@$aKeyRow) {
+ if ($aKey =~ /^(.*):request_location$/) {
+ push(@parRow, {
+ text => $1,
+ request_location => JSON::true
+ });
+ } else {
+ push(@parRow, $aKey);
+ }
+ }
+ push(@parKeys, \@parRow);
+ }
+ $par{keyboard} = \@parKeys;
}
my $refkb = \%par;
@@ -3945,6 +3972,11 @@
<br>
+ <li><code>sendGetLocation [ @<peer1> ... @<peerN>] <text></code><br>
+ Sends a message with a one-time reply keyboard button requesting the recipient's current location.
+ If no peer is specified, defaultPeer is used. Location sharing requires a private chat
+ and explicit action by the recipient.
+ </li>
<li><code>sendLocation [ @<peer1> ... @<peerN>] <latitude> <longitude></code><br>Sends a location as pair of coordinates latitude and longitude as floating point numbers
<br>Example: <code>set aTelegramBotDevice sendLocation @@someusername 51.163375 10.447683</code> will send the coordinates of the geographical center of Germany as location.
</li>
Das komplette Modul hänge ich an.
LG
pah
Das one-time-keyboard zum Senden der gegenwärtigen Position ist dabei noch unangenehm groß.
Wenn man in Zeile 2126 statt
%par = ( "one_time_keyboard" => (( ( defined( $onetime_hide ) ) && ( $onetime_hide ) )?JSON::true:JSON::true ) ); schreibt
%par = ( "one_time_keyboard" => JSON::true, "resize_keyboard" => JSON::true );sieht das etwas eleganter aus.
LG
pah