-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update sraketa command, introduce yaml config
- Loading branch information
Showing
8 changed files
with
131 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
# srakabot2 | ||
|
||
Running: | ||
it requires API Key to be set in the config file or env variable. | ||
TODO: Add docs | ||
## Configuring | ||
|
||
Bot congiration goes in yaml file of the next format | ||
|
||
telegram: | ||
api_token: YOUR:TELEGRAM_BOT_APIKEY_HERE | ||
couchdb: | ||
host: http://your.couchdb.host:5984/ | ||
user: username | ||
password: password | ||
database: database_name | ||
|
||
put this as .srakabot.yml to the home directory or use | ||
|
||
``` -config /path/to/yaml ``` command line argument to specify location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
type Config struct { | ||
Telegram struct { | ||
ApiToken string `yaml:"api_token"` | ||
} | ||
CouchDB struct { | ||
Host string | ||
User string | ||
Password string | ||
Database string | ||
} | ||
} | ||
|
||
func getConfig(filename string) (config *Config, err error) { | ||
data, err := os.ReadFile(filename) | ||
if err != nil { | ||
return | ||
} | ||
config = new(Config) | ||
err = yaml.Unmarshal(data, config) | ||
if err != nil { | ||
return | ||
} | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters