Connect with us


Facebook closes Ayatollah Khamenei’s Arabic page



Facebook closes Ayatollah Khamenei's Arabic page thumbnail

TEHRAN – Facebook has closed the Arabic page of Leader of the Islamic Revolution Ayatollah Ali Khamenei, which had more than 100,000 followers.

According to Press TV, the page was closed after being recently put under restrictions for allegedly violating the social media giant’s terms of service.

It comes as many observers have criticized Facebook for what they consider the U.S.-based company’s political bias in dealing with online activity.

Last month, the U.S. State Department called on social media giants to take down the accounts of Ayatollah Khamenei and Foreign Minister Mohammad Javad Zarif amid protests over petrol prices, which prompted the government to shut off the internet.

“One of the things that we are calling on are social media like Facebook and Instagram and Twitter to shut down the accounts of Supreme Leader Khamenei, Foreign Minister Zarif and President Rouhani until they restore the internet to their own people,” U.S. Special Representative for Iran Brian Hook told Bloomberg.

In recent years, social media giants – including Facebook, Twitter and Instagram – have closed thousands of accounts allegedly tied to Iran and Russia under the pretext of fighting what they call “misinformation” campaigns.

In August 2018, Facebook announced it had targeted hundreds of accounts allegedly tied to Iran and Russia.

“We removed multiple pages, groups and accounts for coordinated inauthentic behavior on Facebook and Instagram. Some of this activity originated in Iran, and some originated in Russia,” it said.

The targets were identified as “networks of accounts misleading people about what they were doing,” Facebook’s chief executive Mark Zuckerberg said back then.

Among the accounts was one belonging to the Quest 4 Truth (Q4T) Iranian media organization, which promotes Islamic values.

Facebook further wrote in bold text, “We’ve removed Pages, groups and accounts that can be linked to sources the U.S. government has previously identified as Russian military intelligence services. This is unrelated to the activities we found in Iran.”

The Facebook investigation was prompted by a tip-off from cybersecurity firm FireEye.

FireEye has claimed the Iranian activity included “anti-Saudi, anti-Israeli, and pro-Palestinian themes” and advocacy of policies favorable to Iran such as the 2015 nuclear deal, to which the U.S. was a party before pulling out in May 2018 in defiance of the international community.

“It really shows it’s not just Russia that engages in this type of activity,” said Lee Foster, an information operations analyst with FireEye.

Facebook said it had worked closely with law enforcement in both the U.S. and the UK on the investigation, and had briefed the U.S. Treasury Department and State Department as Washington has imposed sanctions on Tehran.

In a simultaneous move, Twitter Inc (TWTR.N) and Alphabet Inc (GOOGL.O) also acted on FireEye’s claims and removed hundreds of accounts said to be tied to Iranian “actors,” which are said to be promoting Iran’s geopolitical agenda.

Read More


Build a Discord Bot with Rust and Serenity



By Joe Previte

Discord is on the rise in developer communities. And, as we all know, developers love building on top of platforms they use. It’s fun!

Today, I’m going to show you how to build your own Discord bot using Rust and serenity.

Building the App

Before building the app, I’ll cover how it will work and the prerequisites for following along. After that, I’ll jump in and go through each step before setting it up to run locally on your machine. Finally, I’ll show how to test it out in your own Discord server.

How will it work?

Imagine I’m creating a bot for a developer community Discord server. I’m going to build a Discord bot which supports a single command !help, which will return a message explaining:

  • What channel to post in for technical help
  • Where to find the code of conduct
  • How to get in touch with admins of the server

This could be helpful for new people who need help for various scenarios. Think of it being analogous to the –help flag commonly used by CLIs.


In order to start writing this Rust application, there are a few requirements:

  • Rust installed locally
  • IDE setup for Rust development
  • Discord account

Install Rust

I already have Rust installed locally. If you don’t, you can install it locally using:

 shell curl --proto '=https' --tlsv1.2 -sSf | sh 

Afterwards, run rustup –version to verify that it worked. If it did, you should see something printed to your terminal.

IDE for Rust Development

I’m going to be using VS Code and the rust-analyzer extension. You can find support for other IDEs under the Tools on the rust-lang website.

Discord Account

I already have an account, but if you don’t, you can sign up for free.

Set up Code

Since this is a new project, I’m going to create a new project with cargo. For simplicity, I’ll name the project discord-help-bot.

 shell cargo new discord-help-bot 

