Skip to content

Commit

Permalink
removed fmt package in unnecessary places, left only User-Agent for G…
Browse files Browse the repository at this point in the history
…ET requests and added Latin/Cyrillic check wherever possible because unexpected errors occurred
  • Loading branch information
heycatch committed Jun 18, 2024
1 parent 20612b3 commit 4e55810
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 47 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
### О проекте
Небольшая библиотека для взаимодействия с шикимори, написанная на языке golang.
* Работа с API происходит только через `OAuth2`.
И начать нужно с ознакомления документации [первые шаги](https://github.com/heycatch/goshikimori/blob/master/examples/first_steps/README.md).
* Никаких зависимостей от других библиотек.
* Для тестов и сборки используется утилита
GNU [make](https://www.gnu.org/software/make/manual/make.html).
* Для тестов и сборки используется утилита [GNU make](https://www.gnu.org/software/make/manual/make.html).

### Установка
```bash
Expand Down Expand Up @@ -51,7 +51,6 @@ http://localhost:1337/pkg/github.com/heycatch/goshikimori
* [GraphQL](https://shikimori.one/api/doc/graphql)
* [API v1](https://shikimori.one/api/doc/1.0)
* [API v2](https://shikimori.one/api/doc/2.0)
* [OAuth2](https://shikimori.one/oauth)

## Обратная связь
* Написать в личные сообщения на [сайте](https://shikimori.one/arctica).
Expand Down
5 changes: 3 additions & 2 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
### About
A small library for interacting with shikimori, written in golang.
* Work with API occurs only through `OAuth2`.
And you have to start by familiarizing yourself
with the documentation [first steps](https://github.com/heycatch/goshikimori/blob/master/examples/first_steps/README_en.md).
* No dependencies on other libraries.
* The GNU [make](https://www.gnu.org/software/make/manual/make.html)
* The [GNU make](https://www.gnu.org/software/make/manual/make.html)
utility is used for tests and builds.

### Install
Expand Down Expand Up @@ -51,7 +53,6 @@ http://localhost:1337/pkg/github.com/heycatch/goshikimori
* [GraphQL](https://shikimori.one/api/doc/graphql)
* [API v1](https://shikimori.one/api/doc/1.0)
* [API v2](https://shikimori.one/api/doc/2.0)
* [OAuth2](https://shikimori.one/oauth)

### Feedback
* Private message on the [website](https://shikimori.one/arctica).
Expand Down
3 changes: 2 additions & 1 deletion configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ func (c *Configuration) GetConfiguration() (string, string) {
return c.Application, c.AccessToken
}

// You need to enter the application and the private key.
// For GET requests the name of the application is sufficient.
// A access token is required for POST/PUT/DELETE.
//
// To register the application, follow the link from [OAuth].
//
Expand Down
5 changes: 3 additions & 2 deletions cyrillic.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"unicode"
)

// Comparison of Cyrillic and Latin alphabet.
// Search sometimes breaks, needs checking.
// url.QueryEscape() breaks Cyrillic with spaces, and without it,
// Latin with spaces breaks, so there is this intermediate function
// that solves this problem and there are no more errors.
func languageCheck(target string) string {
for i := 0; i < len(target); i++ {
if target[i] > unicode.MaxASCII {
Expand Down
8 changes: 8 additions & 0 deletions cyrillic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ func TestCharacter(t *testing.T) {
}

func TestClub(t *testing.T) {
var s StatusBar
s.settings(5, "#", 1)
s.run()

c := conf()

fastc, _, _ := c.FastIdClub("Ачивки (достижения)")
Expand Down Expand Up @@ -115,6 +119,10 @@ func TestManga(t *testing.T) {
}

func TestAnime(t *testing.T) {
var s StatusBar
s.settings(5, "#", 1)
s.run()

c := conf()

fastc, _, _ := c.FastIdAnime("Тетрадь смерти")
Expand Down
63 changes: 63 additions & 0 deletions examples/first_steps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
## Сссылки
* [OAuth2](https://shikimori.one/oauth)

## Базовая структура

```golang
package main

import ( g "github.com/heycatch/goshikimori" )

/*
ГАЙД ДЛЯ ЧАЙНИКОВ.
ЕСЛИ ТЫ ЗНАЕШЬ С ЧЕМ РАБОТАЕШЬ, ТО НЕ ТРАТЬ СВОЕ ВРЕМЯ И
ПЕРЕХОДИ СРАЗУ К ДОКУМЕНТАЦИИ.
--------------------------
Для получения полей APPLICATION_NAME и PRIVATE_KEY
перейди по ссылки вверху и создай приложение,
либо присоединись к "Test Api" и используй его, дело твое.
--------------------------
Для большинства запросов, например поиск
аниме/манги/пользователей и тому подобного,
поле APPLICATION_NAME будет достаточным, а
PRIVATE_KEY можно оставить пустым.
func config() *g.Configuration {
return g.SetConfiguratuib(
"MY_APPLICATION",
"",
)
}
--------------------------
Если нужно изменить какую-то информацию, а именно
добавить друга, добавить в игнор или написать
сообщение, то тогда обязательно поле PRIVATE_KEY.
ВАЖНО: у твоего приложения, при регистрации, должны
быть права доступа(что оно может делать от твоего имени)
для тех или иных операций.
func config() *g.Configuration {
return g.SetConfiguratuib(
"MY_APPLICATION",
"MY_PRIVATE_KEY",
)
}
*/

func config() *g.Configuration {
return g.SetConfiguration(
"APPLICATION_NAME",
"PRIVATE_KEY",
)
}
```
62 changes: 62 additions & 0 deletions examples/first_steps/README_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
## Links
* [OAuth2](https://shikimori.one/oauth)

## Basic structure

```golang
package main

import ( g "github.com/heycatch/goshikimori" )

/*
DUMMIES GUIDE.
IF YOU KNOW WHAT YOU'RE WORKING WITH, DON'T WASTE YOUR TIME AND GO STRAIGHT TO THE DOCUMENTATION.
--------------------------
To get the APPLICATION_NAME and PRIVATE_KEY fields
go to the link above and create an application,
or join "Test Api" and use it, it's up to you.
--------------------------
For most queries, like searching
anime/manga/users and the like,
the APPLICATION_NAME field will suffice, and the
PRIVATE_KEY can be left blank.
func config() *g.Configuration {
return g.SetConfiguratuib(
"MY_APPLICATION",
"",
)
}
--------------------------
If you need to change some information, such as
add a friend, add to ignore or write
message, then the PRIVATE_KEY field is mandatory..
IMPORTANT: your application, when registering, must have
have access rights (what it can do on your behalf)
for certain operations.
func config() *g.Configuration {
return g.SetConfiguratuib(
"MY_APPLICATION",
"MY_PRIVATE_KEY",
)
}
*/

func config() *g.Configuration {
return g.SetConfiguration(
"APPLICATION_NAME",
"PRIVATE_KEY",
)
}
```
Loading

0 comments on commit 4e55810

Please sign in to comment.