Struct telecord::Config
[−]
[src]
pub struct Config { /* fields omitted */ }
The Config type contains four values, the Discord Bot's Token, the Telegram Bot's token, a HashMap for quickly getting a Telegram Chat ID from a Discord Channel ID, and a HashMap for quickly getting a Discord Channel ID from a Telegram Chat ID.
Methods
impl Config
[src]
fn new() -> Self
[src]
The new function is what actually accesses the environment to read in the required values.
The CHAT_MAPPINGS
environment variable is read as a comma-separated list of
colon-separated tuples, where the first element of each tuple is a Telegram Chat ID and the
second argument of each tuple is a Discord Channel ID.
For example, CHAT_MAPPINGS=1234:abcd,5678:efgh
would map the Telegram Chat 1234 to the
Discord Channel abcd and would also map the Telegram Chat 5678 to the Discord Channel efgh.
The DISCORD_BOT_TOKEN
and TELEGRAM_BOT_TOKEN
environment variables are
self-explanatory.
If any of the required environment variables are not set, this function will panic. Since this is intended to be the first function an application runs, this should not cause issues. Either the config will be correct, or the application will not attempt to deal with missing configuration options.
fn discord(&self) -> &str
[src]
Returns the Discord Bot Token
fn telegram(&self) -> &str
[src]
Returns the Telegram Bot Token
fn telegram_chat_id(&self, discord_channel_id: &ChannelId) -> Option<Integer>
[src]
Retrieves the Telegram Chat ID that corresponds to the given Discord Channel ID.
fn discord_channel_id(&self, telegram_chat_id: &Integer) -> Option<ChannelId>
[src]
Retrieves the Discord Channel ID that corresponds to the given Telegram Chat ID.