Add Dependencies

This project requires two external dependencies:

  • tokio – “A runtime for writing reliable, asynchronous and slim applications with the Rust programming language”
  • serenity – “a Rust library for the Discord API”

I’ll add both to the Cargo.toml file:

 toml [dependencies] tokio = { version = "0.2", features = ["macros"] } serenity = { default-features = false, features = ["client", "gateway", "model", "rustls_backend"], version = "0.9.0-rc.1"} 

Note: you’ll notice this is a release candidate (rc). When you go through this, check to make sure you’re using the latest version of serenity.

tokio allows the program to run asynchronously and serenity allows you to interact with the Discord API. With both of these dependencies, I can start adding logic to the program.

Add Logic to

Since this is a small program, I will only need to add code to the file. I’ll add the code and then afterwards I’ll walk through how it works.

 rust use std::env; use serenity::{ async_trait, model::{channel::Message, gateway::Ready}, prelude::*, }; const HELP_MESSAGE: &str = " Hello there, Human! You have summoned me. Let's see about getting you what you need. ? Need technical help? => Post in the <#CHANNEL_ID> channel and other humans will assist you. ? Looking for the Code of Conduct? => Here it is: <> ? Something wrong? => You can flag an admin with @admin I hope that resolves your issue! -- Helpbot "; const HELP_COMMAND: &str = "!help"; struct Handler; #[async_trait] impl EventHandler for Handler { async fn message(&self, ctx: Context, msg: Message) { if msg.content == HELP_COMMAND { if let Err(why) = msg.channel_id.say(&ctx.http, HELP_MESSAGE).await { println!("Error sending message: {:?}", why); } } } async fn ready(&self, _: Context, ready: Ready) { println!("{} is connected!",; } } #[tokio::main] async fn main() { let token = env::var("DISCORD_TOKEN") .expect("Expected a token in the environment"); let mut client = Client::new(&token) .event_handler(Handler) .await .expect("Err creating client"); if let Err(why) = client.start().await { println!("Client error: {:?}", why); } } 

Code Walkthrough

I’m going to walk through the code in four chunks. In the first chunk, I’ll look at the following:

 rust use std::env; use serenity::{ async_trait, model::{channel::Message, gateway::Ready}, prelude::*, }; 

These are the use declarations. They make it easier for developers because they “shorten the path required to refer to a module item.” Here, there are two blocks. The first refers to the env module from the standard library, which we later use to access the DISCORD_TOKEN environment variable.

The next block refers to the modules I use provided by serenity. The first is async_trait which I use on the Handler to tell the compiler the type and methods Handler should support. After that are two structs, Message and Ready. The first is used inside the function signature of message to indicate the type for the third parameter msg. As you can guess, this is for the shape of the message when we receive it from the Discord server. The other struct is Ready and is used in the function signature of the ready function for our Handler. The last line here is the prelude which says, “include the basic things out of the box for the user.”

In the second chunk, I’ll discuss the following piece of code:

 rust const HELP_MESSAGE: &str = " Hello there, Human! You have summoned me. Let's see about getting you what you need. ? Need technical help? => Post in the <#CHANNEL_ID> channel and other humans will assist you. ? Looking for the Code of Conduct? => Here it is: <> ? Something wrong? => You can flag an admin with @admin I hope that resolves your issue! -- Helpbot "; const HELP_COMMAND: &str = "!help"; 

I declare both HELP_MESSAGE and HELP_COMMAND using the const keyword because they stay constant throughout the lifetime of the program and don’t change. With const, you must explicitly annotate the type. We use the &str because these are string slices.

In the third chunk, I’ll look at the following:

 rust struct Handler; #[async_trait] impl EventHandler for Handler { async fn message(&self, ctx: Context, msg: Message) { if msg.content == HELP_COMMAND { if let Err(why) = msg.channel_id.say(&ctx.http, HELP_MESSAGE).await { println!("Error sending message: {:?}", why); } } } async fn ready(&self, _: Context, ready: Ready) { println!("{} is connected!",; } } 

In this part of the program, I declare struct Handler. This doesn’t do much because all it does is declare the struct without any fields. In the next block, we use the #[async_trait] macro to tell the compiler that the struct below implements that trait like allowing us to use the async keyword with our functions and the .await method.

