duangsuse::Echo
719 subscribers
4.28K photos
130 videos
583 files
6.5K links
import this:
美而不丑、明而不暗、短而不凡、长而不乱,扁平不宽,读而后码,行之天下,勿托地上天国。
异常勿吞,难过勿过,叹一真理。效率是很重要,盲目最是低效。
简明是可靠的先验,不是可靠的祭品。
知其变,守其恒,为天下式;穷其变,知不穷,得地上势。知变守恒却穷变知新,我认真理,我不认真。

技术相干订阅~
另外有 throws 闲杂频道 @dsuset
转载频道 @dsusep
极小可能会有批评zf的消息 如有不适可退出
suse小站(面向运气编程): https://WOJS.org/#/
Download Telegram
Forwarded from 羽毛的小白板
#friend https://github.com/Yuru-ekis 今天认识了一位也在 JVM 的 dalao @Yukisruri 🐱
今天看见了这个 bot 比较有意思,我们使用 PDL 来伪设计一下这个机器人

使用消息驱动编程,这是一个简单的 Telegram 平台 bot,不使用 inline bot(eg. 按钮菜单、@bot 选项) 功能。

我们的抽象:

onHandleCommand
(Command, MessageContext)

用户使用 /sucide 命令,或者会加上 bot 的用户名,就要将他封禁一段时间。

observe onHandleCommand(cmd, context)
case cmd
"sucide" ->
res = sucideUser(context.group, context.sender)
res.map_err { |e| reply(context, e) }
tease(context, res.ok!())
otherwise -> reply(context, "Unexpected command " ++ cmd)

然后有 procedure:

fn randomTimeRange()
return Random.nextInt($_("minTime"), $_("maxTime")))

来拿到一个随机时间,并且我们假设 Telegram 暴露了一个『block 用户 for 一个时间段』的接口
并且假设『消息位置』肯定是一个 group

然后有 sucideUser(user)

fn sucideUser(group, user)
unless group.group? return Err("Not a group")
results Telegram.block(group, user, PERM_DENY_SEND, randomTimeRange())

这时候我们不管别的,假设有这么一层可以抽象出来(而且的确可以,Telegram 总不可能只告诉 bot 自己被发了哪个命令不告诉是谁在哪里发的)。

然后我们可以取笑封禁用户

fn tease(ctx, millisec)
  reply(ctx, "你被封禁了 " ++ Time.pretty(millisec) ++ ",完美!")

🤪
Forwarded from Deleted Account
Congratulations! You are blocked for 85 seconds (random value, min: 30s, max: 5 minutes). Enjoy your offline time!
#blog #dalao #dip https://bokjan.com/ #recommended 看今日 @metowolf 的新 follow,是一个优秀的华南理工在读大牛,他学的是软件工程,写过一些信息学、计算机图形学、图论、操作系统的东西

https://github.com/Bokjan?tab=repositories GitHub
我也打算试用一下,DJson 是今天晚上的事情,我会尝试使用泛型(ObjectJ<out TypeJ>、ArrayJ<out TypeJ>),不过抽提出来的 interface 肯定要能静态地 getClass()...
我编译安装了这个 #lib 正在编写程序业务逻辑
学了个单词 directories... libraries...
写完了...
duangsuse::Echo
https://github.com/duangsuse/SuicideBot-Cpp 代码已经上传至 #GitHub #CPlusplus #project #Telegram
Tg bot :: Error! connect: Connection refused 🌚...

我得找 Boost asio 写个支持 http_proxy 的 client... 欸
支持了 TgBotCpp 使用的 HttpClient 抽象,CURL 客户端是支持 HTTP 代理的
This media is not supported in your browser
VIEW IN TELEGRAM
/suicide @dSuicideBot
???🌚 为啥无效?
因为无效我就不继续折腾了... 我写个 JSON Parser 先吧... (汗)

那么我们来学学使用 #C CMake:

cmake_minimum_required(VERSION cmake_min_version)
project(project_name)

set(name value)
CMAKE_CXX_FLAGS
Boost_USE_MULTITHREADED
CMAKE_THREADS_LIBS_INIT

find_package(packageName [COMPONENTS {packageName}] [REQUIRED])
PKG_FOUND
PKG_INCLUDE_DIRS
PKG_LIBRARIES

include_directories(dirs)
add_definitions(defs)

if (case)
endif()

add_executable(targetName sources)
target_link_libraries(target libraries)

这就可以用来写简单的 CLI 程序了 🐱