MiraiForum

    • 注册
    • 登录
    • 搜索
    • 热门
    • 最新
    • 未解决
    • 标签
    • 群组
    • 友情链接

    NASAForMirai - 接入NASA公开API

    插件发布
    6
    18
    3026
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • Nambers
      Nambers 摸鱼 最后由 Nambers 编辑

      github地址
      release
      目前只做了4个api,还在继续加
      [WIP]

      api来源: NASA公开API

      配置项

      例子:(json不允许注释, 用的时候把//开头的注释都删掉, path: config/<plugn id>/config.json 不存在会自动生成)

      {
        "apikey": "<apikey>",
        "commandName": {
          "EPIC": "#EPIC" // 改EPIC API 的触发字符串到 #EPIC
        },
        "commandStatus": {
          "EPIC": false // 弃用EPIC API 默认全部启用
        }
      }
      

      配置格式是json

      • apikey: 在Nasa申请的apikey, string类型, 在这里申请, 只需要(虚假的)名字和邮箱
      • commandStatus: 可选, map<String, boolean>类型, key(第一项) 为API名字的一个(在下面:APOD/EARTH/EPIC/Mars...) 代表这个api是否启用, 比如 {"EPIC":false}, #EPIC 2020-1-1 就不会有任何作用(假设EPIC触发的词还是默认的#EPIC)
      • commandTets: 可选, map<String, String>类型, key 为api名字的一个, value(第二项)代表触发的字符串, 默认为 #加各个API名字, 所以默认就是 #EPIC 2020-1-1 就可以触发, 如果在这里设置{"EPIC": "abc"}, abc 2020-1-1就会触发

      目前已经实现的api

      APOD

      当天或者指定时间的天文照片

      返回转发信息, 里面有照片等其他信息

      参数:

      • date: 拍摄日期, 以 yyyy-MM-dd格式

      EARTH

      地球一部分表面照片(和地图的卫星图片差不多), 调用的是google的api所以可能无法使用(建议直接禁用)

      返回单张照片

      参数:

      • lon: 经度
      • lat: 纬度
      • date: 拍摄日期, yyyy-MM-dd

      EPIC

      地球全部的照片

      返回转发信息里面包含图片和其他信息

      目前只支持 natural/date

      参数:

      • date: 拍摄时间, yyyy-MM-dd

      Mars

      火星车拍的照片, 有些早的可能发不出

      返回转发信息里面包含图片和其他信息

      参数:

      • earth_date: 拍摄时间, yyyy-MM-dd
      • <camera>: 可选, 相机名字 FHAZ, RHAZ, MAST, CHEMCAM, MAHLI, MARDI, NAVCAM, PANCAM, MINITES, 对应含义

      license

      Copyright (C) 2021-2021 Eritque arcus and contributors.
      
      This program is free software: you can redistribute it and/or modify
      it under the terms of the GNU Affero General Public License as
      published by the Free Software Foundation, either version 3 of the
      License, or any later version(in your opinion).
      
      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU Affero General Public License for more details.
      
      You should have received a copy of the GNU Affero General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
      

      欢迎pr来加更多的api((
      以后估计还会接入command系统

      1 条回复 最后回复 回复 引用 0
      • 天涯一笑
        天涯一笑 最后由 编辑

        太强了,已经在用了,孩子很喜欢

        1 条回复 最后回复 回复 引用 0
        • Stardust-minus
          Stardust-minus 最后由 编辑

          2022-02-18 23:07:13 V/Bot.2055170746: [《好 兄 弟》(9761****)] FairyLand·苍穹(222***4821) -> #EPIC 2020-1-2
          2022-02-18 23:07:14 E/NasaPlugin: Index 0 out of bounds for length 0
          2022-02-18 23:07:14 E/NasaPlugin: Nasa返回[]
          EPIC无法使用。config是默认生成的,只修改了API,其他功能可用。

          Nambers 1 条回复 最后回复 回复 引用 0
          • Hoshino Tented
            Hoshino Tented ⭐2021⭐ 最后由 编辑

            牛逼
            错误
            请增添发帖内容,不能少于 5 个字符。

            1 条回复 最后回复 回复 引用 0
            • Nambers
              Nambers 摸鱼 @Stardust-minus 最后由 编辑

              @stardust-minus 可能有些日期nasa没有epic照片
              1cee9ee5-995d-464c-b1bc-faca1c7e4310-image.png
              这种nasa有的时候qs有这种情况,我还没做错误处理以后可能加个

              1 条回复 最后回复 回复 引用 0
              • M
                MCAstro414 最后由 编辑

                请问出现以下问题如何解决?

                2022-03-28 17:41:48 E/NasaPlugin: Exception in coroutine Plugin tech.eritquearcus.nasaPlugin of NasaPlugin
                java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
                at java.base/java.util.Collections$SingletonList.get(Collections.java:4849)
                at tech.eritquearcus.nasaPlugin.commands.APOD.build(APOD.kt:29)
                at tech.eritquearcus.nasaPlugin.NasaPluginKt.handle(NasaPlugin.kt:35)
                at tech.eritquearcus.nasaPlugin.NasaPluginKt.access$handle(NasaPlugin.kt:1)
                at tech.eritquearcus.nasaPlugin.NasaPlugin$onEnable$1.invokeSuspend(NasaPlugin.kt:66)
                at tech.eritquearcus.nasaPlugin.NasaPlugin$onEnable$1.invoke(NasaPlugin.kt)
                at tech.eritquearcus.nasaPlugin.NasaPlugin$onEnable$1.invoke(NasaPlugin.kt)
                at net.mamoe.mirai.event.EventChannel$subscribeAlways$1.invokeSuspend(EventChannel.kt:455)
                at net.mamoe.mirai.event.EventChannel$subscribeAlways$1.invoke(EventChannel.kt)
                at net.mamoe.mirai.event.EventChannel$subscribeAlways$1.invoke(EventChannel.kt)
                at net.mamoe.mirai.internal.event.Handler$onEvent$2.invokeSuspend(InternalEventListeners.kt:50)
                at net.mamoe.mirai.internal.event.Handler$onEvent$2.invoke(InternalEventListeners.kt)
                at net.mamoe.mirai.internal.event.Handler$onEvent$2.invoke(InternalEventListeners.kt)
                at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
                at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:165)
                at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
                at net.mamoe.mirai.internal.event.Handler.onEvent(InternalEventListeners.kt:50)
                at net.mamoe.mirai.internal.event.InternalEventListenersKt.process(InternalEventListeners.kt:166)
                at net.mamoe.mirai.internal.event.InternalEventListenersKt.callAndRemoveIfRequired(InternalEventListeners.kt:115)
                at net.mamoe.mirai.internal.event.InternalEventListenersKt$callAndRemoveIfRequired$1.invokeSuspend(InternalEventListeners.kt)
                at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                at kotlinx.coroutines.UndispatchedCoroutine.afterResume(CoroutineContext.kt:147)
                at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
                at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
                at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
                at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
                at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
                at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
                at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

                Nambers 1 条回复 最后回复 回复 引用 0
                • Nambers
                  Nambers 摸鱼 @MCAstro414 最后由 编辑

                  @MCAstro414 怎么触发的? 发送哪条

                  M 1 条回复 最后回复 回复 引用 0
                  • M
                    MCAstro414 @Nambers 最后由 编辑

                    @Nambers 在加载期间出现的,没有发送指令

                    Nambers 1 条回复 最后回复 回复 引用 0
                    • Nambers
                      Nambers 摸鱼 @MCAstro414 最后由 编辑

                      @MCAstro414 配置文件看看? 可能是那里的问题

                      M 1 条回复 最后回复 回复 引用 0
                      • M
                        MCAstro414 最后由 MCAstro414 编辑

                        配置文件截图:

                        fc77e9d7-4016-4816-8c3d-80aeb370767e-image.png

                        Nambers 1 条回复 最后回复 回复 引用 0
                        • M
                          MCAstro414 @Nambers 最后由 编辑

                          @Nambers 在聊天界面输入APOD命令也出现以上问题

                          1 条回复 最后回复 回复 引用 0
                          • Nambers
                            Nambers 摸鱼 @MCAstro414 最后由 编辑

                            @MCAstro414 看起来你的commandName里面没加逗号

                            M 1 条回复 最后回复 回复 引用 0
                            • M
                              MCAstro414 @Nambers 最后由 编辑

                              @Nambers 加了逗号,同样在输命令时报错(

                              Nambers 1 条回复 最后回复 回复 引用 0
                              • Nambers
                                Nambers 摸鱼 @MCAstro414 最后由 编辑

                                @MCAstro414 这是因为APOD需要接受一个日期作为参数(见readme), 但是在里面还没写错误处理就直接抛出了,下个版本会加错误处理,目前的解决办法就是根据readme传入正确的参数,如 APOD 2022-01-01

                                M 1 条回复 最后回复 回复 引用 0
                                • M
                                  MCAstro414 @Nambers 最后由 编辑

                                  @Nambers 成功了!感谢(❁´ω`❁)

                                  1 条回复 最后回复 回复 引用 1
                                  • 1
                                    1286840533 最后由 编辑

                                    火星的指令怎么不回复哇

                                    Nambers 1 条回复 最后回复 回复 引用 0
                                    • Nambers
                                      Nambers 摸鱼 @1286840533 最后由 编辑

                                      @1286840533 看看配置文件? 或者有没有日志之类的

                                      1 1 条回复 最后回复 回复 引用 0
                                      • 1
                                        1286840533 @Nambers 最后由 编辑

                                        @Nambers 解决了是原本是Mars我不清楚用了MARS😂

                                        1 条回复 最后回复 回复 引用 0
                                        • 1 / 1
                                        • First post
                                          Last post
                                        Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact