slack 聊天机器人

by Bertrand Fan

通过范伯特朗

无法筹集资金的Slack机器人 (Unfundable Slack bots)

In December, Slack announced a $80 million fund to invest in software projects that complement its technology. As an early adopter of the Slack API, here are some “bets” that I’ve made on the Slack platform:

去年12月,Slack宣布了8000万美元的基金,用于投资补充其技术的软件项目。 作为Slack API的早期采用者,以下是我在Slack平台上进行的一些“下注”:

每10秒钟播放一帧自动播放《星球大战特别版》(汉斯拍摄的第一张!)的机器人。 整个过程大约需要20个小时。 (A bot that plays all of Star Wars Despecialized Edition (Han shoots first!) one frame every ten seconds. It takes about 20 hours to get through the whole thing.)

托管“抵抗”游戏的机器人(可以选择使用“隐藏议程”扩展程序中的“刺客模块”)。 秘密投票是通过bot通过DM进行的,而公共操作则在渠道中进行。 (A bot that hosts games of The Resistance (optionally with the Assassin Module from the Hidden Agenda expansion). Secret voting is conducted via DM with the bot, while public actions are done in the channel.)

通过发出命令(向左,向右,向上,向下,打开和开火)让您玩Wolfenstein 3D的机器人。 您可以选择指定向左和向右旋转多少度,但是默认情况下您可以旋转45度。 我从未成功完成第一关,但我设法杀死了几名后卫。 (A bot that lets you play Wolfenstein 3D by issuing commands (left, right, up, down, open, and fire). You can optionally specify how many degrees to turn left and right, but by default you turn 45-degrees. I’ve never successfully completed the first level, but I have managed to kill several guards.)

I’m happy to announce that I’ve completed my latest bot, Vandelay Industries. Vandelay Industries is a shameless rip-off of Frinkiac that lets you search for animated gifs from every episode of Seinfeld in Slack. It has every line of dialogue ever spoken in Seinfeld.

我很高兴地宣布,我已经完成了最新的机器人Vandelay Industries 。 Vandelay Industries是Frinkiac的无耻剥夺者 ,它使您可以从Slack的Seinfeld的每一集中搜索GIF动画。 它拥有塞恩费尔德曾经说过的所有对话方式。

If you’d like to try it out in your Slack team, just go to Vandelay Industries and click Add to Slack. It will ask you for permission to add a new slash command, /vandelay and once authorized, it should be ready to use immediately within Slack.

如果您想在Slack团队中尝试一下,只需转到Vandelay Industries ,然后点击添加到Slack即可 。 它会要求您添加新的斜杠命令/ vandelay的权限,并且一旦获得授权,就应该可以立即在Slack中使用它。

If you’re interested in the technical details of how it works, keep on reading! If not, you’ve managed to beat the estimated reading time for this article. Congratulations!

如果您对它如何工作的技术细节感兴趣,请继续阅读! 如果没有,您已经超过了本文的预计阅读时间。 恭喜你!

处理中 (Processing)

I initially started with 91G of all nine seasons of Seinfeld in surprisingly high quality 720p. I ultimately ended up with 111G worth of animated GIFs which tells you everything you need to know about the efficiency of that file format. This section is all about how I went from one to the other.

最初,我以整个720p的高画质开始使用Seinfeld的所有九个季节的91G。 我最终得到了价值111G的动画GIF,可以告诉您有关该文件格式效率的所有信息。 这一部分是关于我如何从一个人到另一个人的。

The files were in MKV containers, so I was able to use MKVToolNix to extract the subtitles from them. You can use mkvinfo to list the various segment tracks:

这些文件位于MKV容器中,因此我能够使用MKVToolNix从它们中提取字幕。 您可以使用mkvinfo列出各种段轨道:

mkvinfo Seinfeld.S01E01.The.Seinfeld.Chronicles.mkv

It’s a little hard to read, but the track that we’re interested in is Track number 3, the first subtitles track. After noting the track ID (2), we can extract the subtitles into an SRT file like this:

有点难读,但是我们感兴趣的音轨是音轨编号3,第一个字幕音轨。 注意轨道ID(2)之后,我们可以将字幕提取到SRT文件中,如下所示:

