来自:一言
var xhr = new XMLHttpRequest(); xhr.open('get', 'https://v1.hitokoto.cn/'); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { var data = JSON.parse(xhr.responseText); var hitokoto = document.getElementById('hitokoto'); hitokoto.innerText = data.hitokoto; } } xhr.send();
最近在学习go语言。
由于技术太菜,无法搞到这些聊天软件的接口,所以只有退一步实现键盘模拟的操作来进行通知。。。[aru_15]
简单说一下,就是起一个web服务,然后接收传来的参数,然后将参数发送到聊天窗口==[aru_16]
大佬勿喷,这是最low的办法了~~建议还是用Server酱=
package main
import (
"fmt"
"github.com/go-vgo/robotgo"
"log"
"net/http"
"time"
)
func sendmsg(msg string){
robotgo.TypeString(msg)
time.Sleep(time.Second)
robotgo.KeyTap("enter") //模拟按键
time.Sleep(time.Second)
robotgo.KeyTap("lctrl","enter")
}
func getmsg(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*") //允许访问所有域
w.Header().Add("Access-Control-Allow-Headers", "Content-Type") //header的类
r.ParseForm()
var name string // 初始化定义变量
var ip string // 初始化定义变量
if r.Method == "GET" {
name = r.FormValue("name")
ip = r.FormValue("ip")
//io.WriteString(w, "收到请求了!")
if ip == ""{
fmt.Fprintf(w, "请输入ip!")
}else{
if name != ""{
fmt.Println("收到请求")
fmt.Println("ip:"+ip+"\n主机名:"+name)
sendmsg("有主机已上线!\n"+ " ip:"+ip +" 主机名:"+name)
fmt.Fprintf(w, "<h1>发送成功</h1>")
}else {
fmt.Fprintf(w, "请输入主机名!")
}
}
}else {
fmt.Fprintf(w, "Test")
}
}
func main() {
fmt.Println("接口服务启动成功!等待接收信息。")
fmt.Println("Example:http://127.0.0.1:7777/?name=测试&ip=10.10.10.10")
http.HandleFunc("/", getmsg)
err := http.ListenAndServe(":7777", nil) //设置监听的端口
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
# 循环获取所有beacon
on beacon_initial {
sub http_get {
local('$output');
$url = [new java.net.URL: $1];
$stream = [$url openStream];
$handle = [SleepUtils getIOHandle: $stream, $null];
@content = readAll($handle);
foreach $line (@content) {
$output .= $line . "\r\n";
}
println($output);
}
#获取ip、计算机名、登录账号
$internalIP = replace(beacon_info($1, "external"), " ", "_");
$computerName = replace(beacon_info($1, "computer"), " ", "_");
#get一下Server酱的链接
$url = 'http://127.0.0.1:9878/?ip='.$internalIP.'&name='.$computerName;
http_get($url);
}
将go直接编译成exe运行,然后cs加载插件。