Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
2020/10/26 Important renew
Browse files Browse the repository at this point in the history
Former-commit-id: 29ed56f
  • Loading branch information
Nambers committed Oct 25, 2020
1 parent f098782 commit 9baa100
Show file tree
Hide file tree
Showing 23 changed files with 68 additions and 45 deletions.
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Compiled class file
#*.class
*.class

# Log file
#*.log
*.log

# BlueJ files
*.ctxt
Expand All @@ -12,9 +12,9 @@

# Package Files #
#*.jar
*.war
*.nar
*.ear
#*.war
#*.nar
#*.ear
#*.zip
#*.tar.gz
#*.rar
Expand Down
Binary file modified kotlin_mirai/.gradle/6.2/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified kotlin_mirai/.gradle/6.2/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified kotlin_mirai/.gradle/6.2/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified kotlin_mirai/.gradle/6.2/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified kotlin_mirai/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified kotlin_mirai/.gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file modified kotlin_mirai/.gradle/checksums/checksums.lock
Binary file not shown.
Binary file modified kotlin_mirai/.gradle/checksums/md5-checksums.bin
Binary file not shown.
Binary file modified kotlin_mirai/.gradle/checksums/sha1-checksums.bin
Binary file not shown.
36 changes: 36 additions & 0 deletions kotlin_mirai/.idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions kotlin_mirai/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id 'com.github.johnrengelman.shadow' version '5.2.0'
}
group = '1122'
version = '0.1.2'
version = '0.2.1'