mkvextract tracks Seinfeld.S01E01.The.Seinfeld.Chronicles.mkv 2:S01E01.srt

The SRT format is fairly straightforward. It contains a counter, start time, end time, and the subtitle text. Using a parser like subtitles-parser, we can easily iterate over the subtitles.

SRT格式相当简单。 它包含一个计数器,开始时间,结束时间和字幕文本。 使用像subtitles- parser这样的解析器 ,我们可以轻松地对字幕进行迭代。

The next step is to loop through each subtitle and extract that time range from the MKV into an animated GIF. There’s an excellent article about using ffmpeg to encode high quality GIF but if you don’t want to read that right now, the trick is to extract a specialized palette from the section of the video that you’re interested in and then use that to encode the GIF.

下一步是遍历每个字幕,并将该时间范围从MKV提取到动画GIF中。 有一篇关于使用ffmpeg编码高质量GIF的出色文章,但是如果您现在不想阅读,诀窍是从您感兴趣的视频部分中提取专门的调色板,然后将其用于编码GIF。

Here’s a script that I adapted for the purposes of this processing step:

这是我为了该处理步骤而修改的脚本:

320 refers to how many pixels wide the resulting GIF will be. You’ll notice that instead of specifying a start time and an end time, I instead specify a duration. Although ffmpeg claims to support end times, no matter which version I tried I could not get it to properly extract the right range, so I ended up calculating the duration by subtracting the start time from the end time and abusing the unix epoch like this:

320表示生成的GIF将有多少像素宽。 您会注意到,我没有指定开始时间和结束时间,而是指定了持续时间。 尽管ffmpeg声称支持结束时间,但是无论我尝试使用哪个版本,我都无法使其正确提取正确的范围,因此最终我通过从结束时间中减去开始时间并滥用unix历元来计算持续时间,如下所示:

After applying the gifenc.sh script, we’re left with a nice animated GIF of the correct extracted range like this:

应用gifenc.sh脚本后,剩下的动画GIF正确提取范围如下:

But I wanted to display the subtitle text at the bottom of the GIF and after digging through the ImageMagick documentation, I came up with this:

但是我想将字幕文本显示在GIF的底部,并且在浏览了ImageMagick文档后,我想到了:

It’s not the most elegant solution, but it gets the job done. Our final gif looks like this:

这不是最优雅的解决方案,但可以完成工作。 我们的最终gif如下所示:

Now just do that about 104,782 more times and you’re done. Running an entire episode through ffmpeg and ImageMagick took about 30 minutes on my top-of-the-line-in-2011 Macbook Pro. This is the part of the story where I’d like to tell you that I managed to leverage Amazon Elastic Transcoder or made a hadoop job to distribute the load to all the computers in my house, but really what I did was put all of this on my reconditioned budget OVH server and let it run for 5 days while I continued to live my life.

现在只需再执行104,782次,您就完成了。 在ffmpeg和ImageMagick上运行一整集,大约花了30分钟,这是我在2011年最先进的Macbook Pro上完成的。 这是故事的一部分,我想告诉您,我设法利用Amazon Elastic Transcoder或做了一个工作,将负载分配到家里的所有计算机上,但实际上我所做的一切在经过重新调整的预算OVH服务器上运行5天,同时继续生活。

Once it was done encoding all the GIFs, I just let Apache serve them statically with a long Expires header and put Cloudflare in front of the whole domain. Only time will tell if that will actually hold up with traffic demands.

完成对所有GIF的编码后,我就让Apache通过长的Expires标头静态地为它们提供服务,并将Cloudflare置于整个域的前面。 只有时间才能证明这是否真的能满足交通需求。

正在搜寻 (Searching)

I installed Elasticsearch and indexed the contents of the SRT files. Here’s where I encountered some non-technical snags: In Season 6, episodes 14 and 15 are an hour-long clip show called Highlights of a Hundred where Jerry Seinfeld shows you a bunch of old clips from previous episodes. And in the final episode of Seinfeld, Season 9, Episode 23, they do a ton of flashbacks to previous episodes. Both of these would routinely get returned in the search results, so I just excluded them from the search query. There’s probably a better way to just lower the quality of those episode scores, but the documentation for doing so in Elasticsearch is about as easy to read as the above mentioned ImageMagick documentation. And at the end of the day, no one wants to see clips from either of those two episodes. Sorry, Larry David, the last episode was terrible.

我安装了Elasticsearch并为SRT文件的内容建立了索引。 在这里,我遇到了一些非技术难题:在第6季中,第14和15集是一个长达一个小时的剪辑节目,称为“一百集精彩集锦”,杰里·塞恩菲尔德(Jerry Seinfeld)向您展示了前几集中的一堆旧剪辑。 在《塞恩菲尔德》的最后一集,第9季,第23集中,他们对前几集进行了大量的回溯。 这两种方法通常都会在搜索结果中返回,因此我只是从搜索查询中排除了它们。 降低这些情节得分的质量可能是更好的方法,但是Elasticsearch中的文档与上述ImageMagick文档一样容易阅读。 最终,没有人希望看到这两集中的任何一个的剪辑。 抱歉,拉里·戴维(Larry David),最后一集很糟糕。

斜杠命令 (Slash Command)

The final step was just to wrap it all together with a Slack slash command, which is just a simple Express app that acts as a client to the Elasticsearch instance. There’s some OAuth to package the command as a Slack App and handle the Add to Slack button, but I don’t really need to check for authentication when the requests come through so I’m not saving the authorization tokens. The code for the server is available here: vandelayindustries-slack-server.

最后一步只是将所有内容与Slack斜杠命令包装在一起,这是一个简单的Express应用程序,充当Elasticsearch实例的客户端。 有一些OAuth可以将命令打包为Slack应用程序并处理“添加到Slack”按钮,但是当请求通过时,我真的不需要检查身份验证,因此我不保存授权令牌。 该服务器的代码在此处可用: vandelayindustries-slack-server 。

That’s it! I hope this technical writeup helps the next person that wants to extract GIFs from an entire television show for little to no actual reason.

而已! 我希望这项技术文章能帮助下一个想要从整个电视节目中提取GIF的人,几乎不需要任何理由。

翻译自: https://www.freecodecamp.org/news/unfundable-slack-bots-9369a75fdd/

slack 聊天机器人

