ICQ Bot Core

ICQ Bot Core API library

Лицензия

Лицензия

Группа

Группа

su.nlq
Идентификатор

Идентификатор

icq-bot-core
Последняя версия

Последняя версия

1.2.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

ICQ Bot Core
ICQ Bot Core API library
Ссылка на сайт

Ссылка на сайт

https://github.com/nolequen/icq-bot-core
Система контроля версий

Система контроля версий

https://github.com/nolequen/icq-bot-core

Скачать icq-bot-core

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/su.nlq/icq-bot-core/ -->
<dependency>
    <groupId>su.nlq</groupId>
    <artifactId>icq-bot-core</artifactId>
    <version>1.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/su.nlq/icq-bot-core/
implementation 'su.nlq:icq-bot-core:1.2.1'
// https://jarcasting.com/artifacts/su.nlq/icq-bot-core/
implementation ("su.nlq:icq-bot-core:1.2.1")
'su.nlq:icq-bot-core:jar:1.2.1'
<dependency org="su.nlq" name="icq-bot-core" rev="1.2.1">
  <artifact name="icq-bot-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='su.nlq', module='icq-bot-core', version='1.2.1')
)
libraryDependencies += "su.nlq" % "icq-bot-core" % "1.2.1"
[su.nlq/icq-bot-core "1.2.1"]

Зависимости

compile (5)

Идентификатор библиотеки Тип Версия
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.3.21
io.ktor : ktor-client-core jar 1.1.1
io.ktor : ktor-client-cio jar 1.1.1
io.ktor : ktor-client-json jar 1.1.1
io.ktor : ktor-client-jackson jar 1.1.1

test (2)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
org.hamcrest : java-hamcrest jar 2.0.0.0

Модули Проекта

Данный проект не имеет модулей.

ICQ Bot Core

Maven Central Build Status Codecov Codebeat

Easy interface to ICQ Bot API powered by Kotlin.

Getting started

  • Create your own bot by sending the /newbot command to MegaBot and follow the instructions
  • Note a bot can only reply after the user has added it contact list, or if the user was the first to start a conversation

Usage

You can find latest release on Maven Central:

  • Maven:
<dependency>
  <groupId>su.nlq</groupId>
  <artifactId>icq-bot-core</artifactId>
  <version>1.2.1</version>
</dependency>
  • Gradle:
compile("su.nlq:icq-bot-core:1.2.1")

How-To

The only thing you should know to create a new bot is token:

val bot = Bot("001.1234567890.1234567890:123456789")

Contacts and messages

To be able to send a message you should create a conversation (no matter is it chat or dialogue):

val penpal = PenPal("42")
val conversation = bot.conversation(penpal)   
// not neccessary but looks nice to set typing status
conversation.typing()
conversation.message("Hi, how are you?")

It is possible to operate the contact list, for example:

bot.contacts().all().onSuccess { buddies ->
  buddies.find { it.name == "Adolf" }?.apply { remove() }
}

Chats

To get any chat information you want is neccessary to create a chat instance:

val chat = bot.chat("123456789@chat.agent")
chat.description().onSuccess {
  println("Chat \"${it.name}\" was created ${it.created} by ${it.creator}")
}

There are various actions you can do with chat members or history, e.g.:

chat.invite(listOf(PenPal("42")))

chat.members().onSuccess { members -> members.forEach { it.block() } }

chat.history(0, 10).onSuccess { history ->
  history.messages.forEach { println("${it.id}: $it") }
  val message = history.messages[0]
  if (message is Chat.Text) {
    message.pin()
  }
}

Files

It is possible to get the file info, upload or download the file:

val files = bot.files()

files.upload(File("myfile.txt")).map { URL(it) }.onSuccess { url ->
  files.download(url)
    .map { it.toInputStream() }
    .onSuccess { stream ->
      println(stream.use { String(it.readAllBytes()) })
    }
}

Версии библиотеки

Версия
1.2.1
1.1.1