repositories {
mavenLocal()
Expand All @@ -19,12 +19,11 @@ repositories {
google()
}
dependencies {
//implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
//api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9"
implementation "net.mamoe:mirai-core-qqandroid:1.1.3"
implementation "net.mamoe:mirai-console:0.5.2"
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10'
//implementation fileTree(dir:'/jars/',includes: ['*.jar'])
}

compileKotlin {
Expand Down
9 changes: 4 additions & 5 deletions kotlin_mirai/src/main/kotlin/com/example/plugin/CPP_lib.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,21 @@ class CPP_lib {
//这里填自己的路径
System.load("D:\\Mirai\\libraries\\mirai-demo.dll")
}

@JvmStatic
fun SendGroup(message:String,id:Long){
GlobalScope.launch(Dispatchers.Default) {
SendG(message, id)
}
}
@JvmStatic
fun SendLog(log:String) {
BasicSendLog(log)
}
@JvmStatic
fun SendPrivate(message: String, id: Long){
fun SendPrivateMSG(message: String, id: Long){
// 反向调用发送消息
GlobalScope.launch(Dispatchers.Default) {
//GlobalScope.launch(Dispatchers.Default) {
Send(message, id)
}
//}
}
@JvmStatic
fun GetNick(qqid:Long): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,28 @@ import net.mamoe.mirai.console.plugins.PluginBase
import net.mamoe.mirai.event.events.*
import net.mamoe.mirai.event.subscribeAlways
import net.mamoe.mirai.message.*
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.Dispatchers

object ExamplePluginMain : PluginBase() {
lateinit var AIbot:Bot
suspend fun Send(message:String, id:Long){
fun Send(message:String, id:Long){
//反向调用
logger.info("Send message for $id is $message")
logger.info(AIbot.selfQQ.toString())
val a=AIbot.getFriend(id)
logger.info("successful get friend")
a.sendMessage(message)
logger.info("Send success")
GlobalScope.launch(Dispatchers.Unconfined) {
a.sendMessage(message)
}
}
fun BasicSendLog(log:String){
logger.info(log);
}
suspend fun SendG(message:String,id:Long){
AIbot.getGroup(id).sendMessage(message)
fun SendG(message:String,id:Long){
GlobalScope.launch(Dispatchers.Unconfined) {
logger.info("Send message for Group($id) is $message")
AIbot.getGroup(id).sendMessage(message)
}
}
fun GetN(qqid:Long):String {
return AIbot.getFriend(qqid).nick;
Expand All @@ -36,9 +41,10 @@ object ExamplePluginMain : PluginBase() {
super.onEnable()
//插件已加载
logger.info("Plugin loaded!")
logger.info("github存储库:https://github.com/Nambers/MiraiCP")
logger.info(cpp.ver)//输出2333 正常
subscribeAlways<BotOnlineEvent> {
AIbot=bot
AIbot=this.bot
}
subscribeAlways<GroupMessageEvent> {
//群信息
Expand Down
Binary file not shown.
Binary file modified mirai-demo/.vs/mirai-demo/v16/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion mirai-demo/.vs/mirai-demo/v16/Browse.VC.db.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
472c0dc532824e8af83aaf97a7c3e2e1a30d9cfd
febb54267148493ada38c9d9145a4dcb5ac98a6a
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a0f347053840a589e0f96237f007492f74781e1a
ba7916e42f421996e7740a815ea56cc61289dcd2
17 changes: 1 addition & 16 deletions mirai-demo/mirai-demo.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,6 @@
</ClCompile>
<ClCompile Include="tools.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="packages\jsoncpp.redist.0.6.0.1\build\native\jsoncpp.redist.targets" Condition="Exists('packages\jsoncpp.redist.0.6.0.1\build\native\jsoncpp.redist.targets')" />
<Import Project="packages\jsoncpp.0.6.0.1\build\native\jsoncpp.targets" Condition="Exists('packages\jsoncpp.0.6.0.1\build\native\jsoncpp.targets')" />
<Import Project="packages\CppRequests.0.0.5\build\native\CppRequests.targets" Condition="Exists('packages\CppRequests.0.0.5\build\native\CppRequests.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\jsoncpp.redist.0.6.0.1\build\native\jsoncpp.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\jsoncpp.redist.0.6.0.1\build\native\jsoncpp.redist.targets'))" />
<Error Condition="!Exists('packages\jsoncpp.0.6.0.1\build\native\jsoncpp.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\jsoncpp.0.6.0.1\build\native\jsoncpp.targets'))" />
<Error Condition="!Exists('packages\CppRequests.0.0.5\build\native\CppRequests.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\CppRequests.0.0.5\build\native\CppRequests.targets'))" />
</Target>
<ImportGroup Label="ExtensionTargets" />
</Project>
3 changes: 0 additions & 3 deletions mirai-demo/mirai-demo.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,4 @@
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions mirai-demo/pch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ JNIEXPORT jboolean JNICALL Java_com_example_plugin_CPP_1lib_FriendRequest
* 返回值:jstring (用str2jstring把string类型转成jsrting) 发送返回的字符串
*/
JNIEXPORT jstring JNICALL Java_com_example_plugin_CPP_1lib_Verify(JNIEnv* env, jobject job) {
//Friend(env, job, (jlong)1930893235).SendMsg("H");
return tools.str2jstring(env, "2333");//验证机制
}
/*
Expand Down
2 changes: 1 addition & 1 deletion mirai-demo/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Friend::Friend (JNIEnv* env, jobject job,jlong id){
*这个方法声明的是(s: String, i: Int)
*/
this->java_first = env->FindClass("com/example/plugin/CPP_lib");
this->Send_Msg_id = env->GetStaticMethodID(java_first, "SendPrivate", "(Ljava/lang/String;J)V");
this->Send_Msg_id = env->GetStaticMethodID(java_first, "SendPrivateMSG", "(Ljava/lang/String;J)V");
this->Nick_Name_id = env->GetStaticMethodID(java_first, "GetNick", "(J)Ljava/lang/String");
this->jid = id;
this->id = (long)id;
Expand Down
4 changes: 2 additions & 2 deletions mirai-demo/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class Friend {
string GetNick();
string nick;
void SendMsg(jstring msg) {
this->env->CallStaticVoidMethod(this->java_first, this->Send_Msg_id, msg, jid);
this->env->CallStaticVoidMethod(this->java_first, this->Send_Msg_id, msg, this->jid);
}
void SendMsg(string msg) {
this->env->CallStaticVoidMethod(this->java_first, this->Send_Msg_id, tools.str2jstring(this->env, msg.c_str()), jid);
this->env->CallStaticVoidMethod(this->java_first, this->Send_Msg_id, tools.str2jstring(this->env, msg.c_str()), this->jid);
}
};
class Group {
Expand Down

0 comments on commit 9baa100

Please sign in to comment.