这是一个tg群组索引机器人,群组收录,群组索引

这篇具有很好参考价值的文章主要介绍了这是一个tg群组索引机器人,群组收录,群组索引。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

tg的索引机器人,今天终于做出来了,索引群组收录
主要功能: 索引机器人+后台管理
积分管理、自动回复、广告管理、消费管理。
机器人管理:搜索关键词管理、机器人群组管理、群组收录、营销软件卡密管理;
担保交易:商家入驻、商品发布、商品管理、订单管理、消费管理;
基于php+tg bot api开发会收集用户的userid以及用户的名称用户搜索的内容。
测试:
https://t.me/sousuo_q
以下代码为主要功能:
telegram超级索引机器人,搜索引擎#pic_center文章来源地址https://www.toymoban.com/news/detail-754327.html

<?php


namespace app\controller;


use TelegramBot\Api\Exception;
use think\exception\ErrorException;
use think\response\Json;

class Message extends Base
{
    private $update;
    private $bot;
    private $token;
    public function __construct($update,$bot)
    {
        $this->update = $update;
        $this->bot = $bot;
    }
    //开始
    public function start($token){
        $content = new Contents();

        //退群操作
        if($this->update->getMessage()->getLeftChatMember()){
            exit();
        }
        //用户进群处理
        if($this->update->getMessage()->getNewChatMembers()){
            $newmember = new Newmember($this->bot,$this->update);
            $newmember->start();
            exit();
        }
        //发送的消息处理
        //$content->getButton($this->update->getMessage()->getText());

            $text = $this->update->getMessage()->getText();
            //记录会员数据
            $arr = [
                "chatid" => $this->update->getMessage()->getChat()->getId(),
                "userid" => $this->update->getMessage()->getFrom()->getId(),
                "type" => $this->update->getMessage()->getChat()->getType(),
                "text" => $text,
                "username" => $this->update->getMessage()->getFrom()->getUsername() == null ? "" : $this->update->getMessage()->getFrom()->getUsername(),
                "firstName" => $this->update->getMessage()->getFrom()->getFirstName() == null ? "" : $this->update->getMessage()->getFrom()->getFirstName(),
                "lastName" => $this->update->getMessage()->getFrom()->getLastName() == null ? "" : $this->update->getMessage()->getFrom()->getLastName(),
            ];
            $json = json_encode($arr, JSON_UNESCAPED_UNICODE);
            $this->sendMess($json);
            $arrd = [
                "tgid" => $this->update->getMessage()->getFrom()->getId(),             //记录会员id
                "username" => $this->update->getMessage()->getFrom()->getUsername() == null ? "" : $this->update->getMessage()->getFrom()->getUsername(),    //记录会员用户名
                "firstname" => $this->update->getMessage()->getFrom()->getFirstName() == null ? "" : $this->update->getMessage()->getFrom()->getFirstName(), //记录会员姓
                "lastname" => $this->update->getMessage()->getFrom()->getLastName() == null ? "" : $this->update->getMessage()->getFrom()->getLastName(),    //记录会员名
                "headimg" => "",           //记录会员头像文件id
                "up_tg_id" => "",                                                                                  //记录会员上级会员id
            ];
            //记录会员信息
            $this->saveMember($arrd);
            
        switch ($this->update->getMessage()->getChat()->getType()){
            //私信机器人
            case "private":
                try{$this->update->getMessage()->getReplyToMessage()->getText();
                    //echo $this->update->getMessage()->getReplyToMessage()->getText();exit();
                    $reply = new Replymess($this->bot,$this->update);
                    $reply->start();
                    exit();
                }catch (\Error $e){}
                $shoulu = new Shoulu();
                if(count(explode("@",$text)) == 2){
                    $user = explode("@",$text);
                    $res = $shoulu->index($token,$user[1],$this->update->getMessage()->getChat()->getId(),0);
                    $this->bot->sendMessage($this->update->getMessage()->getChat()->getId(),$res,"html",true,$this->update->getMessage()->getMessageid());
                    exit();
                }elseif(count(explode("t.me/",$text)) == 2){
                    $user = explode("t.me/",$text);
                    $res = $shoulu->index($token,$user[1],$this->update->getMessage()->getChat()->getId(),0);
                    $this->bot->sendMessage($this->update->getMessage()->getChat()->getId(),$res,"html",true,$this->update->getMessage()->getMessageid());
                    exit();
                }
                //dump($this->update);exit();
                //开启私信搜索功能
                if($this->getSystemConfig("issearch")){
                    $this->bot->sendMessage($this->update->getMessage()->getChat()->getId(),$content->getContent($this->update->getMessage()->getText()),"HTML",true,$this->update->getMessage()->getMessageid(),$content->getButton($this->update->getMessage()->getText()));
                }
                break;
                //超级群组
            case "supergroup":
                //获取到群组搜索的字符字数比对后台设定的字符字数
                if(strlen($text) > (int)$this->getSystemConfig("lenght")){
                    $this->bot->deleteMessage($this->update->getMessage()->getChat()->getId(),$this->update->getMessage()->getMessageid());
                    exit();
                }
                $ginfo = $this->getGroup($this->update->getMessage()->getChat()->getId());
                try {
                    if ($ginfo["issearch"] != 0) {
                        if(!$this->update->getMessage()->getFrom()->isBot()){
                            //echo 1;
                            //dump($content->getContent($this->update->getMessage()->getText()));
                            $this->bot->sendMessage($this->update->getMessage()->getChat()->getId(), $content->getContent($this->update->getMessage()->getText()), "HTML", true, $this->update->getMessage()->getMessageid(), $content->getButton($this->update->getMessage()->getText()));
                            //echo 2;
                        }
                    }
                }catch(ErrorException $e){
                    $this->bot->sendMessage($this->update->getMessage()->getChat()->getId(), $content->getContent($this->update->getMessage()->getText()), "HTML", true, $this->update->getMessage()->getMessageid(), $content->getButton($this->update->getMessage()->getText()));
                }
                break;
                //私群
            case "group":
                //判断私群是否开启搜索功能
                if($this->getSystemConfig("prigroups")) {
                    $this->bot->sendMessage($this->update->getMessage()->getChat()->getId(), $content->getContent($this->update->getMessage()->getText()), "HTML", true, $this->update->getMessage()->getMessageid(), $content->getButton($this->update->getMessage()->getText()));
                }
                break;
        }
    }
}


