Skip to content

An unofficial kik bot api written in Go based on YassienW/kik-node-api

License

Notifications You must be signed in to change notification settings

nanofuxion/kik_go_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kik_go_api

kik_go_api is a Go package for interacting with the Kik messaging API. It allows you to build bots and clients that can send/receive messages on Kik.

The package was inspired by the kik-node-api Node.js library.

Usage

To use kik_go_api, first create a Client instance:

client := kik_go_api.Client

Then configure the client with your username, password, and optionally the Kik version:

client.Settings("username", "password") 
// Kik version defaults to 15.25.0.22493

client.Settings("username", "password", "15.15.0.12345", "pNtboj79GGFYk9w2RbZZTxLpZUY=")  
// Custom Kik version and SHA1 hash

NOTE: The Kik version defaults to 15.25.0.22493 if not provided. Only the major and minor version numbers are needed.

Next, connect the client:

messages := make(chan string)
go client.Connect(messages)

This will start receiving messages on the messages channel.

To send messages, use the SendMsg method:

client.SendMsg("Hello world!", "[email protected]") // Send to a user
client.SendMsg("Hello group!", "[email protected]") // Send to a group

There is also a SendRaw method for sending raw XML stanzas:

client.SendRaw(`
    <message to="[email protected]">
      <body>Hello!</body> 
    </message>
`)

Receiving Messages

To parse incoming messages, you can pass the msg string from the messages channel to your own parsing function.

For example, here is a basic parser from bot.go.example:

for msg := range messages {

  if strings.Contains(msg, "type=\"chat\"") {
      // Extract JID 
      jid := extractJid(msg)  

      // Build message stanza
      stanza := buildMessageStanza("Hello!", jid) 

      // Send message
      client.SendRaw(stanza)
  }

}

func extractJid(msg string) string {
  // Use regexp to extract JID 
  return jid 
}

func buildMessageStanza(body string, to string) string {
  // Build XML stanza
  return stanza
}

This extracts the incoming message JID and sends a response.

You can replicate the parsing logic from other Kik API wrappers like kik-bot-api-unofficial (Python) or kik-node-api (Node.js).

Contributing

Contributions are welcome! kik_go_api is missing some features like group chat and read receipts. See the issue tracker for details.

License

MIT License - see LICENSE for details.

About

An unofficial kik bot api written in Go based on YassienW/kik-node-api

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages