Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.

Commit

Permalink
update botway packages
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Sep 17, 2022
1 parent 00eceea commit 6950f08
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 134 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ require (
github.com/tidwall/sjson v1.2.5
golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035
gopkg.in/yaml.v3 v3.0.1
)

require (
Expand Down Expand Up @@ -99,4 +98,5 @@ require (
golang.org/x/text v0.3.7 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
2 changes: 1 addition & 1 deletion packages/botlin/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ fun GetGuildId(serverName: String): String {

return sn.get("server_id").toString()
}
}
}
7 changes: 1 addition & 6 deletions packages/botnet/BotNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ public string GetBotInfo(string value) {
if (File.Exists(".botway.yaml")) {
dynamic BotConfig = deserializer.Deserialize<dynamic>(File.ReadAllText(".botway.yaml"));

if (BotConfig["bot"]["lang"] != "csharp") {
Exception e = new Exception("ERROR: Your Bot language is not C#");
throw e;
} else {
return BotConfig["bot"][value].ToString();
}
return BotConfig["bot"][value].ToString();
} else {
Exception e = new Exception("ERROR: Bot config file not found");
throw e;
Expand Down
4 changes: 2 additions & 2 deletions packages/botnet/botnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>BotNet</PackageId>
<Version>0.1.1</Version>
<Version>0.1.2</Version>
<Authors>botway</Authors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="YamlDotNet" Version="12.0.0" />
</ItemGroup>
</Project>
</Project>
22 changes: 8 additions & 14 deletions packages/botway-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,14 @@ fn get_bot_info(value: &str) -> String {
// let app_id = botway::get("app_id");
// ```
pub fn get(value_to_get: &str) -> String {
if get_bot_info("lang") != "rust" {
"ERROR: Your Bot language is not Rust".to_string()
} else {
let json = Json::from_str(&return_path()).unwrap();
let json = Json::from_str(&return_path()).unwrap();

if value_to_get == "token" {
unescape(&json.find_path(&["botway", "bots", &get_bot_info("name"), "bot_token"]).unwrap().to_string()).unwrap()
} else if value_to_get == "app_id" {
unescape(&json.find_path(&["botway", "bots", &get_bot_info("name"), "bot_app_id"]).unwrap().to_string()).unwrap()
} else {
"ERROR: Invalid value to get".to_string()
}
if value_to_get == "token" {
unescape(&json.find_path(&["botway", "bots", &get_bot_info("name"), "bot_token"]).unwrap().to_string()).unwrap()
} else if value_to_get == "app_id" {
unescape(&json.find_path(&["botway", "bots", &get_bot_info("name"), "bot_app_id"]).unwrap().to_string()).unwrap()
} else {
"ERROR: Invalid value to get".to_string()
}
}

Expand All @@ -73,9 +69,7 @@ pub fn get(value_to_get: &str) -> String {
// let my_server_id = botway::get_guild_id("SERVER_NAME");
// ```
pub fn get_guild_id(server_name: &str) -> String {
if get_bot_info("lang") != "rust" {
"ERROR: Your Bot language is not Rust".to_string()
} else if get_bot_info("type") != "discord" {
if get_bot_info("type") != "discord" {
"ERROR: This function/feature is only working with discord bots.".to_string()
} else {
let json = Json::from_str(&return_path()).unwrap();
Expand Down
72 changes: 27 additions & 45 deletions packages/botway.js/core/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,67 +25,49 @@ const contents = readFileSync(BOTWAY_CONFIG_PATH, "utf8");
const json = JSON.parse(contents);

export const GetToken = () => {
if (getBotInfo("lang") != "nodejs") {
console.log("ERROR: Your Bot framework is not NodeJS");
} else {
try {
return json["botway"]["bots"][getBotInfo("name")]["bot_token"];
} catch (err: any) {
console.log(err.stack || String(err));
}
try {
return json["botway"]["bots"][getBotInfo("name")]["bot_token"];
} catch (err: any) {
console.log(err.stack || String(err));
}
};

export const GetAppId = () => {
if (getBotInfo("lang") != "nodejs") {
console.log("ERROR: Your Bot framework is not NodeJS");
} else {
try {
if (getBotInfo("type") == "slack") {
return json["botway"]["bots"][getBotInfo("name")]["bot_app_token"];
} else {
return json["botway"]["bots"][getBotInfo("name")]["bot_app_id"];
}
} catch (err: any) {
console.log(err.stack || String(err));
try {
if (getBotInfo("type") == "slack") {
return json["botway"]["bots"][getBotInfo("name")]["bot_app_token"];
} else {
return json["botway"]["bots"][getBotInfo("name")]["bot_app_id"];
}
} catch (err: any) {
console.log(err.stack || String(err));
}
};

export const GetGuildId = (serverName: string) => {
if (getBotInfo("lang") != "nodejs") {
console.log("ERROR: Your Bot framework is not NodeJS");
if (getBotInfo("type") != "discord") {
console.log(
"ERROR: This function/feature is only working with discord bots"
);
} else {
if (getBotInfo("type") != "discord") {
console.log(
"ERROR: This function/feature is only working with discord bots"
);
} else {
try {
return json["botway"]["bots"][getBotInfo("name")]["guilds"][serverName][
"server_id"
];
} catch (err: any) {
console.log(err.stack || String(err));
}
try {
return json["botway"]["bots"][getBotInfo("name")]["guilds"][serverName][
"server_id"
];
} catch (err: any) {
console.log(err.stack || String(err));
}
}
};

export const GetSigningSecret = () => {
if (getBotInfo("lang") != "nodejs") {
console.log("ERROR: Your Bot framework is not NodeJS");
if (getBotInfo("type") != "slack") {
console.log("ERROR: This function/feature is only working with slack bots");
} else {
if (getBotInfo("type") != "slack") {
console.log(
"ERROR: This function/feature is only working with slack bots"
);
} else {
try {
return json["botway"]["bots"][getBotInfo("name")]["signing_secret"];
} catch (err: any) {
console.log(err.stack || String(err));
}
try {
return json["botway"]["bots"][getBotInfo("name")]["signing_secret"];
} catch (err: any) {
console.log(err.stack || String(err));
}
}
};
3 changes: 0 additions & 3 deletions packages/botway.py/botway/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ def getBotInfo(value):
for val in find(botConfigData, 'bot'):
return val[value]

if getBotInfo('lang') != 'python':
raise RuntimeError('ERROR: Your Bot language is not Python')

def GetToken():
for val in find(botwayConfigData, 'botway'):
return val['bots'][getBotInfo('name')]['bot_token']
Expand Down
2 changes: 1 addition & 1 deletion packages/botwaycr
2 changes: 1 addition & 1 deletion packages/botwaygo
26 changes: 7 additions & 19 deletions packages/botwayrb/lib/botwayrb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,32 @@ class Error < StandardError; end
class Core
def get_bot_info(value)
data = YAML.load_file(".botway.yaml")

data["bot"][value]
end

def get_token()
if get_bot_info("lang") != "ruby"
raise Error, "ERROR: Your Bot language is not Ruby"
else
BotwatConfig["botway"]["bots"][get_bot_info("name")]["bot_token"]
end
BotwatConfig["botway"]["bots"][get_bot_info("name")]["bot_token"]
end

def get_app_id()
if get_bot_info("lang") != "ruby"
raise Error, "ERROR: Your Bot language is not Ruby"
if get_bot_info("type") == "slack"
BotwatConfig["botway"]["bots"][get_bot_info("name")]["bot_app_token"]
else
if get_bot_info("type") == "slack"
BotwatConfig["botway"]["bots"][get_bot_info("name")]["bot_app_token"]
else
BotwatConfig["botway"]["bots"][get_bot_info("name")]["bot_app_id"]
end
BotwatConfig["botway"]["bots"][get_bot_info("name")]["bot_app_id"]
end
end

def get_guild_id(serverName)
if get_bot_info("lang") != "ruby"
raise Error, "ERROR: Your Bot language is not Ruby"
elsif get_bot_info("type") != "discord"
if get_bot_info("type") != "discord"
raise Error, "ERROR: This function/feature is only working with discord bots"
else
BotwatConfig["botway"]["bots"][get_bot_info("name")]["guilds"][serverName]["server_id"]
end
end

def get_signing_secret()
if get_bot_info("lang") != "ruby"
raise Error, "ERROR: Your Bot language is not Ruby"
elsif get_bot_info("type") != "slack"
if get_bot_info("type") != "slack"
raise Error, "ERROR: This function/feature is only working with slack bots"
else
BotwatConfig["botway"]["bots"][get_bot_info("name")]["signing_secret"]
Expand Down
2 changes: 1 addition & 1 deletion packages/botwayrb/lib/botwayrb/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Botwayrb
VERSION = "0.3.1"
VERSION = "0.3.2"
end
42 changes: 15 additions & 27 deletions packages/denobot/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,29 @@ const getBotInfo = (value: string) => {
};

export const getToken = () => {
if (getBotInfo("lang") != "deno") {
console.log("ERROR: Your Bot framework is not Deno");
} else {
try {
return botwayConfig["botway"]["bots"][getBotInfo("name")]["bot_token"];
} catch (err: any) {
console.log(err.stack || String(err));
}
try {
return botwayConfig["botway"]["bots"][getBotInfo("name")]["bot_token"];
} catch (err: any) {
console.log(err.stack || String(err));
}
};

export const getAppId = () => {
if (getBotInfo("lang") != "deno") {
console.log("ERROR: Your Bot framework is not Deno");
} else {
try {
if (getBotInfo("type") == "slack") {
return botwayConfig["botway"]["bots"][getBotInfo("name")][
"bot_app_token"
];
} else {
return botwayConfig["botway"]["bots"][getBotInfo("name")]["bot_app_id"];
}
} catch (err: any) {
console.log(err.stack || String(err));
try {
if (getBotInfo("type") == "slack") {
return botwayConfig["botway"]["bots"][getBotInfo("name")][
"bot_app_token"
];
} else {
return botwayConfig["botway"]["bots"][getBotInfo("name")]["bot_app_id"];
}
} catch (err: any) {
console.log(err.stack || String(err));
}
};

export const getGuildId = (serverName: string) => {
if (getBotInfo("lang") != "deno") {
console.log("ERROR: Your Bot framework is not Deno");
} else if (getBotInfo("type") != "discord") {
if (getBotInfo("type") != "discord") {
console.log(
"ERROR: This function/feature is only working with discord bots"
);
Expand All @@ -64,9 +54,7 @@ export const getGuildId = (serverName: string) => {
};

export const getSigningSecret = () => {
if (getBotInfo("lang") != "deno") {
console.log("ERROR: Your Bot framework is not Deno");
} else if (getBotInfo("type") != "slack") {
if (getBotInfo("type") != "slack") {
console.log("ERROR: This function/feature is only working with slack bots");
} else {
try {
Expand Down
13 changes: 0 additions & 13 deletions tools/yaml.go

This file was deleted.

0 comments on commit 6950f08

Please sign in to comment.