') + ')', 'gi');
if (regex.test(text)) {
found = true;
var frag = document.createDocumentFragment();
var parts = text.split(regex);
parts.forEach(function(part, i) {
if (i % 2 === 0) {
frag.appendChild(document.createTextNode(part));
} else {
var span = document.createElement('span');
span.className = 'userscript-highlight';
span.textContent = part;
frag.appendChild(span);
}
});
node.parentNode.replaceChild(frag, node);
}
});
} else if (node.nodeType === 1 && node.childNodes) { // element
var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];
if (!skipTags.includes(node.tagName)) {
Array.from(node.childNodes).forEach(highlight);
}
}
}
highlight(document.body);
// Re-highlight on dynamic content
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(m) {
m.addedNodes.forEach(function(node) {
if (node.nodeType === 1 || node.nodeType === 3) highlight(node);
});
});
});
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); }
})();
(function(){
try {
var __m = "*";
var __re = new RegExp('^' + ".*" + ', 'i');
if (__m === '*' || __re.test(location.href)) {
// Strip utm_, fbclid, gclid, etc. from all links on page
(function() {
var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',
'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',
'ref', 'ref_src', 'source', 'medium', 'campaign'];
function cleanUrl(url) {
try {
var u = new URL(url, window.location.origin);
var changed = false;
trackingParams.forEach(function(p) {
if (u.searchParams.has(p)) {
u.searchParams.delete(p);
changed = true;
}
});
return changed ? u.toString() : url;
} catch (e) {
return url;
}
}
function cleanLinks() {
document.querySelectorAll('a[href]').forEach(function(a) {
var clean = cleanUrl(a.href);
if (clean !== a.href) a.href = clean;
});
}
cleanLinks();
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(m) {
m.addedNodes.forEach(function(node) {
if (node.nodeType === 1) {
if (node.tagName === 'A') cleanLinks();
node.querySelectorAll('a[href]').forEach(function(a) {
var clean = cleanUrl(a.href);
if (clean !== a.href) a.href = clean;
});
}
});
});
});
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); }
})();
(function(){
try {
var __m = "youtube.com";
var __re = new RegExp('^' + "youtube\\.com" + ', 'i');
if (__m === '*' || __re.test(location.href)) {
// Auto-enable theater mode on YouTube
(function() {
function tryTheater() {
var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]');
if (btn && !btn.classList.contains('activated')) {
btn.click();
}
}
// Try immediately
tryTheater();
// Try after navigation (SPA)
var lastUrl = location.href;
setInterval(function() {
if (location.href !== lastUrl) {
lastUrl = location.href;
setTimeout(tryTheater, 500);
}
}, 1000);
// Also try on player load
var observer = new MutationObserver(tryTheater);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); }
})();
(function(){
try {
var __m = "*";
var __re = new RegExp('^' + ".*" + ', 'i');
if (__m === '*' || __re.test(location.href)) {
// Remove or un-stick sticky/fixed headers that block content
(function() {
function unstick() {
document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) {
if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {
el.style.position = 'static';
el.style.top = 'auto';
el.style.zIndex = 'auto';
}
});
}
unstick();
var observer = new MutationObserver(unstick);
observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });
})();
}
} catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); }
})();
})();
GitHub - Kloping/qqpd-bot-java: QQ官方机器人 Java/JVM/kotlin SDK QQ bot sdk qq机器人sdk · GitHub
Repository files navigation
QQ机器人 Java/JVM/kotlin SDK 非官方 可用于 Java 11+
Java SDK主要基于基础 API (opens new window) 封装,提供给用户一种简单、高效的使用方式。
如果这个项目对你有帮助,欢迎赞助支持持续维护与更新:
支持QQ官方频道与Q群消息收发(私域/公域兼容) 开箱即用的消息类型(文本/图片/Markdown/按钮交互) 灵活的事件监听机制(@EventReceiver注解驱动) 多环境支持(沙箱/正式环境一键切换) 完善的HTTP API封装(频道管理、禁言、消息审核等) 支持Java 8+及Kotlin协程环境 支持websocket与webhook方式链接 Maven
<!-- https://repo1.maven.org/maven2/io/github/kloping/bot-qqpd-java/ -->
<dependency >
<groupId >io.github.kloping</groupId >
<artifactId >bot-qqpd-java</artifactId >
<version >1.5.4-L1</version >
</dependency >Gradle
implementation 'io.github.kloping:bot-qqpd-java:1.5.4-L1'
到https://q.qq.com/ 申请机器人 获得Bot 开发者ID(appid) 和机器人密钥(secret) 2. 发布审核 发布后为公域
启动方式
Starter starter = new Starter ("appid" , "secret" );
starter .getConfig ().setCode (Intents .PRIVATE_INTENTS .getCode ());
// webhook 链接方式 //starter.getConfig().setWebhookport(81); starter .run ();V1.5.0-Beta7+ 注册监听器主机方式 [荐] starter .registerListenerHost (new ListenerHost (){
@ EventReceiver public void onEvent (MessageEvent event ){
event .send ("测试通过" );
}
});事件订阅 默认的事件订阅 不会接收消息事件
需要确定自己的机器人是公域还是私域
来确定 需要 设置订阅 的 事件类型
//单事件订阅方式 starter .getConfig ().setCode (Intents .GUILD_MESSAGES .getCode ());
//多事件订阅方式 starter .getConfig ().setCode (Intents .START .and (Intents .GUILD_MESSAGES ,Intents .DIRECT_MESSAGE ));
// 公域机器人订阅推荐 starter .getConfig ().setCode (Intents .PUBLIC_INTENTS .getCode ());
// 私域机器人订阅推荐 starter .getConfig ().setCode (Intents .PRIVATE_INTENTS .getCode ());import io .github .kloping .qqbot .Starter ;
import io .github .kloping .qqbot .api .Intents ;
import io .github .kloping .qqbot .api .message .MessageChannelReceiveEvent ;
import io .github .kloping .qqbot .api .message .MessageDirectReceiveEvent ;
import io .github .kloping .qqbot .impl .ListenerHost ;更多使用方式参考查看 test
You can’t perform that action at this time.