Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; This is a very simple example on how to use the API
- on *:text:!ingame*:#: {
- ;; Check if something is entered
- if ($2 == $null) { msg $chan No ingame entered! }
- else {
- ;; Save channel & requested info
- set %stats.chan $chan
- set %stats.info $2
- ;; Open the socket to the API page
- sockopen -e stats d-bot.net 443
- }
- }
- on *:sockopen:stats: {
- ;; Enter API key, the desired version, sort of requested information and as last the information itself
- sockwrite -nt $sockname GET /api/api.php?key=16fdddrz9etcw&version=com&sort=ingame&info= $+ %stats.info HTTP/1.0
- sockwrite -nt $sockname Host: d-bot.net
- sockwrite -nt $sockname $crlf
- }
- on *:sockread:stats: {
- ;; Read out all the information and save it into the variable %r.
- sockread %stats.output
- if ($chr(124) isin %stats.output) {
- tokenize 124 %stats.output
- set %r. [ $+ [ $1 ] ] $2-
- }
- if (ERROR isin %stats.output) {
- msg %stats.chan ERROR %r.error
- unset %stats.*
- unset %r.*
- sockclose stats
- }
- ;; All the information has been received and saved, now let's read it!
- if (Copyright [D-BoT] isin %stats.output) {
- ;; Some basic if and then's to make it more readable (Use the copyright somewhere in a msg)
- msg %stats.chan Ingame %r.ingame Rank %r.rank (https://d-bot.net)
- msg %stats.chan Has been online for %r.ontime ( $+ %r.on_per $+ )
- if (%r.gender == female) { set %pronoun her }
- else { set %pronoun his }
- msg %stats.chan And is on position %r.rp based on %pronoun rankprogress
- if (%r.status != death) { msg %stats.chan Which is position %r.rp_alive of all alive players }
- ;; Everything done now, forget all the information and close the socket
- unset %stats.*
- unset %r.*
- sockclose stats
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement