Skip to content

Instantly share code, notes, and snippets.

Avatar

Luiz Marcus luizmarcus

View GitHub Profile
View exemplo_photo_telegram.php
<?php
require('parser.php');
define('BOT_TOKEN', 'SEU TOKEN');
define('API_URL', 'https://api.telegram.org/bot'.BOT_TOKEN.'/');
function processMessage($message) {
// processa a mensagem recebida
$message_id = $message['message_id'];
View exemplo_photo_telegram_if.php
<?php
if (isset($message['photo'])) { //checa se existe uma imagem na mensagem
$photo = $message['photo'][count($message['photo'])-1]; //obtém a imagem no tamanho original
//envia a imagem recebida com a legenda
sendMessage("sendPhoto", array('chat_id' => $chat_id, "photo" => $photo["file_id"], "caption" => "A legenda da foto foi: ".$$message["caption"]));
}
?>
View exemplo_photo_telegram.json
{
"update_id":360000000,
"message":{
"message_id":00000,
"from":{"id":137000000,"is_bot":false,"first_name":"Luiz Teste","username":"teste","language_code":"pt-br"},
"chat":{"id":137000000,"first_name":"Luiz Teste","username":"teste","type":"private"},
"date":1616007215,
"photo":[
{"file_id":"AgACAgEQWQSxkBAAKmzWsfrerrgdfgEwSFxc7Zb1OAAK-qDEbXP2QRjWxhui1v8GZjuOuSxcAAwEAAwIAA20AA_HPAAIeCV","file_unique_id":"AQADjuOuSxcAA_HPAAI","file_size":19198,"width":301,"height":320},
{"file_id":"AgACAgEQWQSxkBAAKmzWsfrerrgdfgEwSFxc7Zb1OAAK-qDEbXP2QRjWxhui1v8GZjuOuSxcAAwEAAwIAA20AA_HPAAIeCV","file_unique_id":"AQADjuOuSxcAA_LPAAI","file_size":52522,"width":752,"height":800},
View exemplo_flutter_drawer_expansion.dart
Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: Text('Cabeçalho'),
decoration: BoxDecoration(
color: Colors.blue,
),
),
View chatbot_flutter_backend.php
<?php
require('parser.php');
function processMessage($text) {
if (isset($text)) {
if ($text === "mega") {
echo getResult('megasena', $text);
} else if ($text === "quina") {
echo getResult('quina', $text);
} else if ($text === "lotomania") {
View chatbot_flutter_onsend.dart
void onSend(ChatMessage message) async {
print(message.toJson());
setState(() {
messages = [...messages, message];
print(messages.length);
});
sendMessage(message.text);
}
void initDio() {
View chatbot_flutter_chatuser.dart
final ChatUser user = ChatUser(
name: "Usuário",
firstName: "Usuário",
lastName: "Fulano",
uid: "0001",
);
final ChatUser bot = ChatUser(
name: "Bot",
uid: "0002",
View chatbot_flutter_dashchat.dart
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Chat App"),
),
body: DashChat(
inverted: false,
onSend: onSend,
sendOnEnter: true,