<?php
namespace app\controller;
use TelegramBot\Api\Client;
use TelegramBot\Api\Exception;
use TelegramBot\Api\Types\Update;
use think\exception\ErrorException;

class Index extends Base
{
    public function index($token = null){
        //exit();
        if($token == null || $token == ""){
            ejson("token不能为空");
        }
        try {
            $mess = $this->saveMessage();      //保存消息记
            if($mess["code"] == 0){
                echo 1;exit();
            }
            //实例化消息
            $bot = new Client($token);
            //开始
            $bot->command('start', function ($message) use ($bot) {
                $r = explode(" ",$message->getText());
                $arr = [
                    "tgid" => $message->getChat()->getId(),             //记录会员id
                    "username" => $message->getChat()->getUsername() == null?"":$message->getChat()->getUsername(),    //记录会员用户名
                    "firstname" => $message->getChat()->getFirstName() == null?"":$message->getChat()->getFirstName(), //记录会员姓
                    "lastname" => $message->getChat()->getLastName() == null?"":$message->getChat()->getLastName(),    //记录会员名
                    "headimg" => $message->getChat()->getPhoto() == null?"":$message->getChat()->getPhoto(),           //记录会员头像文件id
                    //"up_tg_id" => "",                                                                                  //记录会员上级会员id
                ];
                if(array_key_exists(1,$r)){
                    $arr["up_tg_id"] = $r[1];
                }else{
                    $arr["up_tg_id"] = "";
                }
                //记录会员信息
                if($this->saveMember($arr)["code"] != 5){
                    hook('invitehook', ['mid'=>$r[1],"number"=>$this->getSystemConfig("newmember"),"msg"=>"邀请新用户".$r[1]."奖励".$this->getSystemConfig("newmember")."积分"]);
                }
                //请求start页面内容
                $submitInfo = $this->getButtonInfo("start");
                //按钮json转换成数组
                $button = json_decode($submitInfo["data"]["button"],true);
                //判断接口是否成功
                if($submitInfo["code"] == 0){
                    //不成功发送错误信息给用户
                    $bot->sendMessage($arr["tgid"],$submitInfo["msg"]);
                }else{
                    //判断按钮是否为空
                    if($button) {
                        //不为空实例化按钮数据并发送消息
                        $keyboard = new \TelegramBot\Api\Types\Inline\InlineKeyboardMarkup($button);
                        $bot->sendMessage($arr["tgid"], $submitInfo["data"]["title"], "HTML", true,null,$keyboard);
                    }else{
                        //否则发送不带按钮的消息
                        $bot->sendMessage($arr["tgid"], $submitInfo["data"]["title"], "HTML", true);
                    }
                }
            });
            //接收到的消息
            $bot->on(function (Update $update) use ($bot,$token) {
                //编辑消息
                if($update->getEditedMessage()){
                    new Editedmessage($update->getEditedMessage(),$bot);
                }
                //正常消息
                if($update->getMessage()){
                    $message = new Message($update,$bot);
                    $message->start($token);
                }
                //内联按钮
                if($update->getCallbackQuery()){
                    $CallbackQuery = new Callbackquery($update,$bot);
                    $CallbackQuery->start();
                }
            }, function () {
                return true;
            });
            $bot->run();
        }catch (Exception $e){
            echo $e->getMessage().$e->getFile();
        }catch (ErrorException $e){
            echo $e->getMessage().$e->getFile().$e->getLine();
        }
    }