After that, the impl EventHandler for Handler tells the compiler, “My struct called Handler is going to look like an EventHandler.” Inside the struct are two functions: message and ready. The message function is where the main logic of our program happens. It takes in a message, checks the content to see if it matches the HELP_COMMAND and it does, it sends the HELP_MESSAGE to that channel using the same channel id. If there’s an error, it prints it.

The ready function logs a statement letting us know the handler for our Discord bot is ready using the bot’s name.

Last, the final chunk I have to walk through is:

 rust #[tokio::main] async fn main() { let token = env::var("DISCORD_TOKEN") .expect("Expected a token in the environment"); let mut client = Client::new(&token) .event_handler(Handler) .await .expect("Err creating client"); if let Err(why) = client.start().await { println!("Client error: {:?}", why); } } 

The first thing I see is the #[tokio::main] macro which is used because this is an asynchronous application. The next is the main function which is called when the program runs. The first thing it does is get the DISCORD_TOKEN environment variable. Then, it creates a new Serenity Client using the token for us to talk to the Discord API. Last, the program starts the client and handles the error if it has issues starting up.

And that’s all the logic for the program! Onto the next step.

Create a Discord Server

In order to test this out, I’ll need my own Discord Server. To create one, follow these steps:

  • Open the Discord application
  • On the left side, click the plus icon “Add a Server”
  • Click “Create a server”
  • Once you’ve filled everything out, click “Create”

Create Channel and Get Channel ID

Since I’m starting from scratch, I’ll need to create a new channel. I can do this by clicking the plus icon on the left next to “TEXT CHANNELS”. I’ll call mine “help”.

I need to get the channel ID. Discord makes it easy to expose this in the UI if you toggle on Developer Mode. To get here, go to Preferences > Appearance > Developer Mode.

To see the channel ID, right click on the channel and select “copy ID”.

Returning to the application, replace the “CHANNEL_ID” placeholder text with yours. After words, it should look something like `<#750828544917110936>`. Make sure you have the angled brackets and the “#” symbol.

Add a Role

I’ll also need to add a role. To do this, follow these steps:

  • In the top left, click on the server dropdown menu
  • Select “Server Settings”
  • Go to Roles on the left
  • Click the plus next to Roles in the middle
  • Type in the role name – I’m using the name “admin”
  • Click “Save changes”

To make yourself that role, right click on your Discord handle either in a message on the right sidebar, select Roles > admin.

Now that I have the role set up, someone can actually use the @admin to get my attention.

Create Discord Application

In order to create a Discord bot, I first need to create a Discord application. Follow these steps to do this:

After this is done, I can move on to the next step to create a bot.

Create Discord Bot and Install on Discord Server

The next step is to create a Discord Bot. Think of this as the profile for the bot. To create one, do the following:

  • On the left sidebar, click “Bot”
  • Click “Add Bot”
  • Feel free to change the name and the icon here
  • After you’re done, click “OAuth2” on the left sidebar
  • Under scopes, select “bot”
  • Scroll down to permissions and select “Send Messages” and “Read Message History”
  • Scroll up and click “copy” to copy the generated OAuth url
  • Paste it in a new tab in your browser
  • It will ask you which server you want to add it to. Note: you can only add bots to servers where you have the “Manage Server” permissions. Since we created our own, we do. Add it to the server you created earlier.
  • Click “Continue”
  • Confirm that you want to allow the bot to send messages and click “Authorize”

Great! Now the Discord bot is created.

Before I leave the Discord Developer Portal, I need one last thing: the Discord Bot auth token. To see it, follow these steps:

  • Click “Bot” on the left sidebar again
  • Next to the bot icon, look for the token
  • Click “copy”

I’m going to save this now because I’ll need it later when I run the application locally. Also, a friendly reminder to not commit this to git. You don’t want your auth token to get in the wrong hands!

Build Code

I am ready to build my project for testing locally. To this, I can run:

 shell cargo build 

If the compiler is happy with my code, it will output my code under /target/debug/ and contain an executable using the name key in the Cargo.toml. In my case, this is discord-help-bot.

Run Locally

It’s time to run the executable locally and see if my bot starts up as expected. I will run the command:

 shell DISCORD_TOKEN=<use your token here> ./target/debug/discord-help-bot 

I’ll replace “<use your token here>” with my token from earlier. This makes the token available as an environment variable to the application.

If it worked, you should see a message printed to the terminal saying “BotName is connected!” where “BotName” shows the name of your bot according to what you named it.

Test Bot on Discord Server

