当前位置: 首页 > news >正文

有哪个网站能卖自己做的衣服重庆白云seo整站优化

有哪个网站能卖自己做的衣服,重庆白云seo整站优化,遂宁建设机械网站,电商网站建设流程接上一篇文章,我们在创建好telegram机器人后,开始开发小游戏或者mini App,那就避免不了登录功能。 公开链接 bot设置教程:https://lengmo714.top/6e79860b.html 参考教程参考教程,telegram已经给我们提供非常多的api,我们在获取用…

接上一篇文章,我们在创建好telegram机器人后,开始开发小游戏或者mini App,那就避免不了登录功能。

公开链接
bot设置教程:https://lengmo714.top/6e79860b.html
参考教程参考教程,telegram已经给我们提供非常多的api,我们在获取用户信息的时候只需要调用对应的api即可。

拉起登录

我这里主要是获取头像、id、名字和状态。
用到2个api,getChatMembergetUserProfilePhotos
用法分别如下:
获取头像:

  // 初始化头像URL为空字符串let photoUrl = '';try {// 获取头像const profilePhotos = await bot.api.getUserProfilePhotos(userId, { limit: 1 });if (profilePhotos.total_count > 0) {const fileId = profilePhotos.photos[0][0].file_id;const file = await bot.api.getFile(fileId);photoUrl = `https://api.telegram.org/file/bot${TOKEN}/${file.file_path}`;}} catch (error) {console.error("获取头像失败: ", error);}

获取登录id:

  let userInfo = '';let id = "";let name = "";try {const chatMember = await bot.api.getChatMember(ctx.chat.id, userId);id = chatMember.user.id;name = chatMember.user.first_name;userInfo = `信息:\nID: ${chatMember.user.id}\n名字: ${chatMember.user.first_name}\n用户名: ${chatMember.user.username}\n状态: ${chatMember.status}`;} catch (error) {console.error("获取信息失败: ", error);}if (photoUrl) {await ctx.reply(`头像链接: ${photoUrl}`);} else {await ctx.reply("未能获取头像。");}await ctx.reply(userInfo || "未能获取信息。");

完整代码

import { Bot, InlineKeyboard } from "https://deno.land/x/grammy@v1.25.0/mod.ts";const TOKEN = '';  // bot机器人的token
const bot = new Bot(TOKEN);// 处理 /start 命令
bot.command("start", async (ctx) => {const firstName = ctx.update.message.from.first_name;const userId = ctx.from.id;// 初始化头像URL为空字符串let photoUrl = '';try {// 获取头像信息const profilePhotos = await bot.api.getUserProfilePhotos(userId, { limit: 1 });if (profilePhotos.total_count > 0) {const fileId = profilePhotos.photos[0][0].file_id;const file = await bot.api.getFile(fileId);photoUrl = `https://api.telegram.org/file/bot${TOKEN}/${file.file_path}`;}} catch (error) {console.error("获取头像失败: ", error);}// 获取用户登录信息let userInfo = '';let id = "";let name = "";try {const chatMember = await bot.api.getChatMember(ctx.chat.id, userId);id = chatMember.user.id;name = chatMember.user.first_name;userInfo = `信息:\nID: ${chatMember.user.id}\n名字: ${chatMember.user.first_name}\n用户名: ${chatMember.user.username}\n状态: ${chatMember.status}`;} catch (error) {console.error("获取信息失败: ", error);}if (photoUrl) {await ctx.reply(`头像链接: ${photoUrl}`);} else {await ctx.reply("未能获取头像。");}await ctx.reply(userInfo || "未能获取信息。");
});// 启动机器人
bot.start();

运行代码看先现象

执行下面命令,运动代码

deno run --allow-net ts脚本.ts
http://www.khdw.cn/news/9281.html

相关文章:

  • 西安学校网站建设费用注册公司
  • 网站做网站建网站赚钱
  • 王爷追妻有点忙石家庄seo结算
  • 广州设计网站百中搜优化
  • 如何做运营推广北京官网优化公司
  • 香港做电商网站最佳磁力吧cili8
  • 山西省网站建设制作十大免费网站推广入口
  • 申请好域名后 怎么做网站免费推广的网站平台
  • 网站建设管理制度好的搜索引擎推荐
  • 手机上可以做网站吗网站的营销推广方案
  • dw怎么做网站相册seo服务外包客服
  • wordpress如何去掉显示文章的分类杭州seo俱乐部
  • 常州网站外包网址注册查询
  • 做网站首页cdr杭州网站搜索排名
  • 辽宁建设厅南平网站seo
  • 做日历的网站教育培训网站设计
  • 传奇类游戏网站参考消息今天新闻
  • 装饰公司网站建设crm软件
  • 让别人做网站的步骤网站网络推广优化
  • 站长之家查询域名今天重大新闻头条新闻军事
  • 网站建设哪家有名简易网站制作
  • 大型网站怎么做个人怎么做网站
  • 仿织梦长沙网站公司淄博网站营销与推广
  • 怎么做一个软件手机优化大师官方版
  • 设计师联盟网站搜索引擎国外
  • 建设网站那个好郑州网站建设公司哪家好
  • 电子商务网站建设移动电商开发抖音十大搜索关键词
  • 专业团队p图沈阳百度推广优化
  • web前端自学网站2023年8月疫情爆发
  • discuz模板下载广州百度seo代理