    public function test(){
        echo hook('invitehook', ['mid'=>1,"number"=>1,"msg"=>"邀请新用户奖励1积分"]);
    }
    //充值成功通知
    public function notify($uid,$money,$orderid){
        $bot = new Client(getSystemConfig("timetasktoken"));
        $bot->sendMessage($uid,"您的订单号:{$orderid}\n到账金额:{$money} USDT\n充值成功,成功到账到余额,请注意查看");
    }
    
    public function sendtx($ids,$uid){
        $txinfo = $this->queryCash($ids);
        $bot = new Client(getSystemConfig("timetasktoken"));
        $bot->sendMessage($uid,"您的提现已经处理了\n提现金额:".$txinfo["actualmoney"]." USDT\n到账金额:".$txinfo["money"]." USDT\n到账TRC20地址 : ".$txinfo["utoken"]."\n提示消息 : ".$txinfo["msg"]);
    }

}

到了这里,关于这是一个tg群组索引机器人,群组收录,群组索引的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 3dsmax制作一个机器人

    2024年02月16日
    浏览(31)
  • 制作一个Python聊天机器人

    我们学习一下如何使用 ChatterBot 库在 Python 中创建聊天机器人,该库实现了各种机器学习算法来生成响应对话,还是挺不错的 聊天机器人也称为聊天机器人、机器人、人工代理等,基本上是由人工智能驱动的软件程序,其目的是通过文本或语音与用户进行对话。 我们日常接触

    2024年01月19日
    浏览(48)
  • matlab中画有重影的机器人运动过程【给另一个机器人设置透明度】

    1、前言如题 2、参考连接如下 How to plot two moving robot in the same figure and change one of them transparency? - MATLAB Answers - MATLAB Central (mathworks.cn)3、代码:【找到figure中对应对象并设置属性】 4、结果【同样的轨迹,实影的先运动几个步数,虚影后续运动】    

    2024年02月17日
    浏览(34)
  • 使用Streamlit 实现一个聊天机器人界面

    效果如下: 只需要效果generate_llama2_response 为你的 llm的输出即可。

    2024年03月09日
    浏览(62)
  • 使用Node+Wechaty做一个机器人

    目录 前言 准备工作 起步 实践 写在最后 这篇文章将结合Wechaty去实现一个机器人 在开始编码之前,我们先了解一下 wechaty Wechaty是一个聊天机器人,只需6行代码即可实现一个机器人,其跨平台性,多编程语言支持,使其在众多开源的bot项目中大放光彩。 关于它的使用,官方

    2024年02月11日
    浏览(36)
  • 搭建一个 MidJourney-微信群机器人

    知数云 MJ 微信群机器人,调用 Midjourney Imagine API 进行画图。 市面上价值XXXX的 MidJourney 微信群机器人,且用且珍惜。 需求 :mytimerun。 wechaty_puppet_service_token = “环境变量” zhishuyun_chatgpt_35_token = “GPT API 接口的 token” zhishuyun_midjourney_token = “MJ API 接口的 token” 执行代码前先设

    2024年02月16日
    浏览(34)
  • Javascript 编写一个简单的聊天机器人

    在本 Web 开发教程中,我们将了解如何使用 HTML、CSS 和 vanilla JavaScript 创建基本的聊天机器人。本练习侧重于 JS 基础知识,而不是任何类型的人工智能 (AI)。为了使该过程更简单,更易于学习,我没有使用任何第三方库。我将通过专注于JavaScript编程语言的基础知识从头开始

    2024年02月05日
    浏览(37)
  • 使用Python做一个微信机器人

    实现代码和pip安装: https://blog.csdn.net/Qwertyuiop2016/article/details/135076957 简介 该程序将微信的内部功能提取出来,然后在程序里加载Python,接着将这些功能导出成库函数,就可以在Python里使用这些函数 程序启动的时候会执行py_code目录下的main.py,类似于你在命令行使用 python main

    2024年02月07日
    浏览(27)
  • 基于小程序制作一个ChatGPT聊天机器人

    在AI技术日新月异的浪潮中,将ChatGPT与实战开发相结合,制作一个随身携带的聊天机器人,紧贴前沿的同时稳固基础。

    2023年04月11日
    浏览(41)
  • 使用Arduino Uno构建一个巡线机器人

    原文 MX 巡线机器人 (LFR: line follower robot)是一种简单的自主引导机器人,它遵循在地面上绘制的线来检测白色表面上的暗线或黑暗表面上的白线。在本教程中,使用 Arduino Uno 和一些易于访问的组件构建黑线跟随机器人。 巡线机器人的原理 如前所述,巡线机器人(LFR)跟随

    2024年02月10日
    浏览(31)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包