slack 聊天机器人_无法筹集资金的Slack机器人相关推荐

  1. slack 聊天机器人_构建自己的Slack机器人

    slack 聊天机器人 利用Slack的强大功能,您可以做很多很酷的事情-专用频道,嵌入各种内容,从一个位置搜索所有消息,共享文件和代码,使用许多可用的集成中的一些或自己构建. 在这篇文章中,我将重点 ...

  2. 用python写聊天机器人_用Python 写一个机器人陪你聊天(文尾有彩蛋)

    工作一忙,原来秉烛夜谈的好友现在都很少聊天,微信都成了微信群的天下,鲜有微信好友给你发消息,想要主动发却也找不到开题话题,怎么办?用Python写一个机器人陪自己聊聊天吧.以下是源码及解析,小白都看得 ...

  3. 第十代晨风机器人_第十代QQ机器人下载_第十代QQ机器人 v20180102 官方版 - 西西下载...

    官方介绍: 第十代QQ机器人是对QQ进行功能扩展的程序,在第十代机器人软件登录QQ号码后可以按照预先设定的一些指令自动完成某些任务,例如与好友进行交流,执行一些数据交互任务,实现QQ与网站的交互,常用 ...

  4. mc有什么红石机器人_我的世界红石机器人怎么做_我的世界红石机器人制作教程...

    我的世界是一款风靡全球的高自由度沙盒游戏,很多玩家都认为在游戏中做一个会动的机器人是一件很有趣的事情,然而还有很多小伙伴不清楚怎么搭建机器人,那么我的世界红石机器人怎么做?下面小编就把我的世界红石机器 ...

  5. 正定小主人机器人_石家庄正定县2015中小学生机器人运动大赛隆重开幕

    原标题:石家庄正定县2015中小学生机器人运动大赛隆重开幕 河北新闻网讯(燕赵都市报记者刘杰 通讯员魏志军)近日,石家庄正定县2015年中小学生机器人运动大赛在正定一中隆重开幕.来自全县中小学28支代 ...

  6. ironbot智能编程机器人_视频 | 多模式编程机器人,“程序猿”培养从小抓起

    原标题:视频 | 多模式编程机器人,"程序猿"培养从小抓起 一谈到机器人,男孩子的心中必定莫名的兴奋,已经三十好几的我,谈到机器人依然兴奋不已.男孩子的心中对于机器总有一丝莫名的冲 ...

  7. 光伏电站清扫机器人_轻型光伏电站清扫机器人的制作方法

    本实用新型涉及一种清扫机器人,尤其涉及一种轻型光伏电站清扫机器人. 背景技术: 众所周知,现有光伏电站的清扫机器人逐渐增多,但清扫机器人重量都偏重,一般都在65KG以上,有的甚至能达到80KG:这样的 ...

  8. delphi 企业微信消息机器人_企业微信—群聊机器人

    在企业微信群聊机器人接口对接天气API使用过程中,遇到 过一个问题,就是对于嵌套json数据如何进行嵌套的| 一:"msgtype": "text", curl ...

  9. 萨默尔机器人_助力产业发展 西安市人工智能机器人学会正式成立

    8月23日,西安市人工智能机器人学会在西咸新区沣东新城协同创新港正式成立.西安报业全媒体记者 冯炜 摄 8月23日,西安市人工智能机器人学会正式成立.学会将通过市场化机制.社会化服务等方式,整合科技创 ...

  10. 妖帝q群机器人_有关酷Q 晨风机器人,契约 qqlite qqlight ,mypc等QQ机器人关停一事的一点想法...

    估计有不少朋友都使用过QQ机器人,因为很多网友每天都要管理很多个QQ交流群,如果一个人管理,估计都得累死,所以一般都会使用QQ机器人来帮助自己管理. 只是腾讯自身的QQ机器人实在不给力,功能太鸡肋,而 ...

最新文章

  1. 微信是把“杀猪刀”,还改变了我的表情包
  2. STM32使用另外两种方法使LED灯闪烁
  3. RubyOnRails小资料
  4. |洛谷|分治|P2799 国王的魔镜
  5. 2022年初,给5年内还想做产品经理的提个醒!
  6. 安装 | Anaconda3下载链接
  7. Jupyter Notebook: 解决build docker-stacks时conda太慢的问题
  8. 多租户数据库设计方法:共享数据库表
  9. iptables二之防火墙SNAT源地址转换,MASQUERADE地址伪装之DNAT目标地址转换讲解和实验演示...
  10. IWMS实现频道页面的方法
  11. 基于像素聚类的分割方法基于slic的方法_博士论文摘要 | 张荣春:数码影像与TLS点云数据融合提取地质结构面方法研究...
  12. java.io.file.sync_Java(25)IO流和File类
  13. 线性结构 —— 分块算法
  14. 2021年中国一次性卫生设备市场趋势报告、技术动态创新及2027年市场预测
  15. 合并排序 非递归 java_合并排序-非递归
  16. 解析Node.js通过axios实现网络请求
  17. Flutte的ListView不能直接嵌套ListView解决办法
  18. android随机摇号代码,抽奖摇号系统随机性算法介绍
  19. 北航大学计算机学院新媒体艺术系,本科优秀毕业论文参考-北航新媒体与艺术学院-北京航空航天大学.doc...
  20. 视觉伺服入门第二步:带你从经典论文阅读Visual Servo Control Part II: Advanced Approaches进阶版

热门文章

  1. python 矩阵连乘
  2. EDA技术及应用实验2 or2a程序
  3. python操作wps表格_python3怎么用pandas读wps表格,pandas python教程
  4. 使用电脑群控制手机时,电脑硬件配置如何配?
  5. 软件项目开发与管理(单代号网络图参考例题)
  6. MySQL数据库实验环境
  7. [渝粤教育] 西南科技大学 机械设计基础 在线考试复习资料
  8. 在没有原始数据的情况下, 我把列线图转换成了网页计算器
  9. 教你用R画列线图,形象展示预测模型的结果
  10. C1083,无法打开包括文件...