The moment I’ve been waiting for – testing my bot on my Discord server. With the bot still running from the previous step, I will open my Discord server where the bot is installed and send the message “!help” in the #general channel. And it works! I see the help message I wrote earlier posted to the channel almost immediately by my bot.

Woohoo! Mission accomplished.


Congratulations on making it through this project with me! I had a lot of fun and hope you did as well. I built a basic Discord bot with Rust and tested it on my Discord server by running it locally.

If you’d like to see a full-working version of this, you can check it out here on GitHub. If you want to make this better, I encourage you to open a pull request! You can ask questions there in an issue or open an issue if you find a bug. All contributions are welcome!

Next Steps

If you’d like to continue hacking on this project further, here are a few ideas:

  • Print a message to the console along with the username of the person who interacted with the bot
  • Add an avatar/icon to the bot
  • Add a second command to the bot
  • Deploy the bot

Let me know if you do this or something similar. We’d love to see what you build.

Resources for Learning More Rust

Looking for more ways to develop your Rust skills? Here are a few recommendations for continuing your learning:

Thanks for reading. Happy coding!

Special thanks to the maintainers of Serenity for the project examples and Will Harris’ article “How to Add a Bot to Discord” both of which made writing this tutorial possible.

To learn more about Facebook Open Source, visit our open source site, subscribe on Youtube, or follow us on Twitter and Facebook.

Facebook Developers

Continue Reading


Celebrating our Facebook Online Hackathon winners!



Thanks to everyone who joined our Facebook Live earlier today, where we announced the winners of our latest Facebook Online Hackathon!

For those who haven’t taken part yet, we’ve been running a series of virtual hackathons throughout the year, providing global innovators with opportunities to get immersed in Facebook products and build breakthrough software solutions.

This time around, participants were invited to tap into the power of one of three Facebook technology tracks – Messenger, Spark AR and – with a focus on projects that are designed to help build community and drive social impact.

For our winners, we were thrilled to offer up to US$21,000 in total cash prizes, alongside Oculus VR headsets.


The Messenger team asked participants to create messaging solutions that help people and businesses build lasting relationships through conversation.

Messaging has come a long way since the early days of texting, and we love partnering with our developer ecosystem to take these experiences even further.

With this in mind, we challenged our hackathon participants to build Messenger experiences that drive social impact and leverage some of our latest features, including Handover Protocol, One-Time Notifications, Private Replies and Quick Replies.

First place
US$3,000 total cash, Oculus VR headset per team member (max. 4) and Facebook expert mentoring
A travel companion for learning new languages

Second place
US$2,500 total cash
A messaging experience to help aspiring innovators build their coding skills

Third place
US$1,500 total cash
A solution designed to help small retailers build a chat-based customer service experience

Spark AR

Our ambition is to help Spark AR creators imagine, build and share augmented reality experiences that could potentially reach hundreds of millions of people on Facebook and Instagram.

Whether they were a beginner using Spark AR templates and libraries to create their first effect, or an experienced pro using customizations to build more interactive experiences — we tasked our hackathon participants to put their creativity to the test.

We invited all creators to build a World AR effect that was optimized for an exciting new product — Instagram Reels! Freshly available right at the start of the hackathon back in August, Reels brings over Instagram’s entire Spark AR effect catalogue to allow people to record and edit short videos with single or multiple AR effects.

In the hackathon, we were looking for submissions that demonstrated an imaginative use of features like plane tracking and segmentation in an effect that’s fun and tailored for short-form, creative performances on Reels.

First place
US$3,000 total cash, Oculus VR headset per team member (max. 4) and Facebook expert mentoring
Motion Effect Kit
An amazing set of effects for Instagram Reels with custom patches to extract movement directions and areas

Second place
US$2,500 total cash
Geometry – Real-Time VFX
A mesmerizing tool that enables Reels fans to create dynamic geometric shapes around them, that look especially cool while you’re dancing!

Third place
US$1,500 total cash
Mirror World
An effect that leverages plane tracking to give users the illusion of being surrounded by multiple mirrors in the real world

Honorable mention
Mysterious Wings
An effect that enables users to choose different sets of wings by changing their facial expression

Here at Facebook, we’re passionate about bringing the world closer together by advancing artificial intelligence (AI) – connecting people to what they care about; powering new, meaningful experiences; and advancing ‘the state-of-the-art’ through open research and accessible tooling.

