Skip to content

Commit

Permalink
Merge branch 'release/1.0.0-alpha.39'
Browse files Browse the repository at this point in the history
  • Loading branch information
nekofar committed Sep 28, 2023
2 parents ede926d + a7af5be commit 790d570
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 17 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## [1.0.0-alpha.39] - 2023-09-28

### Refactor

- Update abstain vote terminology in farcaster
- Update FarcasterHandler to accept dynamic channel key

## [1.0.0-alpha.38] - 2023-09-28

### Refactor
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lilnouns-bots"
version = "1.0.0-alpha.38"
version = "1.0.0-alpha.39"
authors = ["Milad Nekofar <milad@nekofar.com>"]
edition = "2021"
description = "Our bots are designed to keep the Lil Nouns DAO community informed and engaged."
Expand Down
25 changes: 20 additions & 5 deletions src/meta_gov/handler/farcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,23 @@ use crate::{
pub struct FarcasterHandler {
base_url: String,
bearer_token: String,
channel_key: String,
cache: Cache,
client: Client,
}

impl FarcasterHandler {
pub fn new(base_url: String, bearer_token: String, cache: Cache, client: Client) -> Self {
pub fn new(
base_url: String,
bearer_token: String,
channel_key: String,
cache: Cache,
client: Client,
) -> Self {
Self {
base_url,
bearer_token,
channel_key,
cache,
client,
}
Expand All @@ -37,11 +45,18 @@ impl FarcasterHandler {
pub fn new_from_env(env: &Env) -> Result<FarcasterHandler> {
let base_url = env.var("META_GOV_BASE_URL")?.to_string();
let bearer_token = env.secret("META_GOV_WARP_CAST_TOKEN")?.to_string();
let channel_key = env.secret("META_GOV_WARP_CAST_CHANNEL")?.to_string();

let cache = Cache::new_from_env(env);
let client = Client::new();

Ok(Self::new(base_url, bearer_token, cache, client))
Ok(Self::new(
base_url,
bearer_token,
channel_key,
cache,
client,
))
}

async fn make_http_request(&self, request_data: Value) -> Result<()> {
Expand Down Expand Up @@ -111,7 +126,7 @@ impl Handler for FarcasterHandler {
let request_data = json!({
"text": description,
"embeds": [url],
"channelKey": "lil-nouns"
"channelKey": self.channel_key
});

self.make_http_request(request_data).await?;
Expand Down Expand Up @@ -151,7 +166,7 @@ impl Handler for FarcasterHandler {
match vote.choice {
1 => "for",
2 => "against",
3 => "abstain on",
3 => "abstain",
_ => "unknown",
},
wallet,
Expand All @@ -160,7 +175,7 @@ impl Handler for FarcasterHandler {
let request_data = json!({
"text": description,
"embeds": [url],
"channelKey": "lil-nouns"
"channelKey": self.channel_key
});

self.make_http_request(request_data).await?;
Expand Down
25 changes: 20 additions & 5 deletions src/prop_house/handler/farcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,23 @@ use crate::{
pub struct FarcasterHandler {
base_url: String,
bearer_token: String,
channel_key: String,
cache: Cache,
client: Client,
}

impl FarcasterHandler {
pub fn new(base_url: String, bearer_token: String, cache: Cache, client: Client) -> Self {
pub fn new(
base_url: String,
bearer_token: String,
channel_key: String,
cache: Cache,
client: Client,
) -> Self {
Self {
base_url,
bearer_token,
channel_key,
cache,
client,
}
Expand All @@ -36,11 +44,18 @@ impl FarcasterHandler {
pub fn new_from_env(env: &Env) -> Result<FarcasterHandler> {
let base_url = env.var("PROP_HOUSE_BASE_URL")?.to_string();
let bearer_token = env.secret("PROP_HOUSE_WARP_CAST_TOKEN")?.to_string();
let channel_key = env.var("PROP_HOUSE_WARP_CAST_CHANNEL")?.to_string();

let cache = Cache::new_from_env(env);
let client = Client::new();

Ok(Self::new(base_url, bearer_token, cache, client))
Ok(Self::new(
base_url,
bearer_token,
channel_key,
cache,
client,
))
}

async fn make_http_request(&self, request_data: Value) -> Result<()> {
Expand Down Expand Up @@ -92,7 +107,7 @@ impl Handler for FarcasterHandler {
let request_data = json!({
"text": description,
"embeds": [url],
"channelKey": "lil-nouns"
"channelKey": self.channel_key
});

self.make_http_request(request_data).await?;
Expand Down Expand Up @@ -132,7 +147,7 @@ impl Handler for FarcasterHandler {
let request_data = json!({
"text": description,
"embeds": [url],
"channelKey": "lil-nouns"
"channelKey": self.channel_key
});

self.make_http_request(request_data).await?;
Expand Down Expand Up @@ -177,7 +192,7 @@ impl Handler for FarcasterHandler {
let request_data = json!({
"text": description,
"embeds": [url],
"channelKey": "lil-nouns"
"channelKey": self.channel_key
});

self.make_http_request(request_data).await?;
Expand Down
25 changes: 20 additions & 5 deletions src/prop_lot/handler/farcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,23 @@ use crate::{
pub struct FarcasterHandler {
base_url: String,
bearer_token: String,
channel_key: String,
cache: Cache,
client: Client,
}

impl FarcasterHandler {
pub fn new(base_url: String, bearer_token: String, cache: Cache, client: Client) -> Self {
pub fn new(
base_url: String,
bearer_token: String,
channel_key: String,
cache: Cache,
client: Client,
) -> Self {
Self {
base_url,
bearer_token,
channel_key,
cache,
client,
}
Expand All @@ -36,11 +44,18 @@ impl FarcasterHandler {
pub fn new_from_env(env: &Env) -> Result<FarcasterHandler> {
let base_url = env.var("PROP_LOT_BASE_URL")?.to_string();
let bearer_token = env.secret("PROP_LOT_WARP_CAST_TOKEN")?.to_string();
let channel_key = env.var("PROP_LOT_WARP_CAST_CHANNEL")?.to_string();

let cache = Cache::new_from_env(env);
let client = Client::new();

Ok(Self::new(base_url, bearer_token, cache, client))
Ok(Self::new(
base_url,
bearer_token,
channel_key,
cache,
client,
))
}

async fn make_http_request(&self, request_data: Value) -> Result<()> {
Expand Down Expand Up @@ -90,7 +105,7 @@ impl Handler for FarcasterHandler {
let request_data = json!({
"text": description,
"embeds": [url],
"channelKey": "lil-nouns"
"channelKey": self.channel_key
});

self.make_http_request(request_data).await?;
Expand Down Expand Up @@ -129,7 +144,7 @@ impl Handler for FarcasterHandler {
let request_data = json!({
"text": description,
"embeds": [url],
"channelKey": "lil-nouns"
"channelKey": self.channel_key
});

self.make_http_request(request_data).await?;
Expand Down Expand Up @@ -168,7 +183,7 @@ impl Handler for FarcasterHandler {
let request_data = json!({
"text": description,
"embeds": [url],
"channelKey": "lil-nouns"
"channelKey": self.channel_key
});

self.make_http_request(request_data).await?;
Expand Down
3 changes: 3 additions & 0 deletions wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ KV_STORE_NAME = "CACHE"
META_GOV_ENABLED = "true"
META_GOV_DISCORD_ENABLED = "true"
META_GOV_FARCASTER_ENABLED = "true"
META_GOV_WARP_CAST_CHANNEL = "lil-nouns"
META_GOV_BASE_URL = "https://lilnouns.wtf/vote/nounsdao"
META_GOV_SNAPSHOT_GRAPHQL_URL = "https://hub.snapshot.org/graphql"
META_GOV_SNAPSHOT_SPACE_ID = "leagueoflils.eth"
PROP_HOUSE_ENABLED = "true"
PROP_HOUSE_DISCORD_ENABLED = "true"
PROP_HOUSE_FARCASTER_ENABLED = "true"
PROP_HOUSE_WARP_CAST_CHANNEL = "lil-nouns"
PROP_HOUSE_BASE_URL = "https://prop.house/lil-nouns"
PROP_HOUSE_COMMUNITY_ID = "2"
PROP_HOUSE_GRAPHQL_URL = "https://prod.backend.prop.house/graphql"
PROP_LOT_ENABLED = "true"
PROP_LOT_DISCORD_ENABLED = "true"
PROP_LOT_FARCASTER_ENABLED = "true"
PROP_LOT_WARP_CAST_CHANNEL = "lil-nouns"
PROP_LOT_BASE_URL = "https://lilnouns.proplot.wtf"
PROP_LOT_GRAPHQL_URL = "https://lilnouns.proplot.wtf/api/graphql"
ETHEREUM_MAINNET_RPC_URL = "https://eth.llamarpc.com"
Expand Down

0 comments on commit 790d570

Please sign in to comment.