To help us drive this vision around artificial intelligence forward, is Facebook’s AI technology that enables people to interact with products using voice and text.

For the hackathon, the team tasked participants with creating an engaging, voice-enabled app for consumers featuring natural language interactions that leverage the platform

We were looking for innovative solutions across a range of categories including day-to-day basics, social coordination, local discovery, media consumption, fitness, voice/AR navigation, voice games, shopping assistant and entertainment.

First place
US$3,000 total cash, Oculus VR headset per team member (max. 4) and Facebook expert mentoring
Fitness Voice
A NLP fitness trainer for web browsers

Second place
US$2,500 total cash
An AI assistant that automates meeting notes

Third place
US$1,500 total cash
Dance with AR
An AR dance teacher that teaches you new moves and leverages AI voice commands

Honorable Mentions
Handstand Quest
A solution applying natural language processing to help guide your fitness workout

VC4U: an aid for the blind
AR smart glasses that help identify objects for the visually impaired

Project Suavekeys
A voice-powered gaming controller

Huge congratulations to everyone who took part across our three Facebook technology tracks!

On behalf of the entire Facebook team, we’re so in awe of the way our growing hackathon community just keeps raising the bar.

But the opportunities don’t stop there!

We have a bunch of fresh and fun building experiences coming your way very soon, so stay tuned to the Facebook for Developers page for more updates!

In addition, did you know our annual Facebook Developer Circles Community Challenge is currently underway? The Challenge is another virtual hackathon – this time spanning Facebook Open Source tools in addition to Messenger, Spark AR and – with up to US$133,000 dollars in cash prizes up for grabs!

To get started and to check out the official rules, visit the Challenge webpage here.

From our whole team, we hope you stay safe and healthy, and we’re so honored to be supporting you as you #BuildwithFacebook.

Congratulations again to everyone who took part in the hackathon!

Facebook Developers

Continue Reading


Data Use Checkup Rolling Out Broadly to Facebook Platform Developers



Maintaining a safe, thriving developer ecosystem is critical to our mission of giving people the power to build community and bringing the world closer together. Recently, we have made changes to simplify our Platform Terms and Developer Policies so businesses and developers clearly understand their shared responsibility to safeguard data and respect people’s privacy when using our platform and tools.

These changes represent our strengthened commitment to protect people’s privacy and ensure developers have the tools and information they need to continue to use our platform responsibly.

Today, we’re announcing the broad launch of Data Use Checkup, a new annual workflow for Facebook platform developers that we began testing in April. Through Data Use Checkup, developers will be asked to review the permissions they have access to and commit that their API access and data use comply with the Facebook Platform Terms and Developer Policies within 60 days or risk losing their API access.

We are gradually rolling out Data Use Checkup in waves over the coming months. When you are enrolled in Data Use Checkup, you will receive information via a developer alert, an email to the registered contact, and in your Task List within the App Dashboard.

Developers who manage many apps will have the option to complete Data Use Checkup for multiple apps at once. You can access this flow by going to your “My Apps” page in the App Dashboard. From there, you will see all apps for which you are an admin, be able to filter down to a subset, and complete Data Use Checkup in bulk. This process will still require you to review each app you manage and the permissions you have access to and commit that your platform use complies with the Facebook Platform Terms and Developer Policies.

If you are not yet enrolled in Data Use Checkup, these are steps to take to prepare for the process:

  • Ensure you can access your app(s) in the App Dashboard. If you are unable to and need to regain admin status, click here.
  • Update contact details and app administrator designation for each app within your organization to receive the most up-to-date notifications. Any app admin will be able to complete the Data Use Checkup, so they should be in a position of authority to act on behalf of your organization. You can designate an app administrator within App Dashboard > Roles and update contact information within App Dashboard > Settings > Advanced.
  • Audit your apps and remove those that are no longer needed. To remove an app, go to App Dashboard > Settings > Advanced. This will ensure you’re only receiving developer alerts and notifications for apps that you need.
  • Review the permissions and features your apps have access to and remove any that are no longer needed in App Dashboard > App Review > My Permissions and Features.

Data Use Checkup is required for developers using many of our products and platforms across the Facebook Family of Apps. If you are developing on Oculus, here are specifics to consider and here is an update for businesses.

We know user privacy is just as important to our developer community as it is to us. Thank you for continuing to partner with us as we build a safer, more sustainable platform.

Facebook Developers

Continue Reading